]> granicus.if.org Git - curl/commitdiff
examples: Avoid reserved names in hiperfifo examples
authorBrad Spencer <bspencer@blackberry.com>
Thu, 18 Jul 2019 18:25:25 +0000 (15:25 -0300)
committerJay Satiro <raysatiro@yahoo.com>
Fri, 26 Jul 2019 02:23:40 +0000 (22:23 -0400)
- Trade in __attribute__((unused)) for the classic (void)x to silence
  unused symbols.

Because the classic way is not gcc specific. Also because the prior
method mapped to symbol _Unused, which starts with _ and a capital
letter which is reserved.

Assisted-by: The Infinnovation team
Bug: https://github.com/curl/curl/issues/4120#issuecomment-512542108

Closes https://github.com/curl/curl/pull/4153

docs/examples/ephiperfifo.c
docs/examples/hiperfifo.c

index bc4b0f057ea0eb220709d78b1e3cb150ac484a9c..657b6125727e3a29a9cd9ee250d4a362ea0d00c6 100644 (file)
@@ -73,12 +73,6 @@ callback.
 
 #include <curl/curl.h>
 
-#ifdef __GNUC__
-#define _Unused __attribute__((unused))
-#else
-#define _Unused
-#endif
-
 #define MSG_OUT stdout /* Send info to stdout, change to stderr if you want */
 
 
@@ -336,22 +330,21 @@ static int sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void *sockp)
 
 
 /* CURLOPT_WRITEFUNCTION */
-static size_t write_cb(void *ptr _Unused, size_t size, size_t nmemb,
-                       void *data)
+static size_t write_cb(void *ptr, size_t size, size_t nmemb, void *data)
 {
-  size_t realsize = size * nmemb;
-  (void)_Unused;
+  (void)ptr;
   (void)data;
-
-  return realsize;
+  return size * nmemb;
 }
 
 
 /* CURLOPT_PROGRESSFUNCTION */
-static int prog_cb(void *p, double dltotal, double dlnow, double ult _Unused,
-                   double uln _Unused)
+static int prog_cb(void *p, double dltotal, double dlnow, double ult,
+                   double uln)
 {
   ConnInfo *conn = (ConnInfo *)p;
+  (void)ult;
+  (void)uln;
 
   fprintf(MSG_OUT, "Progress: %s (%g/%g)\n", conn->url, dlnow, dltotal);
   return 0;
@@ -469,12 +462,14 @@ void SignalHandler(int signo)
   }
 }
 
-int main(int argc _Unused, char **argv _Unused)
+int main(int argc, char **argv)
 {
   GlobalInfo g;
   struct itimerspec its;
   struct epoll_event ev;
   struct epoll_event events[10];
+  (void)argc;
+  (void)argv;
 
   g_should_exit_ = 0;
   signal(SIGINT, SignalHandler);
@@ -547,5 +542,6 @@ int main(int argc _Unused, char **argv _Unused)
   fflush(MSG_OUT);
 
   curl_multi_cleanup(g.multi);
+  clean_fifo(&g);
   return 0;
 }
index a50522a8e442537c10c185c158594dba2215937c..6f176365b59b6868f7a8b80e4d13762ac50a2793 100644 (file)
@@ -72,12 +72,6 @@ callback.
 #include <errno.h>
 #include <sys/cdefs.h>
 
-#ifdef __GNUC__
-#define _Unused __attribute__((unused))
-#else
-#define _Unused
-#endif
-
 #define MSG_OUT stdout /* Send info to stdout, change to stderr if you want */
 
 
@@ -143,9 +137,10 @@ static void mcode_or_die(const char *where, CURLMcode code)
 
 
 /* Update the event timer after curl_multi library calls */
-static int multi_timer_cb(CURLM *multi _Unused, long timeout_ms, GlobalInfo *g)
+static int multi_timer_cb(CURLM *multi, long timeout_ms, GlobalInfo *g)
 {
   struct timeval timeout;
+  (void)multi;
 
   timeout.tv_sec = timeout_ms/1000;
   timeout.tv_usec = (timeout_ms%1000)*1000;
@@ -220,10 +215,12 @@ static void event_cb(int fd, short kind, void *userp)
 
 
 /* Called by libevent when our timeout expires */
-static void timer_cb(int fd _Unused, short kind _Unused, void *userp)
+static void timer_cb(int fd, short kind, void *userp)
 {
   GlobalInfo *g = (GlobalInfo *)userp;
   CURLMcode rc;
+  (void)fd;
+  (void)kind;
 
   rc = curl_multi_socket_action(g->multi,
                                   CURL_SOCKET_TIMEOUT, 0, &g->still_running);
@@ -303,22 +300,21 @@ static int sock_cb(CURL *e, curl_socket_t s, int what, void *cbp, void *sockp)
 
 
 /* CURLOPT_WRITEFUNCTION */
-static size_t write_cb(void *ptr _Unused, size_t size, size_t nmemb,
-                       void *data)
+static size_t write_cb(void *ptr, size_t size, size_t nmemb, void *data)
 {
-  size_t realsize = size * nmemb;
-  (void)_Unused;
+  (void)ptr;
   (void)data;
-
-  return realsize;
+  return size * nmemb;
 }
 
 
 /* CURLOPT_PROGRESSFUNCTION */
-static int prog_cb(void *p, double dltotal, double dlnow, double ult _Unused,
-                   double uln _Unused)
+static int prog_cb(void *p, double dltotal, double dlnow, double ult,
+                   double uln)
 {
   ConnInfo *conn = (ConnInfo *)p;
+  (void)ult;
+  (void)uln;
 
   fprintf(MSG_OUT, "Progress: %s (%g/%g)\n", conn->url, dlnow, dltotal);
   return 0;
@@ -361,12 +357,14 @@ static void new_conn(char *url, GlobalInfo *g)
 }
 
 /* This gets called whenever data is received from the fifo */
-static void fifo_cb(int fd _Unused, short event _Unused, void *arg)
+static void fifo_cb(int fd, short event, void *arg)
 {
   char s[1024];
   long int rv = 0;
   int n = 0;
   GlobalInfo *g = (GlobalInfo *)arg;
+  (void)fd;
+  (void)event;
 
   do {
     s[0]='\0';
@@ -427,9 +425,11 @@ static void clean_fifo(GlobalInfo *g)
     unlink(fifo);
 }
 
-int main(int argc _Unused, char **argv _Unused)
+int main(int argc, char **argv)
 {
   GlobalInfo g;
+  (void)argc;
+  (void)argv;
 
   memset(&g, 0, sizeof(GlobalInfo));
   g.evbase = event_base_new();