[Midnightbsd-cvs] src [8883] trunk/libexec/tftpd: mark tftp_log as printflike

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Mon Sep 26 18:23:59 EDT 2016


Revision: 8883
          http://svnweb.midnightbsd.org/src/?rev=8883
Author:   laffer1
Date:     2016-09-26 18:23:59 -0400 (Mon, 26 Sep 2016)
Log Message:
-----------
mark tftp_log as printflike

Modified Paths:
--------------
    trunk/libexec/tftpd/tftp-io.c
    trunk/libexec/tftpd/tftp-options.c
    trunk/libexec/tftpd/tftp-utils.h
    trunk/libexec/tftpd/tftpd.c

Modified: trunk/libexec/tftpd/tftp-io.c
===================================================================
--- trunk/libexec/tftpd/tftp-io.c	2016-09-26 22:23:39 UTC (rev 8882)
+++ trunk/libexec/tftpd/tftp-io.c	2016-09-26 22:23:59 UTC (rev 8883)
@@ -106,13 +106,13 @@
 	for (i = 0; i < 12 ; i++) {
 		DROPPACKETn("send_packet", 0);
 
-		if (sendto(peer, pkt, size, 0,
-			(struct sockaddr *)&peer_sock, peer_sock.ss_len)
-			== size) {
+		if (sendto(peer, pkt, size, 0, (struct sockaddr *)&peer_sock,
+		    peer_sock.ss_len) == size) {
 			if (i)
 				tftp_log(LOG_ERR,
 				    "%s block %d, attempt %d successful",
-				    block, i);
+		    		    packettype(ntohs(((struct tftphdr *)
+				    (pkt))->th_opcode)), block, i);
 			return (0);
 		}
 		tftp_log(LOG_ERR,
@@ -142,7 +142,7 @@
 	char buf[MAXPKTSIZE];
 
 	if (debug&DEBUG_PACKETS)
-		tftp_log(LOG_DEBUG, "Sending ERROR %d: %s", error);
+		tftp_log(LOG_DEBUG, "Sending ERROR %d", error);
 
 	DROPPACKET("send_error");
 

Modified: trunk/libexec/tftpd/tftp-options.c
===================================================================
--- trunk/libexec/tftpd/tftp-options.c	2016-09-26 22:23:39 UTC (rev 8882)
+++ trunk/libexec/tftpd/tftp-options.c	2016-09-26 22:23:59 UTC (rev 8883)
@@ -99,16 +99,17 @@
 int
 option_timeout(int peer)
 {
+	int to;
 
 	if (options[OPT_TIMEOUT].o_request == NULL)
 		return (0);
 
-	int to = atoi(options[OPT_TIMEOUT].o_request);
+	to = atoi(options[OPT_TIMEOUT].o_request);
 	if (to < TIMEOUT_MIN || to > TIMEOUT_MAX) {
 		tftp_log(acting_as_client ? LOG_ERR : LOG_WARNING,
 		    "Received bad value for timeout. "
-		    "Should be between %d and %d, received %s",
-		    TIMEOUT_MIN, TIMEOUT_MAX);
+		    "Should be between %d and %d, received %d",
+		    TIMEOUT_MIN, TIMEOUT_MAX, to);
 		send_error(peer, EBADOP);
 		if (acting_as_client)
 			return (1);
@@ -195,7 +196,7 @@
 			tftp_log(LOG_ERR,
 			    "Invalid blocksize (%d bytes), "
 			    "net.inet.udp.maxdgram sysctl limits it to "
-			    "%d bytes.\n", size, maxdgram);
+			    "%ld bytes.\n", size, maxdgram);
 			send_error(peer, EBADOP);
 			return (1);
 		} else {
@@ -202,7 +203,7 @@
 			tftp_log(LOG_WARNING,
 			    "Invalid blocksize (%d bytes), "
 			    "net.inet.udp.maxdgram sysctl limits it to "
-			    "%d bytes.\n", size, maxdgram);
+			    "%ld bytes.\n", size, maxdgram);
 			size = maxdgram;
 			/* No reason to return */
 		}
@@ -257,7 +258,7 @@
 		}
 		tftp_log(LOG_INFO,
 		    "Invalid blocksize2 (%d bytes), net.inet.udp.maxdgram "
-		    "sysctl limits it to %d bytes.\n", size, maxdgram);
+		    "sysctl limits it to %ld bytes.\n", size, maxdgram);
 		size = sizes[i];
 		/* No need to return */
 	}

Modified: trunk/libexec/tftpd/tftp-utils.h
===================================================================
--- trunk/libexec/tftpd/tftp-utils.h	2016-09-26 22:23:39 UTC (rev 8882)
+++ trunk/libexec/tftpd/tftp-utils.h	2016-09-26 22:23:59 UTC (rev 8883)
@@ -106,7 +106,7 @@
 extern int tftp_logtostdout;
 void	tftp_openlog(const char *ident, int logopt, int facility);
 void	tftp_closelog(void);
-void	tftp_log(int priority, const char *message, ...);
+void	tftp_log(int priority, const char *message, ...) __printflike(2, 3);
 
 /*
  * Performance figures

Modified: trunk/libexec/tftpd/tftpd.c
===================================================================
--- trunk/libexec/tftpd/tftpd.c	2016-09-26 22:23:39 UTC (rev 8882)
+++ trunk/libexec/tftpd/tftpd.c	2016-09-26 22:23:59 UTC (rev 8883)
@@ -65,6 +65,7 @@
 #include <fcntl.h>
 #include <netdb.h>
 #include <pwd.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -799,8 +800,8 @@
 	tftp_send(peer, &block, &ts);
 	read_close();
 	if (debug&DEBUG_SIMPLE)
-		tftp_log(LOG_INFO, "Sent %d bytes in %d seconds",
-		    ts.amount, time(NULL) - now);
+		tftp_log(LOG_INFO, "Sent %jd bytes in %jd seconds",
+		    (intmax_t)ts.amount, (intmax_t)time(NULL) - now);
 }
 
 static void
@@ -832,8 +833,8 @@
 		f = now2.tv_sec - now1.tv_sec +
 		    (now2.tv_usec - now1.tv_usec) / 100000.0;
 		tftp_log(LOG_INFO,
-		    "Download of %d bytes in %d blocks completed after %0.1f seconds\n",
-		    ts.amount, block, f);
+		    "Download of %jd bytes in %d blocks completed after %0.1f seconds\n",
+		    (intmax_t)ts.amount, block, f);
 	}
 
 	return;



More information about the Midnightbsd-cvs mailing list