]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Cast NULL as char * when terminating lists, and use printf like attributes on our...
authorRoy Marples <roy@marples.name>
Thu, 5 Apr 2007 14:33:39 +0000 (14:33 +0000)
committerRoy Marples <roy@marples.name>
Thu, 5 Apr 2007 14:33:39 +0000 (14:33 +0000)
client.c
configure.c
dhcp.c
dhcpcd.c
interface.c
logger.h
socket.c

index afdc4f56a1b6781e88b8aaac32dd90b20f8ed941..4455f2682bd3042cdddfad46ed1a4731b761bf19 100644 (file)
--- a/client.c
+++ b/client.c
@@ -217,7 +217,7 @@ int dhcp_run (const options_t *options)
              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 */
index fe36737ead669d5dd554969f574781ae54625629..3ea93db798f0dd0bd18c634fc9382dbac3600065 100644 (file)
@@ -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 @@ static void exec_script (const char *script, const char *infofile,
 
 #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 @@ static void restore_resolv(const char *ifname)
     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 @@ static int make_ntp (const char *ifname, const dhcp_t *dhcp)
 
 #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 @@ static int make_nis (const char *ifname, const dhcp_t *dhcp)
 
   fclose (f);
 
-  exec_cmd (NISSERVICE, NISRESTARTARGS, NULL);
+  exec_cmd (NISSERVICE, NISRESTARTARGS, (char *) NULL);
   return 0;
 }
 #endif
diff --git a/dhcp.c b/dhcp.c
index efe016a7abb4a75b45d7315244e56e2b8eaf2adc..bd7289a169758a81ad17dee419c4145994723065 100644 (file)
--- a/dhcp.c
+++ b/dhcp.c
@@ -271,7 +271,7 @@ size_t send_message (const interface_t *iface, const dhcp_t *dhcp,
   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));
index 4e0ad2efeb6c88a9e5ac83db7778b79f0fd3a395..1d8fed250741363219a1f060bfdced6c8f214298 100644 (file)
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -342,7 +342,7 @@ int main(int argc, char **argv)
       if (doversion || dohelp)
        exit (EXIT_SUCCESS);
 
-      logger (LOG_ERR, "no interface specified", options.interface);
+      logger (LOG_ERR, "no interface specified");
       exit (EXIT_FAILURE);
     }
 
index 0bf8da4a46f41d9484c9b475095b7a5e42388c64..758336652abd0afbb33531de57e014bcfe13c639 100644 (file)
@@ -406,7 +406,6 @@ static int do_route (const char *ifname,
 {
   int s;
   char *dstd;
-  char *gend;
   struct rtm
     {
       struct rt_msghdr hdr;
@@ -432,7 +431,7 @@ static int do_route (const char *ifname,
   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",
index e37c820131c214c36705a39057fc51f9ac5a4e39..740056f3d6c9ebe4e0026ed683f32c8508388bce 100644 (file)
--- a/logger.h
+++ b/logger.h
 #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
index a00fda999daa2465d836f0218d359fb5c439f0c1..ba94215e8228397b7058e6cd9a43ee216eeef10c 100644 (file)
--- a/socket.c
+++ b/socket.c
@@ -265,7 +265,7 @@ int open_socket (interface_t *iface, bool arp)
   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;
     }