fix print formatting string directives
authorYang Tse <yangsita@gmail.com>
Thu, 4 Sep 2008 05:29:10 +0000 (05:29 +0000)
committerYang Tse <yangsita@gmail.com>
Thu, 4 Sep 2008 05:29:10 +0000 (05:29 +0000)
tests/server/sockfilt.c
tests/server/sws.c
tests/server/tftpd.c

index f390fc6..f78590f 100644 (file)
 #define DEFAULT_LOGFILE "log/sockfilt.log"
 #endif
 
-const char *serverlogfile = (char *)DEFAULT_LOGFILE;
+const char *serverlogfile = DEFAULT_LOGFILE;
 
 bool verbose = FALSE;
 bool use_ipv6 = FALSE;
@@ -178,29 +178,29 @@ static void install_signal_handlers(void)
 #ifdef SIGHUP
   /* ignore SIGHUP signal */
   if((old_sighup_handler = signal(SIGHUP, SIG_IGN)) == SIG_ERR)
-    logmsg("cannot install SIGHUP handler: 5s", strerror(ERRNO));
+    logmsg("cannot install SIGHUP handler: %s", strerror(ERRNO));
 #endif
 #ifdef SIGPIPE
   /* ignore SIGPIPE signal */
   if((old_sigpipe_handler = signal(SIGPIPE, SIG_IGN)) == SIG_ERR)
-    logmsg("cannot install SIGPIPE handler: 5s", strerror(ERRNO));
+    logmsg("cannot install SIGPIPE handler: %s", strerror(ERRNO));
 #endif
 #ifdef SIGALRM
   /* ignore SIGALRM signal */
   if((old_sigalrm_handler = signal(SIGALRM, SIG_IGN)) == SIG_ERR)
-    logmsg("cannot install SIGALRM handler: 5s", strerror(ERRNO));
+    logmsg("cannot install SIGALRM handler: %s", strerror(ERRNO));
 #endif
 #ifdef SIGINT
   /* handle SIGINT signal with our exit_signal_handler */
   if((old_sigint_handler = signal(SIGINT, exit_signal_handler)) == SIG_ERR)
-    logmsg("cannot install SIGINT handler: 5s", strerror(ERRNO));
+    logmsg("cannot install SIGINT handler: %s", strerror(ERRNO));
   else
     siginterrupt(SIGINT, 1);
 #endif
 #ifdef SIGTERM
   /* handle SIGTERM signal with our exit_signal_handler */
   if((old_sigterm_handler = signal(SIGTERM, exit_signal_handler)) == SIG_ERR)
-    logmsg("cannot install SIGTERM handler: 5s", strerror(ERRNO));
+    logmsg("cannot install SIGTERM handler: %s", strerror(ERRNO));
   else
     siginterrupt(SIGTERM, 1);
 #endif
@@ -269,7 +269,7 @@ static ssize_t fullread(int filedes, void *buffer, size_t nbytes)
   } while((size_t)nread < nbytes);
 
   if(verbose)
-    logmsg("read %ld bytes", (long)nread);
+    logmsg("read %zd bytes", nread);
 
   return nread;
 }
@@ -313,7 +313,7 @@ static ssize_t fullwrite(int filedes, const void *buffer, size_t nbytes)
   } while((size_t)nwrite < nbytes);
 
   if(verbose)
-    logmsg("wrote %ld bytes", (long)nwrite);
+    logmsg("wrote %zd bytes", nwrite);
 
   return nwrite;
 }
@@ -565,11 +565,11 @@ static bool juggle(curl_socket_t *sockfdp,
 
       buffer_len = (ssize_t)strtol((char *)buffer, NULL, 16);
       if (buffer_len > (ssize_t)sizeof(buffer)) {
-        logmsg("ERROR: Buffer size (%ld bytes) too small for data size "
-               "(%ld bytes)", (long)sizeof(buffer), (long)buffer_len);
+        logmsg("ERROR: Buffer size (%zu bytes) too small for data size "
+               "(%zd bytes)", sizeof(buffer), buffer_len);
         return FALSE;
       }
-      logmsg("> %d bytes data, server => client", buffer_len);
+      logmsg("> %zd bytes data, server => client", buffer_len);
 
       if(!read_stdin(buffer, buffer_len))
         return FALSE;
@@ -585,7 +585,7 @@ static bool juggle(curl_socket_t *sockfdp,
         /* send away on the socket */
         bytes_written = swrite(sockfd, buffer, buffer_len);
         if(bytes_written != buffer_len) {
-          logmsg("Not all data was sent. Bytes to send: %d sent: %d", 
+          logmsg("Not all data was sent. Bytes to send: %zd sent: %zd",
                  buffer_len, bytes_written);
         }
       }
@@ -650,7 +650,7 @@ static bool juggle(curl_socket_t *sockfdp,
     if(!write_stdout(buffer, nread_socket))
       return FALSE;
 
-    logmsg("< %d bytes data, client => server", nread_socket);
+    logmsg("< %zd bytes data, client => server", nread_socket);
     lograw(buffer, nread_socket);
   }
 
@@ -906,7 +906,7 @@ int main(int argc, char *argv[])
 #endif /* ENABLE_IPV6 */
     if(rc) {
       error = SOCKERRNO;
-      logmsg("Error connecting to port %d: (%d) %s",
+      logmsg("Error connecting to port %hu: (%d) %s",
              connectport, error, strerror(error));
       goto sockfilt_cleanup;
     }
@@ -925,9 +925,9 @@ int main(int argc, char *argv[])
          (use_ipv6?6:4));
 
   if(connectport)
-    logmsg("Connected to port %d", connectport);
+    logmsg("Connected to port %hu", connectport);
   else
-    logmsg("Listening on port %d", port);
+    logmsg("Listening on port %hu", port);
 
   wrotepidfile = write_pidfile(pidname);
   if(!wrotepidfile)
index f658d18..a4d7e89 100644 (file)
@@ -273,7 +273,7 @@ int ProcessRequest(struct httprequest *req)
         error = ERRNO;
         logmsg("fopen() failed with error: %d %s", error, strerror(error));
         logmsg("Error opening file: %s", filename);
-        logmsg("Couldn't open test file %d", req->testno);
+        logmsg("Couldn't open test file %ld", req->testno);
         req->open = FALSE; /* closes connection */
         return 1; /* done */
       }
@@ -374,7 +374,7 @@ int ProcessRequest(struct httprequest *req)
    */
 
   do {
-    if((req->cl<=0) && curlx_strnequal("Content-Length:", line, 15)) {
+    if((req->cl==0) && curlx_strnequal("Content-Length:", line, 15)) {
       /* If we don't ignore content-length, we read it and we read the whole
          request including the body before we return. If we've been told to
          ignore the content-length, we will return as soon as all headers
@@ -382,9 +382,9 @@ int ProcessRequest(struct httprequest *req)
       size_t cl = strtol(line+15, &line, 10);
       req->cl = cl - req->skip;
 
-      logmsg("Found Content-Length: %d in the request", cl);
+      logmsg("Found Content-Length: %zu in the request", cl);
       if(req->skip)
-        logmsg("... but will abort after %d bytes", req->cl);
+        logmsg("... but will abort after %zu bytes", req->cl);
       break;
     }
     else if(curlx_strnequal("Transfer-Encoding: chunked", line,
@@ -418,16 +418,16 @@ int ProcessRequest(struct httprequest *req)
        Digest stuff to work in the test suite. */
     req->partno += 1000;
     req->digest = TRUE; /* header found */
-    logmsg("Received Digest request, sending back data %d", req->partno);
+    logmsg("Received Digest request, sending back data %ld", req->partno);
   }
   else if(!req->ntlm &&
           strstr(req->reqbuf, "Authorization: NTLM TlRMTVNTUAAD")) {
     /* If the client is passing this type-3 NTLM header */
     req->partno += 1002;
     req->ntlm = TRUE; /* NTLM found */
-    logmsg("Received NTLM type-3, sending back data %d", req->partno);
+    logmsg("Received NTLM type-3, sending back data %ld", req->partno);
     if(req->cl) {
-      logmsg("  Expecting %d POSTed bytes", req->cl);
+      logmsg("  Expecting %zu POSTed bytes", req->cl);
     }
   }
   else if(!req->ntlm &&
@@ -435,7 +435,7 @@ int ProcessRequest(struct httprequest *req)
     /* If the client is passing this type-1 NTLM header */
     req->partno += 1001;
     req->ntlm = TRUE; /* NTLM found */
-    logmsg("Received NTLM type-1, sending back data %d", req->partno);
+    logmsg("Received NTLM type-1, sending back data %ld", req->partno);
   }
   if(strstr(req->reqbuf, "Connection: close"))
     req->open = FALSE; /* close connection after this request */
@@ -496,7 +496,7 @@ void storerequest(char *reqbuf, ssize_t totalsize)
   if (totalsize == 0)
     return;
   else if (totalsize < 0) {
-    logmsg("Invalid size (%d bytes) for request input. Not written to %s",
+    logmsg("Invalid size (%zd bytes) for request input. Not written to %s",
            totalsize, REQUEST_DUMP);
     return;
   }
@@ -522,7 +522,7 @@ void storerequest(char *reqbuf, ssize_t totalsize)
   if (writeleft > 0) {
     logmsg("Error writing file %s error: %d %s",
            REQUEST_DUMP, error, strerror(error));
-    logmsg("Wrote only (%d bytes) of (%d bytes) request input to %s",
+    logmsg("Wrote only (%zd bytes) of (%zd bytes) request input to %s",
            totalsize-writeleft, totalsize, REQUEST_DUMP);
   }
 
@@ -534,7 +534,7 @@ void storerequest(char *reqbuf, ssize_t totalsize)
            REQUEST_DUMP, error, strerror(error));
 
   if(!writeleft)
-    logmsg("Wrote request (%d bytes) input to " REQUEST_DUMP,
+    logmsg("Wrote request (%zd bytes) input to " REQUEST_DUMP,
            totalsize);
 }
 
@@ -575,7 +575,7 @@ static int get_request(curl_socket_t sock, struct httprequest *req)
 
   while (req->offset < REQBUFSIZ-1) {
     if(pipereq_length) {
-      memmove(reqbuf, pipereq, pipereq_length); 
+      memmove(reqbuf, pipereq, pipereq_length);
       got = pipereq_length;
       pipereq_length = 0;
     }
@@ -601,7 +601,7 @@ static int get_request(curl_socket_t sock, struct httprequest *req)
       return DOCNUMBER_INTERNAL;
     }
 
-    logmsg("Read %d bytes", got);
+    logmsg("Read %zd bytes", got);
 
     req->offset += got;
     reqbuf[req->offset] = '\0';
@@ -657,7 +657,7 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
 
   char partbuf[80]="data";
 
-  logmsg("Send response number %d part %d", req->testno, req->partno);
+  logmsg("Send response number %ld part %ld", req->testno, req->partno);
 
   switch(req->rcmd) {
   default:
@@ -695,7 +695,7 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
       logmsg("Identifying ourselves as friends");
       sprintf(msgbuf, "WE ROOLZ: %ld\r\n", (long)getpid());
       msglen = strlen(msgbuf);
-      sprintf(weare, "HTTP/1.1 200 OK\r\nContent-Length: %d\r\n\r\n%s",
+      sprintf(weare, "HTTP/1.1 200 OK\r\nContent-Length: %zu\r\n\r\n%s",
               msglen, msgbuf);
       buffer = weare;
       break;
@@ -795,7 +795,7 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
       break;
     }
     else {
-      logmsg("Sent off %d bytes", written);
+      logmsg("Sent off %zd bytes", written);
     }
     /* write to file as well */
     fwrite(buffer, 1, written, dump);
@@ -812,7 +812,7 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
            RESPONSE_DUMP, error, strerror(error));
 
   if(sendfailure) {
-    logmsg("Sending response failed. Only (%d bytes) of (%d bytes) were sent",
+    logmsg("Sending response failed. Only (%zu bytes) of (%zu bytes) were sent",
            responsesize-count, responsesize);
     if(ptr)
       free(ptr);
@@ -821,7 +821,7 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
     return -1;
   }
 
-  logmsg("Response sent (%d bytes) and written to " RESPONSE_DUMP,
+  logmsg("Response sent (%zu bytes) and written to " RESPONSE_DUMP,
          responsesize);
 
   if(ptr)
@@ -986,7 +986,7 @@ int main(int argc, char *argv[])
     return 1;
   }
 
-  logmsg("Running IPv%d version on port %d",
+  logmsg("Running IPv%d version on port %hu",
 #ifdef ENABLE_IPV6
          (use_ipv6?6:4)
 #else
index 7737519..4cf27ed 100644 (file)
@@ -505,7 +505,7 @@ int main(int argc, char **argv)
     return 1;
   }
 
-  logmsg("Running IPv%d version on port UDP/%d",
+  logmsg("Running IPv%d version on port UDP/%hu",
 #ifdef ENABLE_IPV6
          (use_ipv6?6:4)
 #else