changeset 80:ea8c5f1f0382 draft

Cast NULL as char * when terminating lists, and use printf like attributes on our logging functions.
author Roy Marples <roy@marples.name>
date Thu, 05 Apr 2007 14:33:39 +0000
parents ee2c527a6b84
children 4016314de606
files client.c configure.c dhcp.c dhcpcd.c interface.c logger.h socket.c
diffstat 7 files changed, 17 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/client.c	Wed Apr 04 14:28:07 2007 +0000
+++ b/client.c	Thu Apr 05 14:33:39 2007 +0000
@@ -217,7 +217,7 @@
 	      if (iface->fd > -1 && uptime () - last_send >= TIMEOUT_MINI)
 		SEND_MESSAGE (last_type);
 
-	      logger (LOG_DEBUG, "waiting on select for %d seconds",
+	      logger (LOG_DEBUG, "waiting on select for %ld seconds",
 		      timeout);
 	      /* If we're waiting for a reply, then we re-send the last
 		 DHCP request periodically in-case of a bad line */
--- a/configure.c	Wed Apr 04 14:28:07 2007 +0000
+++ b/configure.c	Thu Apr 05 14:33:39 2007 +0000
@@ -47,7 +47,6 @@
 #include "logger.h"
 #include "socket.h"
 
-
 /* IMPORTANT: Ensure that the last parameter is NULL when calling */
 static int exec_cmd (const char *cmd, const char *args, ...)
 {
@@ -110,10 +109,10 @@
 
 #ifdef ENABLE_INFO
   logger (LOG_DEBUG, "exec \"%s %s %s\"", script, infofile, arg);
-  exec_cmd (script, infofile, arg, NULL);
+  exec_cmd (script, infofile, arg, (char *) NULL);
 #else
   logger (LOG_DEBUG, "exec \"%s \"\" %s\"", script, infofile, arg);
-  exec_cmd (script, infofile, "", arg, NULL);
+  exec_cmd (script, infofile, "", arg, (char *) NULL);
 #endif
 }
 
@@ -176,7 +175,7 @@
     return;
 
   logger (LOG_DEBUG, "removing information from resolvconf");
-  exec_cmd (RESOLVCONF, "-d", ifname, NULL);
+  exec_cmd (RESOLVCONF, "-d", ifname, (char *) NULL);
 #endif
 }
 
@@ -294,16 +293,16 @@
 
 #ifdef NTPSERVICE
   if (restart_ntp)
-    retval += exec_cmd (NTPSERVICE, NTPRESTARTARGS, NULL);
+    retval += exec_cmd (NTPSERVICE, NTPRESTARTARGS, (char *) NULL);
 #endif
 
 #if defined (NTPSERVICE) && defined (OPENNTPSERVICE)
   if (restart_openntp &&
       (strcmp (NTPSERVICE, OPENNTPSERVICE) != 0 || ! restart_ntp))
-    retval += exec_cmd (OPENNTPSERVICE, OPENNTPRESTARTARGS, NULL);
+    retval += exec_cmd (OPENNTPSERVICE, OPENNTPRESTARTARGS, (char *) NULL);
 #elif defined (OPENNTPSERVICE) && ! defined (NTPSERVICE)
   if (restart_openntp) 
-    retval += exec_cmd (OPENNTPSERVICE, OPENNTPRESTARTARGS, NULL);
+    retval += exec_cmd (OPENNTPSERVICE, OPENNTPRESTARTARGS, (char *) NULL);
 #endif
 
   return retval;
@@ -342,7 +341,7 @@
 
   fclose (f);
 
-  exec_cmd (NISSERVICE, NISRESTARTARGS, NULL);
+  exec_cmd (NISSERVICE, NISRESTARTARGS, (char *) NULL);
   return 0;
 }
 #endif
--- a/dhcp.c	Wed Apr 04 14:28:07 2007 +0000
+++ b/dhcp.c	Thu Apr 05 14:33:39 2007 +0000
@@ -271,7 +271,7 @@
   make_dhcp_packet (&packet, (unsigned char *) &message, message_length,
 		    from, to);
 
-  logger (LOG_DEBUG, "sending %s with xid 0x%x", dhcp_message[(int) type], xid);
+  logger (LOG_DEBUG, "sending %s with xid 0x%lx", dhcp_message[(int) type], xid);
   return send_packet (iface, ETHERTYPE_IP, (unsigned char *) &packet,
 		      message_length + sizeof (struct ip) +
 		      sizeof (struct udphdr));
--- a/dhcpcd.c	Wed Apr 04 14:28:07 2007 +0000
+++ b/dhcpcd.c	Thu Apr 05 14:33:39 2007 +0000
@@ -342,7 +342,7 @@
       if (doversion || dohelp)
 	exit (EXIT_SUCCESS);
 
-      logger (LOG_ERR, "no interface specified", options.interface);
+      logger (LOG_ERR, "no interface specified");
       exit (EXIT_FAILURE);
     }
 
--- a/interface.c	Wed Apr 04 14:28:07 2007 +0000
+++ b/interface.c	Thu Apr 05 14:33:39 2007 +0000
@@ -406,7 +406,6 @@
 {
   int s;
   char *dstd;
-  char *gend;
   struct rtm
     {
       struct rt_msghdr hdr;
@@ -432,7 +431,7 @@
   if (gateway.s_addr == destination.s_addr)
     logger (LOG_INFO, "%s route to %s/%d",
 	    change ? "changing" : del ? "removing" : "adding",
-	    dstd, gend, inet_ntocidr (netmask));
+	    dstd, inet_ntocidr (netmask));
   else if (destination.s_addr == INADDR_ANY && netmask.s_addr == INADDR_ANY)
     logger (LOG_INFO, "%s default route via %s",
 	    change ? "changing" : del ? "removing" : "adding",
--- a/logger.h	Wed Apr 04 14:28:07 2007 +0000
+++ b/logger.h	Thu Apr 05 14:33:39 2007 +0000
@@ -22,11 +22,15 @@
 #ifndef LOGGER_H
 #define LOGGER_H
 
+#ifdef __GNUC__
+#  define _PRINTF_LIKE(_one, _two)  __attribute__ ((__format__ (__printf__, _one, _two)))
+#endif
+
 #include <syslog.h>
 
 int logtolevel (const char *priority);
 void setloglevel (int level);
 void setlogprefix (const char *prefix);
-void logger (int level, const char *fmt, ...);
+void logger (int level, const char *fmt, ...) _PRINTF_LIKE (2, 3);
 
 #endif
--- a/socket.c	Wed Apr 04 14:28:07 2007 +0000
+++ b/socket.c	Thu Apr 05 14:33:39 2007 +0000
@@ -265,7 +265,7 @@
   if (ioctl (fd, BIOCSETIF, &ifr) < 0)
     {
       logger (LOG_ERR, "cannot attach interface `%s' to bpf device `%s': %s",
-	      iface->name, strerror (errno));
+	      iface->name, device, strerror (errno));
       close (fd);
       return -1;
     }