]> granicus.if.org Git - curl/commitdiff
string formatting: fix 25+ printf-style format strings
authorYang Tse <yangsita@gmail.com>
Tue, 23 Jul 2013 13:59:07 +0000 (15:59 +0200)
committerYang Tse <yangsita@gmail.com>
Tue, 23 Jul 2013 23:21:26 +0000 (01:21 +0200)
12 files changed:
lib/connect.c
lib/ftp.c
lib/hash.c
lib/imap.c
lib/memdebug.c
lib/multi.c
lib/pipeline.c
lib/pop3.c
lib/security.c
lib/smtp.c
lib/ssh.c
lib/url.c

index be8c0e45a8c071dff4fda0140cafe493a4157794..2b5719d1234196ae501332191e5f95f9c7d38417 100644 (file)
@@ -1144,7 +1144,7 @@ CURLcode Curl_connecthost(struct connectdata *conn,  /* context */
 
   if(sockfd == CURL_SOCKET_BAD) {
     /* no good connect was made */
-    failf(data, "couldn't connect to %s at %s:%d",
+    failf(data, "couldn't connect to %s at %s:%ld",
           conn->bits.proxy?"proxy":"host",
           conn->bits.proxy?conn->proxy.name:conn->host.name, conn->port);
     return CURLE_COULDNT_CONNECT;
index 021796f0a1798453b29ce85ef71ae5f235144091..318bfa75a5c6be6ff1549a5d1223491586ccb32f 100644 (file)
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -828,7 +828,7 @@ static void _state(struct connectdata *conn,
 #if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
   if(ftpc->state != newstate)
     infof(conn->data, "FTP %p (line %d) state change from %s to %s\n",
-          ftpc, lineno, names[ftpc->state], names[newstate]);
+          (void *)ftpc, lineno, names[ftpc->state], names[newstate]);
 #endif
   ftpc->state = newstate;
 }
index 0a8e99ab2092e987f39436ae43b45a19423ce555..4a12e1a7b921b17f2fb862fcfa6c8a3b6d7caec9 100644 (file)
@@ -5,7 +5,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
  *
  * This software is licensed as described in the file COPYING, which
  * you should have received as part of this distribution. The terms
@@ -391,7 +391,7 @@ void Curl_hash_print(struct curl_hash *h,
     if(func)
       func(he->ptr);
     else
-      fprintf(stderr, " [%p]", he->ptr);
+      fprintf(stderr, " [%p]", (void *)he->ptr);
 
     he = Curl_hash_next_element(&iter);
   }
index b13bd3da745479caa9e435dc6370e713026820fc..3547a346735dd8b7abb862f4a1df506eceff7e93 100644 (file)
@@ -77,6 +77,7 @@
 #include "url.h"
 #include "rawstr.h"
 #include "curl_sasl.h"
+#include "warnless.h"
 
 #define _MPRINTF_REPLACE /* use our functions only */
 #include <curl/mprintf.h>
@@ -398,7 +399,7 @@ static void state(struct connectdata *conn, imapstate newstate)
 
   if(imapc->state != newstate)
     infof(conn->data, "IMAP %p state change from %s to %s\n",
-          imapc, names[imapc->state], names[newstate]);
+          (void *)imapc, names[imapc->state], names[newstate]);
 #endif
 
   imapc->state = newstate;
@@ -2069,7 +2070,7 @@ static CURLcode imap_sendf(struct connectdata *conn, const char *fmt, ...)
 
   /* Calculate the tag based on the connection ID and command ID */
   snprintf(imapc->resptag, sizeof(imapc->resptag), "%c%03d",
-           'A' + (conn->connection_id % 26), imapc->cmdid);
+           'A' + curlx_sltosi(conn->connection_id % 26), imapc->cmdid);
 
   /* Prefix the format with the tag */
   taggedfmt = aprintf("%s %s", imapc->resptag, fmt);
index 4e4f84cb267701e7c85af2625348965e4542dbd3..f9afae3a79b8d5a44167699b2118066a733a2a1c 100644 (file)
@@ -186,7 +186,9 @@ void *curl_domalloc(size_t wantedsize, int line, const char *source)
 
   if(source)
     curl_memlog("MEM %s:%d malloc(%zd) = %p\n",
-                source, line, wantedsize, mem ? mem->mem : 0);
+                source, line, wantedsize,
+                mem ? (void *)mem->mem : (void *)0);
+
   return (mem ? mem->mem : NULL);
 }
 
@@ -212,7 +214,9 @@ void *curl_docalloc(size_t wanted_elements, size_t wanted_size,
 
   if(source)
     curl_memlog("MEM %s:%d calloc(%zu,%zu) = %p\n",
-                source, line, wanted_elements, wanted_size, mem?mem->mem:0);
+                source, line, wanted_elements, wanted_size,
+                mem ? (void *)mem->mem : (void *)0);
+
   return (mem ? mem->mem : NULL);
 }
 
@@ -234,7 +238,7 @@ char *curl_dostrdup(const char *str, int line, const char *source)
 
   if(source)
     curl_memlog("MEM %s:%d strdup(%p) (%zu) = %p\n",
-                source, line, str, len, mem);
+                source, line, (void *)str, len, (void *)mem);
 
   return mem;
 }
@@ -259,7 +263,7 @@ wchar_t *curl_dowcsdup(const wchar_t *str, int line, const char *source)
 
   if(source)
     curl_memlog("MEM %s:%d wcsdup(%p) (%zu) = %p\n",
-                source, line, str, bsiz, mem);
+                source, line, (void *)str, bsiz, (void *)mem);
 
   return mem;
 }
@@ -295,7 +299,8 @@ void *curl_dorealloc(void *ptr, size_t wantedsize,
   mem = (Curl_crealloc)(mem, size);
   if(source)
     curl_memlog("MEM %s:%d realloc(%p, %zu) = %p\n",
-                source, line, ptr, wantedsize, mem?mem->mem:NULL);
+                source, line, (void *)ptr, wantedsize,
+                mem ? (void *)mem->mem : (void *)0);
 
   if(mem) {
     mem->size = wantedsize;
@@ -330,7 +335,7 @@ void curl_dofree(void *ptr, int line, const char *source)
   (Curl_cfree)(mem);
 
   if(source)
-    curl_memlog("MEM %s:%d free(%p)\n", source, line, ptr);
+    curl_memlog("MEM %s:%d free(%p)\n", source, line, (void *)ptr);
 }
 
 curl_socket_t curl_socket(int domain, int type, int protocol,
@@ -343,8 +348,10 @@ curl_socket_t curl_socket(int domain, int type, int protocol,
                     "FD %s:%d socket() = %zd\n" ;
 
   curl_socket_t sockfd = socket(domain, type, protocol);
+
   if(source && (sockfd != CURL_SOCKET_BAD))
     curl_memlog(fmt, source, line, sockfd);
+
   return sockfd;
 }
 
@@ -360,8 +367,10 @@ int curl_socketpair(int domain, int type, int protocol,
                     "FD %s:%d socketpair() = %zd %zd\n" ;
 
   int res = socketpair(domain, type, protocol, socket_vector);
+
   if(source && (0 == res))
     curl_memlog(fmt, source, line, socket_vector[0], socket_vector[1]);
+
   return res;
 }
 #endif
@@ -377,9 +386,12 @@ curl_socket_t curl_accept(curl_socket_t s, void *saddr, void *saddrlen,
 
   struct sockaddr *addr = (struct sockaddr *)saddr;
   curl_socklen_t *addrlen = (curl_socklen_t *)saddrlen;
+
   curl_socket_t sockfd = accept(s, addr, addrlen);
+
   if(source && (sockfd != CURL_SOCKET_BAD))
     curl_memlog(fmt, source, line, sockfd);
+
   return sockfd;
 }
 
@@ -408,9 +420,11 @@ FILE *curl_fopen(const char *file, const char *mode,
                  int line, const char *source)
 {
   FILE *res=fopen(file, mode);
+
   if(source)
     curl_memlog("FILE %s:%d fopen(\"%s\",\"%s\") = %p\n",
-                source, line, file, mode, res);
+                source, line, file, mode, (void *)res);
+
   return res;
 }
 
@@ -419,9 +433,11 @@ FILE *curl_fdopen(int filedes, const char *mode,
                   int line, const char *source)
 {
   FILE *res=fdopen(filedes, mode);
+
   if(source)
     curl_memlog("FILE %s:%d fdopen(\"%d\",\"%s\") = %p\n",
-                source, line, filedes, mode, res);
+                source, line, filedes, mode, (void *)res);
+
   return res;
 }
 #endif
@@ -433,9 +449,11 @@ int curl_fclose(FILE *file, int line, const char *source)
   assert(file != NULL);
 
   res=fclose(file);
+
   if(source)
     curl_memlog("FILE %s:%d fclose(%p)\n",
-                source, line, file);
+                source, line, (void *)file);
+
   return res;
 }
 
index e173fd64ff81cd93f7c29d3102be5680e9bf507c..cd15620203dff7fd6a69ba7cc481f078d0664e4f 100644 (file)
@@ -131,7 +131,7 @@ static void mstate(struct Curl_one_easy *easy, CURLMstate state
     infof(easy->easy_handle,
           "STATE: %s => %s handle %p; line %d (connection #%ld) \n",
           statename[oldstate], statename[easy->state],
-          (char *)easy, lineno, connection_id);
+          (void *)easy, lineno, connection_id);
   }
 #endif
   if(state == CURLM_STATE_COMPLETED)
@@ -966,7 +966,7 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
        we're using gets cleaned up and we're left with nothing. */
     if(data->state.pipe_broke) {
       infof(data, "Pipe broke: handle 0x%p, url = %s\n",
-            easy, data->state.path);
+            (void *)easy, data->state.path);
 
       if(easy->state < CURLM_STATE_COMPLETED) {
         /* Head back to the CONNECT state */
index 624fc4257b6906079732853da78f12afceac1476..73ac9c5a3eca978d5b935119bf2439bdc52d29e1 100644 (file)
@@ -6,6 +6,7 @@
  *                             \___|\___/|_| \_\_____|
  *
  * Copyright (C) 2013, Linus Nielsen Feltzing, <linus@haxx.se>
+ * Copyright (C) 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
  *
  * This software is licensed as described in the file COPYING, which
  * you should have received as part of this distribution. The terms
@@ -84,9 +85,10 @@ bool Curl_pipeline_penalized(struct SessionHandle *data,
        (curl_off_t)conn->chunk.datasize > chunk_penalty_size)
       penalized = TRUE;
 
-    infof(data, "Conn: %d (%p) Receive pipe weight: (%d/%d), penalized: %d\n",
-          conn->connection_id, conn, recv_size,
-          conn->chunk.datasize, penalized);
+    infof(data, "Conn: %ld (%p) Receive pipe weight: (%" FORMAT_OFF_T
+          "/%zd), penalized: %s\n",
+          conn->connection_id, (void *)conn, recv_size,
+          conn->chunk.datasize, penalized?"TRUE":"FALSE");
     return penalized;
   }
   return FALSE;
@@ -101,7 +103,7 @@ CURLcode Curl_add_handle_to_pipeline(struct SessionHandle *handle,
 
   pipeline = conn->send_pipe;
 
-  infof(conn->data, "Adding handle: conn: %p\n", conn);
+  infof(conn->data, "Adding handle: conn: %p\n", (void *)conn);
   infof(conn->data, "Adding handle: send: %d\n", conn->send_pipe->size);
   infof(conn->data, "Adding handle: recv: %d\n", conn->recv_pipe->size);
   rc = Curl_addHandleToPipeline(handle, pipeline);
@@ -111,7 +113,7 @@ CURLcode Curl_add_handle_to_pipeline(struct SessionHandle *handle,
     conn->writechannel_inuse = FALSE; /* not in use yet */
 #ifdef DEBUGBUILD
     infof(conn->data, "%p is at send pipe head!\n",
-          conn->send_pipe->head->ptr);
+          (void *)conn->send_pipe->head->ptr);
 #endif
     Curl_expire(conn->send_pipe->head->ptr, 1);
   }
@@ -144,7 +146,7 @@ void Curl_move_handle_from_send_to_recv_pipe(struct SessionHandle *handle,
         conn->writechannel_inuse = FALSE; /* not used now */
 #ifdef DEBUGBUILD
         infof(conn->data, "%p is at send pipe head B!\n",
-              conn->send_pipe->head->ptr);
+              (void *)conn->send_pipe->head->ptr);
 #endif
         Curl_expire(conn->send_pipe->head->ptr, 1);
       }
@@ -320,9 +322,9 @@ void print_pipeline(struct connectdata *conn)
     curr = cb_ptr->conn_list->head;
     while(curr) {
       conn = curr->ptr;
-      infof(data, "- Conn %d (%p) send_pipe: %d, recv_pipe: %d\n",
+      infof(data, "- Conn %ld (%p) send_pipe: %zd, recv_pipe: %zd\n",
             conn->connection_id,
-            conn,
+            (void *)conn,
             conn->send_pipe->size,
             conn->recv_pipe->size);
       curr = curr->next;
index 6f188b254b213526c82aace7e46002cec257606b..0099a509b5648b9efc77f4d1b06c486359ed1bac 100644 (file)
@@ -382,7 +382,7 @@ static void state(struct connectdata *conn, pop3state newstate)
 
   if(pop3c->state != newstate)
     infof(conn->data, "POP3 %p state change from %s to %s\n",
-          pop3c, names[pop3c->state], names[newstate]);
+          (void *)pop3c, names[pop3c->state], names[newstate]);
 #endif
 
   pop3c->state = newstate;
index 3c46953cbfc2c6049eee023582a2d5846114f32e..495a4969398f136ac237e232b58b63ca594e8ba7 100644 (file)
@@ -10,7 +10,7 @@
  * Copyright (c) 1998, 1999 Kungliga Tekniska Högskolan
  * (Royal Institute of Technology, Stockholm, Sweden).
  *
- * Copyright (C) 2001 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 2001 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
  *
  * All rights reserved.
  *
@@ -498,7 +498,7 @@ static CURLcode choose_mech(struct connectdata *conn)
     /* We have no mechanism with a NULL name but keep this check */
     DEBUGASSERT(mech_name != NULL);
     if(mech_name == NULL) {
-      infof(data, "Skipping mechanism with empty name (%p)\n", mech);
+      infof(data, "Skipping mechanism with empty name (%p)\n", (void *)mech);
       continue;
     }
     tmp_allocation = realloc(conn->app_data, (*mech)->size);
index 065c7037f3ed8a9b890f3a8feb6ab620cf3840a1..04b33d0c4af7a5b903a6b01c23a7d4dc7d2096bd 100644 (file)
@@ -337,7 +337,7 @@ static void state(struct connectdata *conn, smtpstate newstate)
 
   if(smtpc->state != newstate)
     infof(conn->data, "SMTP %p state change from %s to %s\n",
-          smtpc, names[smtpc->state], names[newstate]);
+          (void *)smtpc, names[smtpc->state], names[newstate]);
 #endif
 
   smtpc->state = newstate;
index 9b37ad69e2fa66c68b0e59f707135d12149ff1f0..422357be9848085f549c9acad77e53f61993368e 100644 (file)
--- a/lib/ssh.c
+++ b/lib/ssh.c
@@ -392,7 +392,7 @@ static void state(struct connectdata *conn, sshstate nowstate)
 #if defined(DEBUGBUILD) && !defined(CURL_DISABLE_VERBOSE_STRINGS)
   if(sshc->state != nowstate) {
     infof(conn->data, "SFTP %p state change from %s to %s\n",
-          sshc, names[sshc->state], names[nowstate]);
+          (void *)sshc, names[sshc->state], names[nowstate]);
   }
 #endif
 
index a8f2a09852e5e9d4972d6264fae5950ea3eed43f..347092d597a23bc832d631b122b3ec22ccaae3b0 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -2574,7 +2574,7 @@ CURLcode Curl_disconnect(struct connectdata *conn, bool dead_connection)
     conn->handler->disconnect(conn, dead_connection);
 
     /* unlink ourselves! */
-  infof(data, "Closing connection %d\n", conn->connection_id);
+  infof(data, "Closing connection %ld\n", conn->connection_id);
   Curl_conncache_remove_conn(data->state.conn_cache, conn);
 
 #if defined(USE_LIBIDN)
@@ -2875,7 +2875,8 @@ ConnectionExists(struct SessionHandle *data,
     size_t best_pipe_len = max_pipe_len;
     struct curl_llist_element *curr;
 
-    infof(data, "Found bundle for host %s: %p\n", needle->host.name, bundle);
+    infof(data, "Found bundle for host %s: %p\n",
+          needle->host.name, (void *)bundle);
 
     /* We can't pipe if we don't know anything about the server */
     if(canPipeline && !bundle->server_supports_pipelining) {
@@ -2911,7 +2912,7 @@ ConnectionExists(struct SessionHandle *data,
 
         if(dead) {
           check->data = data;
-          infof(data, "Connection %d seems to be dead!\n",
+          infof(data, "Connection %ld seems to be dead!\n",
                 check->connection_id);
 
           /* disconnect resources */
@@ -5335,7 +5336,7 @@ static CURLcode create_conn(struct SessionHandle *data,
   if(reuse && !force_reuse && IsPipeliningPossible(data, conn_temp)) {
     size_t pipelen = conn_temp->send_pipe->size + conn_temp->recv_pipe->size;
     if(pipelen > 0) {
-      infof(data, "Found connection %d, with requests in the pipe (%d)\n",
+      infof(data, "Found connection %ld, with requests in the pipe (%zd)\n",
             conn_temp->connection_id, pipelen);
 
       if(conn_temp->bundle->num_connections < max_host_connections &&