From: Roy Marples Date: Thu, 5 Apr 2007 14:33:39 +0000 (+0000) Subject: Cast NULL as char * when terminating lists, and use printf like attributes on our... X-Git-Tag: v3.2.3~294 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bc3f8ad57d8bf6d9e6a56ce47cd68b47bfc94d50;p=thirdparty%2Fdhcpcd.git Cast NULL as char * when terminating lists, and use printf like attributes on our logging functions. --- diff --git a/client.c b/client.c index afdc4f56..4455f268 100644 --- 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 */ diff --git a/configure.c b/configure.c index fe36737e..3ea93db7 100644 --- a/configure.c +++ b/configure.c @@ -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 efe016a7..bd7289a1 100644 --- 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)); diff --git a/dhcpcd.c b/dhcpcd.c index 4e0ad2ef..1d8fed25 100644 --- 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); } diff --git a/interface.c b/interface.c index 0bf8da4a..75833665 100644 --- a/interface.c +++ b/interface.c @@ -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", diff --git a/logger.h b/logger.h index e37c8201..740056f3 100644 --- a/logger.h +++ b/logger.h @@ -22,11 +22,15 @@ #ifndef LOGGER_H #define LOGGER_H +#ifdef __GNUC__ +# define _PRINTF_LIKE(_one, _two) __attribute__ ((__format__ (__printf__, _one, _two))) +#endif + #include 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 diff --git a/socket.c b/socket.c index a00fda99..ba94215e 100644 --- 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; }