]> granicus.if.org Git - curl/commitdiff
fix printf-style format strings
authorYang Tse <yangsita@gmail.com>
Thu, 4 Feb 2010 19:44:31 +0000 (19:44 +0000)
committerYang Tse <yangsita@gmail.com>
Thu, 4 Feb 2010 19:44:31 +0000 (19:44 +0000)
15 files changed:
lib/connect.c
lib/easy.c
lib/ftp.c
lib/http.c
lib/ldap.c
lib/mprintf.c
lib/multi.c
lib/qssl.c
lib/sendf.c
lib/socks.c
lib/ssh.c
lib/telnet.c
lib/tftp.c
lib/transfer.c
lib/url.c

index 1d2947488c53e6bc3ab1b6a025b32f39570adaf2..5e94b8673176c21af43899ae7ff2a1fbb4f96f41 100644 (file)
@@ -397,13 +397,13 @@ static CURLcode bindlocal(struct connectdata *conn,
               error, Curl_strerror(conn, error));
         return CURLE_INTERFACE_FAILED;
       }
-      infof(data, "Local port: %d\n", port);
+      infof(data, "Local port: %hu\n", port);
       conn->bits.bound = TRUE;
       return CURLE_OK;
     }
 
     if(--portnum > 0) {
-      infof(data, "Bind to local port %d failed, trying next\n", port);
+      infof(data, "Bind to local port %hu failed, trying next\n", port);
       port++; /* try next port */
       /* We re-use/clobber the port variable here below */
       if(sock->sa_family == AF_INET)
index 06cd3fb5003ee72f198821e5770751af15fc564f..a90e0bd3a4c5753b8ceb4025de7362c842e7f0ae 100644 (file)
@@ -882,8 +882,8 @@ CURLcode Curl_convert_to_network(struct SessionHandle *data,
     rc = data->set.convtonetwork(buffer, length);
     if(rc != CURLE_OK) {
       failf(data,
-            "CURLOPT_CONV_TO_NETWORK_FUNCTION callback returned %i: %s",
-            rc, curl_easy_strerror(rc));
+            "CURLOPT_CONV_TO_NETWORK_FUNCTION callback returned %d: %s",
+            (int)rc, curl_easy_strerror(rc));
     }
     return(rc);
   }
@@ -943,8 +943,8 @@ CURLcode Curl_convert_from_network(struct SessionHandle *data,
     rc = data->set.convfromnetwork(buffer, length);
     if(rc != CURLE_OK) {
       failf(data,
-            "CURLOPT_CONV_FROM_NETWORK_FUNCTION callback returned %i: %s",
-            rc, curl_easy_strerror(rc));
+            "CURLOPT_CONV_FROM_NETWORK_FUNCTION callback returned %d: %s",
+            (int)rc, curl_easy_strerror(rc));
     }
     return(rc);
   }
@@ -1004,8 +1004,8 @@ CURLcode Curl_convert_from_utf8(struct SessionHandle *data,
     rc = data->set.convfromutf8(buffer, length);
     if(rc != CURLE_OK) {
       failf(data,
-            "CURLOPT_CONV_FROM_UTF8_FUNCTION callback returned %i: %s",
-            rc, curl_easy_strerror(rc));
+            "CURLOPT_CONV_FROM_UTF8_FUNCTION callback returned %d: %s",
+            (int)rc, curl_easy_strerror(rc));
     }
     return(rc);
   }
index 6a9573ab5740185bf66f73da15ef855754ee8500..862b3402f6250305335dc9a460274295bf949848 100644 (file)
--- a/lib/ftp.c
+++ b/lib/ftp.c
@@ -882,7 +882,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
         /* The requested bind address is not local.  Use the address used for
          * the control connection instead and restart the port loop
          */
-        failf(data, "bind(port=%i) failed: %s", port,
+        failf(data, "bind(port=%hu) failed: %s", port,
               Curl_strerror(conn, error) );
 
         sslen = sizeof(ss);
@@ -896,7 +896,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
         continue;
       }
       else if(error != EADDRINUSE && error != EACCES) {
-        failf(data, "bind(port=%i) failed: %s", port,
+        failf(data, "bind(port=%hu) failed: %s", port,
               Curl_strerror(conn, error) );
         sclose(portsock);
         return CURLE_FTP_PORT_FAILED;
@@ -978,7 +978,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
        * EPRT |2|1080::8:800:200C:417A|5282|
        */
 
-      result = Curl_pp_sendf(&ftpc->pp, "%s |%d|%s|%d|", mode[fcmd],
+      result = Curl_pp_sendf(&ftpc->pp, "%s |%d|%s|%hu|", mode[fcmd],
                              sa->sa_family == AF_INET?1:2,
                              myhost, port);
       if(result)
@@ -999,7 +999,7 @@ static CURLcode ftp_state_use_port(struct connectdata *conn,
         source++;
       }
       *dest = 0;
-      snprintf(dest, 20, ",%d,%d", port>>8, port&0xff);
+      snprintf(dest, 20, ",%d,%d", (int)(port>>8), (int)(port&0xff));
 
       result = Curl_pp_sendf(&ftpc->pp, "%s %s", mode[fcmd], tmp);
       if(result)
@@ -1623,7 +1623,7 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
       (unsigned short)conn->port; /* we connect to the proxy's port */
 
     if(!addr) {
-      failf(data, "Can't resolve proxy host %s:%d",
+      failf(data, "Can't resolve proxy host %s:%hu",
             conn->proxy.name, connectport);
       return CURLE_FTP_CANT_GET_HOST;
     }
@@ -1638,7 +1638,7 @@ static CURLcode ftp_state_pasv_resp(struct connectdata *conn,
     connectport = newport; /* we connect to the remote port */
 
     if(!addr) {
-      failf(data, "Can't resolve new host %s:%d", newhost, connectport);
+      failf(data, "Can't resolve new host %s:%hu", newhost, connectport);
       return CURLE_FTP_CANT_GET_HOST;
     }
   }
@@ -2420,7 +2420,7 @@ static CURLcode ftp_statemach_act(struct connectdata *conn)
           break;
         default:
           failf(data, "unsupported parameter to CURLOPT_FTPSSLAUTH: %d",
-                data->set.ftpsslauth);
+                (int)data->set.ftpsslauth);
           return CURLE_FAILED_INIT; /* we don't know what to do */
         }
         PPSENDF(&ftpc->pp, "AUTH %s", ftpauth[ftpc->count1]);
@@ -3367,7 +3367,7 @@ static CURLcode ftp_nextconnect(struct connectdata *conn)
     result = Curl_setup_transfer(conn, -1, -1, FALSE, NULL, -1, NULL);
 
   /* end of transfer */
-  DEBUGF(infof(data, "DO-MORE phase ends with %d\n", result));
+  DEBUGF(infof(data, "DO-MORE phase ends with %d\n", (int)result));
 
   return result;
 }
index 15943202e540011f8a37453d2002d45bb157359a..9820b8f629cb9867195c65e960364de92a5af92e 100644 (file)
@@ -1305,7 +1305,7 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
       char *host_port;
       Curl_send_buffer *req_buffer;
 
-      infof(data, "Establish HTTP proxy tunnel to %s:%d\n",
+      infof(data, "Establish HTTP proxy tunnel to %s:%hu\n",
             hostname, remote_port);
 
       if(data->req.newurl) {
@@ -1322,7 +1322,7 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
       if(!req_buffer)
         return CURLE_OUT_OF_MEMORY;
 
-      host_port = aprintf("%s:%d", hostname, remote_port);
+      host_port = aprintf("%s:%hu", hostname, remote_port);
       if(!host_port) {
         free(req_buffer);
         return CURLE_OUT_OF_MEMORY;
@@ -1357,7 +1357,7 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
         /* BLOCKING */
         result =
           Curl_add_bufferf(req_buffer,
-                      "CONNECT %s:%d HTTP/%s\r\n"
+                      "CONNECT %s:%hu HTTP/%s\r\n"
                       "%s"  /* Host: */
                       "%s"  /* Proxy-Authorization */
                       "%s"  /* User-Agent */
@@ -1525,7 +1525,7 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
                   keepon = FALSE;
                 }
                 else
-                  infof(data, "Read %d bytes of chunk, continue\n",
+                  infof(data, "Read %zd bytes of chunk, continue\n",
                         tookcareof);
               }
             }
@@ -1596,7 +1596,7 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
                            attention so that this is cleared again when this
                            function returns! */
                         k->ignorebody = TRUE;
-                        infof(data, "%d bytes of chunk left\n", gotbytes-i);
+                        infof(data, "%zd bytes of chunk left\n", gotbytes-i);
 
                         if(line_start[1] == '\n') {
                           /* this can only be a LF if the letter at index 0
@@ -1615,7 +1615,7 @@ CURLcode Curl_proxyCONNECT(struct connectdata *conn,
                           keepon = FALSE;
                         }
                         else
-                          infof(data, "Read %d bytes of chunk, continue\n",
+                          infof(data, "Read %zd bytes of chunk, continue\n",
                                 gotbytes);
                       }
                       else {
@@ -2284,7 +2284,7 @@ CURLcode Curl_http(struct connectdata *conn, bool *done)
                                     host,
                                     conn->bits.ipv6_ip?"]":"");
     else
-      conn->allocptr.host = aprintf("Host: %s%s%s:%d\r\n",
+      conn->allocptr.host = aprintf("Host: %s%s%s:%hu\r\n",
                                     conn->bits.ipv6_ip?"[":"",
                                     host,
                                     conn->bits.ipv6_ip?"]":"",
index 1b86e5925191fda9a6294511da77702807bd22a4..fcd56b9e9054b65ff3577a85ead826d5c5418c82 100644 (file)
@@ -262,7 +262,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
     }
     server = ldapssl_init(conn->host.name, (int)conn->port, 1);
     if(server == NULL) {
-      failf(data, "LDAP local: Cannot connect to %s:%d",
+      failf(data, "LDAP local: Cannot connect to %s:%hu",
               conn->host.name, conn->port);
       status = CURLE_COULDNT_CONNECT;
       goto quit;
@@ -302,7 +302,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
     }
     server = ldap_init(conn->host.name, (int)conn->port);
     if(server == NULL) {
-      failf(data, "LDAP local: Cannot connect to %s:%d",
+      failf(data, "LDAP local: Cannot connect to %s:%hu",
               conn->host.name, conn->port);
       status = CURLE_COULDNT_CONNECT;
       goto quit;
@@ -337,7 +337,7 @@ static CURLcode Curl_ldap(struct connectdata *conn, bool *done)
   } else {
     server = ldap_init(conn->host.name, (int)conn->port);
     if(server == NULL) {
-      failf(data, "LDAP local: Cannot connect to %s:%d",
+      failf(data, "LDAP local: Cannot connect to %s:%hu",
               conn->host.name, conn->port);
       status = CURLE_COULDNT_CONNECT;
       goto quit;
index ceafb519756dc06765fdf28b90c2d6149a284434..b0f1a9267703bc9f1da5007afce0396da38d7f4d 100644 (file)
@@ -5,7 +5,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1999 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1999 - 2010, 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
@@ -1219,7 +1219,7 @@ int main()
 
   curl_mprintf("%3d %5d\n", 10, 1998);
 
-  ptr=curl_maprintf("test this then baby %s%s%s%s%s%s %d %d %d loser baby get a hit in yer face now!", "", "pretty long string pretty long string pretty long string pretty long string pretty long string", "/", "/", "/", "pretty long string", 1998, 1999, 2001);
+  ptr=curl_maprintf("test this then baby %s%s%s%s%s%s %d %d %d loser baby get a kiss in yer face now!", "", "pretty long string pretty long string pretty long string pretty long string pretty long string", "/", "/", "/", "pretty long string", 1998, 1999, 2001);
 
   puts(ptr);
 
index 02f84aa7d692c1b2a7666a5f373eae3ffa58b3af..e4e1ce8c9bee33a5c75a7ac08b0cd9065d30579c 100644 (file)
@@ -567,7 +567,7 @@ static void debug_print_sock_hash(void *p)
   struct Curl_sh_entry *sh = (struct Curl_sh_entry *)p;
 
   fprintf(stderr, " [easy %p/magic %x/socket %d]",
-          (void *)sh->easy, sh->easy->magic, sh->socket);
+          (void *)sh->easy, sh->easy->magic, (int)sh->socket);
 }
 #endif
 
@@ -1131,12 +1131,12 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
     case CURLM_STATE_WAITDO:
       /* Wait for our turn to DO when we're pipelining requests */
 #ifdef DEBUGBUILD
-      infof(easy->easy_handle, "Conn %ld send pipe %d inuse %d athead %d\n",
+      infof(easy->easy_handle, "Conn %ld send pipe %zu inuse %d athead %d\n",
             easy->easy_conn->connectindex,
             easy->easy_conn->send_pipe->size,
-            easy->easy_conn->writechannel_inuse,
+            easy->easy_conn->writechannel_inuse?1:0,
             isHandleAtHead(easy->easy_handle,
-                           easy->easy_conn->send_pipe));
+                           easy->easy_conn->send_pipe)?1:0);
 #endif
       if(!easy->easy_conn->writechannel_inuse &&
          isHandleAtHead(easy->easy_handle,
@@ -1319,12 +1319,12 @@ static CURLMcode multi_runsingle(struct Curl_multi *multi,
       }
 #ifdef DEBUGBUILD
       else {
-        infof(easy->easy_handle, "Conn %ld recv pipe %d inuse %d athead %d\n",
+        infof(easy->easy_handle, "Conn %ld recv pipe %zu inuse %d athead %d\n",
               easy->easy_conn->connectindex,
               easy->easy_conn->recv_pipe->size,
-              easy->easy_conn->readchannel_inuse,
+              easy->easy_conn->readchannel_inuse?1:0,
               isHandleAtHead(easy->easy_handle,
-                             easy->easy_conn->recv_pipe));
+                             easy->easy_conn->recv_pipe)?1:0);
       }
 #endif
       break;
index 5ef8037db4b7acb3a0c26195b7661574c1777196..a45b9a1807182cfb19ad67fd953f577acf73acd0 100644 (file)
@@ -5,7 +5,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2010, 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
@@ -289,7 +289,7 @@ static int Curl_qsossl_close_one(struct ssl_connect_data * conn,
     }
 
     /* An SSL error. */
-    failf(data, "SSL_Destroy() returned error %d", SSL_Strerror(rc, NULL));
+    failf(data, "SSL_Destroy() returned error %s", SSL_Strerror(rc, NULL));
     return -1;
   }
 
@@ -406,7 +406,7 @@ ssize_t Curl_qsossl_send(struct connectdata * conn, int sockindex,
     }
 
     /* An SSL error. */
-    failf(conn->data, "SSL_Write() returned error %d",
+    failf(conn->data, "SSL_Write() returned error %s",
           SSL_Strerror(rc, NULL));
     return -1;
   }
index e2afd7170fb88d51bc7c6d904a951891b85cbac4..0d6764cbfe55c4f705748b6e01bb753753c22733 100644 (file)
@@ -343,8 +343,8 @@ static CURLcode pausewrite(struct SessionHandle *data,
   /* mark the connection as RECV paused */
   k->keepon |= KEEP_RECV_PAUSE;
 
-  DEBUGF(infof(data, "Pausing with %d bytes in buffer for type %02x\n",
-               (int)len, type));
+  DEBUGF(infof(data, "Pausing with %zu bytes in buffer for type %02x\n",
+               len, type));
 
   return CURLE_OK;
 }
@@ -426,7 +426,7 @@ CURLcode Curl_client_write(struct connectdata *conn,
       return pausewrite(data, type, ptr, len);
 
     if(wrote != len) {
-      failf(data, "Failed writing body (%d != %d)", (int)wrote, (int)len);
+      failf(data, "Failed writing body (%zu != %zu)", wrote, len);
       return CURLE_WRITE_ERROR;
     }
   }
index a1ead128f6565a23e9f2b6e9407cbdee5d4532e3..d68c3df34a3904a3ab914c3a50cb776fcfc2af97 100644 (file)
@@ -5,7 +5,7 @@
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
- * Copyright (C) 1998 - 2009, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2010, 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
@@ -393,7 +393,7 @@ CURLcode Curl_SOCKS5(const char *proxy_name,
   if(!socks5_resolve_local && hostname_len > 255)
   {
     infof(conn->data,"SOCKS5: server resolving disabled for hostnames of "
-          "length > 255 [actual len=%d]\n", hostname_len);
+          "length > 255 [actual len=%zu]\n", hostname_len);
     socks5_resolve_local = TRUE;
   }
 
index edc89fde8f18a7ad14551867ca4c6b9f753a65b5..a143f3bb9b3727eb94bff0ce57b8903a7c464798 100644 (file)
--- a/lib/ssh.c
+++ b/lib/ssh.c
@@ -965,7 +965,8 @@ static CURLcode ssh_statemach_act(struct connectdata *conn, bool *block)
         err = libssh2_sftp_last_error(sshc->sftp_session);
         result = sftp_libssh2_error_to_CURLE(err);
         sshc->actualcode = result?result:CURLE_SSH;
-        DEBUGF(infof(data, "error = %d makes libcurl = %d\n", err, result));
+        DEBUGF(infof(data, "error = %d makes libcurl = %d\n",
+                     err, (int)result));
         state(conn, SSH_STOP);
         break;
       }
@@ -2491,7 +2492,7 @@ static CURLcode ssh_connect(struct connectdata *conn, bool *done)
 
 #ifdef CURL_LIBSSH2_DEBUG
   libssh2_trace(ssh->ssh_session, ~0);
-  infof(data, "SSH socket: %d\n", sock);
+  infof(data, "SSH socket: %d\n", (int)sock);
 #endif /* CURL_LIBSSH2_DEBUG */
 
   state(conn, SSH_S_STARTUP);
index 335bfe03b64382e0746e66a6315c958b56d1e1b3..0a87375218241ef1c01dba056bb3ab341fe82ccf 100644 (file)
@@ -729,7 +729,7 @@ static void printsub(struct SessionHandle *data,
           else if(CURL_TELCMD_OK(i))
             infof(data, "%s ", CURL_TELCMD(i));
           else
-            infof(data, "%d ", i);
+            infof(data, "%u ", i);
           if(CURL_TELOPT_OK(j))
             infof(data, "%s", CURL_TELOPT(j));
           else if(CURL_TELCMD_OK(j))
index dee97c5148c273ece479d5c4348c89143f2ba65a..cbf6dc842acb566022d3b4f3932083c879f0e99c 100644 (file)
@@ -274,7 +274,7 @@ static CURLcode tftp_set_timeouts(tftp_state_data_t *state)
 
   infof(state->conn->data,
         "set timeouts for state %d; Total %ld, retry %d maxtry %d\n",
-        state->state, (long)(state->max_time-state->start_time),
+        (int)state->state, (long)(state->max_time-state->start_time),
         state->retry_time, state->retry_max);
 
   /* init RX time */
index b8bb9d8cfdb154de07a0cfdcd6dafa454386913e..2bfcb17623ad9e30e4ca3c3a8daa21722059297a 100644 (file)
@@ -583,7 +583,7 @@ static CURLcode readwrite_data(struct SessionHandle *data,
             failf(data, "Failed writing data");
             return CURLE_WRITE_ERROR;
           }
-          failf(data, "Received problem %d in the chunky parser", res);
+          failf(data, "Received problem %d in the chunky parser", (int)res);
           return CURLE_RECV_ERROR;
         }
         else if(CHUNKE_STOP == res) {
index 34626e69a4955e5e88b2497d2be201165544ca65..8340e52c0c3cc08aa8b5ef7218456ef2e4ba27a0 100644 (file)
--- a/lib/url.c
+++ b/lib/url.c
@@ -4234,7 +4234,7 @@ static CURLcode parse_remote_port(struct SessionHandle *data,
        * are stripped off. It would be better to work directly from the
        * original URL and simply replace the port part of it.
        */
-      url = aprintf("%s://%s%s%s:%d%s%s", conn->handler->scheme,
+      url = aprintf("%s://%s%s%s:%hu%s%s", conn->handler->scheme,
                     conn->bits.ipv6_ip?"[":"", conn->host.name,
                     conn->bits.ipv6_ip?"]":"", conn->remote_port,
                     isftp?"/":"", data->state.path);