changeset 300:bd43831eb570 draft

Quiet some lint warnings.
author Roy Marples <roy@marples.name>
date Mon, 21 Jan 2008 21:19:53 +0000
parents 3861aae6c690
children 1f3aecf365e0
files arp.c client.c common.c config.h configure.c dhcp.c dhcp.h dhcpcd.c dhcpcd.h duid.c info.c interface.c interface.h ipv4ll.c logger.c logger.h mk/prog.mk socket.c socket.h
diffstat 19 files changed, 148 insertions(+), 113 deletions(-) [+]
line wrap: on
line diff
--- a/arp.c	Mon Jan 21 16:08:42 2008 +0000
+++ b/arp.c	Mon Jan 21 21:19:53 2008 +0000
@@ -77,7 +77,7 @@
 		     const unsigned char *taddr, struct in_addr tip)
 {
 	struct arphdr *arp;
-	int arpsize = arphdr_len2 (iface->hwlen, sizeof (struct in_addr));
+	size_t arpsize = arphdr_len2 (iface->hwlen, sizeof (struct in_addr));
 	caddr_t tha;
 	int retval;
 
@@ -89,8 +89,8 @@
 	arp->ar_hln = iface->hwlen;
 	arp->ar_pln = sizeof (struct in_addr);
 	arp->ar_op = htons (op);
-	memcpy (ar_sha (arp), iface->hwaddr, arp->ar_hln);
-	memcpy (ar_spa (arp), &sip, arp->ar_pln);
+	memcpy (ar_sha (arp), iface->hwaddr, (size_t) arp->ar_hln);
+	memcpy (ar_spa (arp), &sip, (size_t) arp->ar_pln);
 	if (taddr) {
 		/* NetBSD can return NULL from ar_tha, which is probably wrong
 		 * but we still need to deal with it */
@@ -99,9 +99,9 @@
 			errno = EINVAL;
 			return (-1);
 		}
-		memcpy (tha, taddr, arp->ar_hln);
+		memcpy (tha, taddr, (size_t) arp->ar_hln);
 	}
-	memcpy (ar_tpa (arp), &tip, arp->ar_pln);
+	memcpy (ar_tpa (arp), &tip, (size_t) arp->ar_pln);
 
 	retval = send_packet (iface, ETHERTYPE_ARP,
 			      (unsigned char *) arp, arphdr_len (arp));
@@ -143,8 +143,8 @@
 
 	for (;;) {
 		struct timeval tv;
-		int bufpos = -1;
-		int buflen = iface->buffer_length;
+		size_t bufpos = 0;
+		size_t buflen = iface->buffer_length;
 		fd_set rset;
 		int bytes;
 		int s = 0;
@@ -226,7 +226,7 @@
 			continue;
 
 		memset (buffer, 0, buflen);
-		while (bufpos != 0)	{
+		do {
 			union {
 				unsigned char *c;
 				struct in_addr *a;
@@ -270,10 +270,10 @@
 
 			logger (LOG_ERR, "ARPOP_REPLY received from %s (%s)",
 				inet_ntoa (*rp.a),
-				hwaddr_ntoa (rh.c, reply->ar_hln));
+				hwaddr_ntoa (rh.c, (size_t) reply->ar_hln));
 			retval = -1;
 			goto eexit;
-		}
+		} while (bufpos != 0);
 	}
 
 eexit:
--- a/client.c	Mon Jan 21 16:08:42 2008 +0000
+++ b/client.c	Mon Jan 21 21:19:53 2008 +0000
@@ -75,7 +75,7 @@
 
 #ifdef THERE_IS_NO_FORK
 # ifndef ENABLE_INFO
-#  error "Non MMU requires ENABLE_INFO to work"
+ #  error "Non MMU requires ENABLE_INFO to work"
 # endif
 #endif
 
@@ -117,12 +117,12 @@
 	time_t last_sent;
 	time_t last_type;
 	long timeout;
-	long nakoff;
+	time_t nakoff;
 	bool daemonised;
 	bool persistent;
 	unsigned char *buffer;
-	ssize_t buffer_len;
-	ssize_t buffer_pos;
+	size_t buffer_len;
+	size_t buffer_pos;
 } state_t;
 
 static pid_t daemonise (int *pidfd)
@@ -462,7 +462,7 @@
 		else
 			tv.tv_sec = TIMEOUT_MINI;
 		if (state->timeout < tv.tv_sec)
-			tv.tv_sec = state->timeout;
+			tv.tv_sec = (time_t) state->timeout;
 		tv.tv_usec = 0;
 		state->start = uptime ();
 		maxfd = signal_fd_set (rset, iface->fd);
@@ -516,7 +516,7 @@
 			logger (LOG_INFO, "received SIGHUP, releasing lease");
 			if (! IN_LINKLOCAL (ntohl (state->dhcp->address.s_addr))) {
 				do_socket (state, SOCKET_OPEN);
-				state->xid = random ();
+				state->xid = (uint32_t) random ();
 				if ((open_socket (state->interface, false)) >= 0)
 					_send_message (state, DHCP_RELEASE, options);
 				do_socket (state, SOCKET_CLOSED);
@@ -632,7 +632,7 @@
 
 	switch (state->state) {
 		case STATE_INIT:
-			state->xid = random ();
+			state->xid = (uint32_t) random ();
 			do_socket (state, SOCKET_OPEN);
 			state->timeout = options->timeout;
 			iface->start_uptime = uptime ();
@@ -662,7 +662,8 @@
 				break;
 			}
 			state->state = STATE_RENEWING;
-			state->xid = random ();
+			state->xid = (uint32_t) random ();
+			/* FALLTHROUGH */
 		case STATE_RENEWING:
 			iface->start_uptime = uptime ();
 			logger (LOG_INFO, "renewing lease of %s", inet_ntoa
@@ -677,7 +678,7 @@
 			memset (&dhcp->address, 0, sizeof (struct in_addr));
 			do_socket (state, SOCKET_OPEN);
 			if (state->xid == 0)
-				state->xid = random ();
+				state->xid = (uint32_t) random ();
 			_send_message (state, DHCP_REQUEST, options);
 			state->timeout = dhcp->leasetime - dhcp->rebindtime;
 			state->state = STATE_REQUESTING;
@@ -689,7 +690,7 @@
 			break;
 
 		case STATE_RELEASED:
-			dhcp->leasetime = -1;
+			dhcp->leasetime = 0;
 			break;
 	}
 
@@ -715,7 +716,7 @@
 		/* If we constantly get NAKS then we should slowly back off */
 		if (state->nakoff > 0) {
 			logger (LOG_DEBUG, "sleeping for %ld seconds",
-				state->nakoff);
+				(long) state->nakoff);
 			tv.tv_sec = state->nakoff;
 			tv.tv_usec = 0;
 			state->nakoff *= 2;
@@ -915,7 +916,7 @@
 	if (! state->buffer)
 		state->buffer = xmalloc (iface->buffer_length);
 	state->buffer_len = iface->buffer_length;
-	state->buffer_pos = -1;
+	state->buffer_pos = 0;
 
 	/* We loop through until our buffer is empty.
 	   The benefit is that if we get >1 DHCP packet in our buffer and
@@ -924,7 +925,7 @@
 	memset (&message, 0, sizeof (struct dhcpmessage_t));
 	new_dhcp = xmalloc (sizeof (dhcp_t));
 
-	while (state->buffer_pos != 0) {
+	do {
 		if (get_packet (iface, (unsigned char *) &message,
 				state->buffer,
 				&state->buffer_len, &state->buffer_pos) == -1)
@@ -952,7 +953,7 @@
 		   any more DHCP packets at this point. */
 		valid = true;
 		break;
-	}
+	} while (state->buffer_pos != 0);
 
 	/* No packets for us, so wait until we get one */
 	if (! valid) {
--- a/common.c	Mon Jan 21 16:08:42 2008 +0000
+++ b/common.c	Mon Jan 21 21:19:53 2008 +0000
@@ -180,12 +180,12 @@
 void writepid (int fd, pid_t pid)
 {
 	char spid[16];
-	if (ftruncate (fd, 0) == -1) {
+	if (ftruncate (fd, (off_t) 0) == -1) {
 		logger (LOG_ERR, "ftruncate: %s", strerror (errno));
 	} else {
 		ssize_t len;
 		snprintf (spid, sizeof (spid), "%u", pid);
-		len = pwrite (fd, spid, strlen (spid), 0);
+		len = pwrite (fd, spid, strlen (spid), (off_t) 0);
 		if (len != (ssize_t) strlen (spid))
 			logger (LOG_ERR, "pwrite: %s", strerror (errno));
 	}
@@ -199,7 +199,9 @@
 		return (value);
 
 	logger (LOG_ERR, "memory exhausted");
+
 	exit (EXIT_FAILURE);
+	/* NOTREACHED */
 }
 
 void *xrealloc (void *ptr, size_t s)
@@ -211,6 +213,7 @@
 
 	logger (LOG_ERR, "memory exhausted");
 	exit (EXIT_FAILURE);
+	/* NOTREACHED */
 }
 
 char *xstrdup (const char *str)
@@ -225,5 +228,5 @@
 
 	logger (LOG_ERR, "memory exhausted");
 	exit (EXIT_FAILURE);
+	/* NOTREACHED */
 }
-
--- a/config.h	Mon Jan 21 16:08:42 2008 +0000
+++ b/config.h	Mon Jan 21 21:19:53 2008 +0000
@@ -93,32 +93,40 @@
 # define NISRESTARTARGS      "--nodeps", "--quiet", "conditionalrestart"
 # define NTPSERVICE          ETCDIR "/init.d/ntpd"
 # define NTPRESTARTARGS      "--nodeps", "--quiet", "conditionalrestart"
-#elif ENABLE_BSDRC
+#endif
+#if ENABLE_BSDRC
 # define SERVICE             "BSDRC"
 # define NISSERVICE          ETCDIR "/rc.d/ypbind"
 # define NISRESTARTARGS      "restart"
 # define NTPSERVICE          ETCDIR "/rc.d/ntpd"
 # define NTPRESTARTARGS      "restart"
-#elif ENABLE_SLACKRC
+#endif
+#if ENABLE_SLACKRC
 # define SERVICE             "SLACKRC"
 # define NISSERVICE          ETCDIR "/rc.d/rc.ypbind"
 # define NISRESTARTARGS      "restart"
 # define NTPSERVICE          ETCDIR "/rc.d/rc.ntpd"
 # define NTPRESTARTARGS      "restart"
-#elif ENABLE_SERVICE
+#endif
+#if ENABLE_SERVICE
 # define SERVICE             "SERVICE"
 # define NISSERVICE          "service"
 # define NISRESTARTARGS      "ypbind", "restart"
 # define NTPSERVICE          "service"
 # define NTPRESTARTARGS      "ntpd", "restart"
-#elif ENABLE_SYSV
+#endif
+#if ENABLE_SYSV
 # define SERVICE             "SYSV"
 # define NISSERVICE          ETCDIR "/init.d/ypbind"
 # define NISRESTARTARGS      "restart"
 # define NTPSERVICE          ETCDIR "/init.d/ntpd"
 # define NTPRESTARTARGS      "restart"
-#else
+#endif
+
+#ifndef NISSERVICE
 # undef ENABLE_NIS
+#endif
+#ifndef NTPSERVICE
 # undef ENABLE_NTP
 #endif
 
--- a/configure.c	Mon Jan 21 16:08:42 2008 +0000
+++ b/configure.c	Mon Jan 21 21:19:53 2008 +0000
@@ -382,7 +382,7 @@
 	fprintf (f, "# Generated by dhcpcd for interface %s\n", ifname);
 
 	if (dhcp->nisdomain) {
-		setdomainname (dhcp->nisdomain, strlen (dhcp->nisdomain));
+		setdomainname (dhcp->nisdomain, (int) strlen (dhcp->nisdomain));
 
 		if (dhcp->nisservers)
 			snprintf (prefix, PREFIXSIZE, "domain %s server",
@@ -752,7 +752,7 @@
 		if (*newhostname) {
 			logger (LOG_INFO, "setting hostname to `%s'",
 				newhostname);
-			sethostname (newhostname, strlen (newhostname));
+			sethostname (newhostname, (int) strlen (newhostname));
 		}
 
 		free (newhostname);
--- a/dhcp.c	Mon Jan 21 16:08:42 2008 +0000
+++ b/dhcp.c	Mon Jan 21 21:19:53 2008 +0000
@@ -79,7 +79,7 @@
 }
 
 ssize_t send_message (const interface_t *iface, const dhcp_t *dhcp,
-		      unsigned long xid, char type,
+		      uint32_t xid, char type,
 		      const options_t *options)
 {
 	struct udp_dhcp_packet *packet;
@@ -87,13 +87,13 @@
 	unsigned char *m;
 	unsigned char *p;
 	unsigned char *n_params = NULL;
-	unsigned long l;
+	size_t l;
 	struct in_addr from;
 	struct in_addr to;
 	time_t up = uptime() - iface->start_uptime;
 	uint32_t ul;
 	uint16_t sz;
-	unsigned int message_length;
+	size_t message_length;
 	ssize_t retval;
 
 	if (!iface || !options || !dhcp)
@@ -313,7 +313,7 @@
 		memcpy (p, options->clientid, options->clientid_len);
 		p += options->clientid_len;
 #ifdef ENABLE_DUID
-	} else if (iface->duid && options->clientid_len != -1) {
+	} else if (iface->duid && options->doduid) {
 		*p++ = iface->duid_length + 5;
 		*p++ = 255; /* RFC 4361 */
 
@@ -354,7 +354,7 @@
 			  from, to);
 	free (message);
 
-	logger (LOG_DEBUG, "sending %s with xid 0x%lx",
+	logger (LOG_DEBUG, "sending %s with xid 0x%x",
 		dhcp_message (type), xid);
 	retval = send_packet (iface, ETHERTYPE_IP, (unsigned char *) packet,
 			      message_length + sizeof (struct ip) +
@@ -452,13 +452,13 @@
 		ocets = (cidr + 7) / 8;
 
 		if (ocets > 0) {
-			memcpy (&route->destination.s_addr, q, ocets);
+			memcpy (&route->destination.s_addr, q, (size_t) ocets);
 			q += ocets;
 		}
 
 		/* Now enter the netmask */
 		if (ocets > 0) {
-			memset (&route->netmask.s_addr, 255, ocets - 1);
+			memset (&route->netmask.s_addr, 255, (size_t) ocets - 1);
 			memset ((unsigned char *) &route->netmask.s_addr +
 				(ocets - 1),
 				(256 - (1 << (32 - cidr) % 8)), 1);
@@ -534,7 +534,7 @@
 	char *p;
 	const char encoding = *data++;
 	struct in_addr addr;
-	int len;
+	size_t len;
 
 	length--;
 
@@ -577,10 +577,11 @@
 /* This calculates the netmask that we should use for static routes.
  * This IS different from the calculation used to calculate the netmask
  * for an interface address. */
-static unsigned long route_netmask (unsigned long ip_in)
+static uint32_t route_netmask (uint32_t ip_in)
 {
-	unsigned long p = ntohl (ip_in);
-	unsigned long t;
+	/* used to be unsigned long - check if error */
+	uint32_t p = ntohl (ip_in);
+	uint32_t t;
 
 	if (IN_CLASSA (p))
 		t = ~IN_CLASSA_NET;
@@ -788,8 +789,8 @@
 #define GETSTR(_var) { \
 	MIN_LENGTH (sizeof (char)); \
 	if (_var) free (_var); \
-	_var = xmalloc (length + 1); \
-	memcpy (_var, p, length); \
+	_var = xmalloc ((size_t) length + 1); \
+	memcpy (_var, p, (size_t) length); \
 	memset (_var + length, 0, 1); \
 }
 			case DHCP_HOSTNAME:
--- a/dhcp.h	Mon Jan 21 16:08:42 2008 +0000
+++ b/dhcp.h	Mon Jan 21 21:19:53 2008 +0000
@@ -139,10 +139,10 @@
 	struct in_addr broadcast;
 	unsigned short mtu;
 
-	unsigned int leasedfrom;
-	unsigned int leasetime;
-	unsigned int renewaltime;
-	unsigned int rebindtime;
+	uint32_t leasedfrom;
+	uint32_t leasetime;
+	uint32_t renewaltime;
+	uint32_t rebindtime;
 
 	route_t *routes;
 
@@ -209,7 +209,7 @@
 };
 
 ssize_t send_message (const interface_t *iface, const dhcp_t *dhcp,
-		      unsigned long xid, char type,
+		      uint32_t xid, char type,
 		      const options_t *options);
 void free_dhcp (dhcp_t *dhcp);
 int parse_dhcpmessage (dhcp_t *dhcp, const dhcpmessage_t *message);
--- a/dhcpcd.c	Mon Jan 21 16:08:42 2008 +0000
+++ b/dhcpcd.c	Mon Jan 21 21:19:53 2008 +0000
@@ -119,7 +119,7 @@
 		return (-1);	
 	}
 
-	return (n);
+	return ((int) n);
 }
 
 static pid_t read_pid (const char *pidfile)
@@ -182,6 +182,7 @@
 	options->daemonise = true;
 	options->doinform = false;
 	options->doipv4ll = true;
+	options->doduid = true;
 	options->timeout = DEFAULT_TIMEOUT;
 
 	gethostname (options->hostname, sizeof (options->hostname));
@@ -203,7 +204,6 @@
 					"option `%s' should set a flag",
 					longopts[option_index].name);
 				goto abort;
-				break;
 			case 'c':
 				options->script = optarg;
 				break;
@@ -258,12 +258,17 @@
 				sig = SIGHUP;
 				break;
 			case 'l':
-				options->leasetime = atoint (optarg);
-				if (options->leasetime <= 0) {
+				if (*optarg == '-') {
 					logger (LOG_ERR,
 						"leasetime must be a positive value");
 					goto abort;
 				}
+				errno = 0;
+				options->leasetime = (uint32_t) strtol (optarg, NULL, 0);
+				if (errno == EINVAL || errno == ERANGE) {
+					logger (LOG_ERR, "`%s' out of range", optarg);
+					goto abort;
+				}
 				break;
 			case 'm':
 				options->metric = atoint (optarg);
@@ -298,8 +303,8 @@
 							goto abort;
 						}
 					}
-					/* fall through */
 				}
+				/* FALLTHROUGH */
 			case 'r':
 				if (! options->doinform)
 					options->dorequest = true;
@@ -381,10 +386,11 @@
 									 sizeof (options->clientid));
 					/* empty string disabled duid */
 					if (options->clientid_len == 0)
-						options->clientid_len = -1;
+						options->doduid = false;
+
 				} else {
 					memset (options->clientid, 0, sizeof (options->clientid));
-					options->clientid_len = -1;
+					options->doduid = false;
 				}
 				break;
 			case 'L':
@@ -640,4 +646,5 @@
 	logger (LOG_INFO, "exiting");
 
 	exit (retval);
+	/* NOTREACHED */
 }
--- a/dhcpcd.h	Mon Jan 21 16:08:42 2008 +0000
+++ b/dhcpcd.h	Mon Jan 21 21:19:53 2008 +0000
@@ -56,12 +56,12 @@
 	char hostname[MAXHOSTNAMELEN];
 	int fqdn;
 	char classid[CLASS_ID_MAX_LEN];
-	int classid_len;
+	size_t classid_len;
 	char clientid[CLIENT_ID_MAX_LEN];
-	int clientid_len;
+	size_t clientid_len;
 	char userclass[USERCLASS_MAX_LEN];
-	int userclass_len;
-	unsigned leasetime;
+	size_t userclass_len;
+	uint32_t leasetime;
 	time_t timeout;
 	int metric;
 
@@ -77,6 +77,7 @@
 	bool doinform;
 	bool dorequest;
 	bool doipv4ll;
+	bool doduid;
 	int domscsr;
 
 	struct in_addr request_address;
--- a/duid.c	Mon Jan 21 16:08:42 2008 +0000
+++ b/duid.c	Mon Jan 21 21:19:53 2008 +0000
@@ -111,7 +111,7 @@
 	if (! (fp = fopen (DUIDFILE, "w")))
 		logger (LOG_ERR, "fopen `%s': %s", DUIDFILE, strerror (errno));
 	else {
-		int i;
+		size_t i;
 		for (i = 0; i < iface->duid_length; i++)
 			x += fprintf (fp, "%.2X", iface->duid[i]);
 		fprintf (fp, "\n");
--- a/info.c	Mon Jan 21 16:08:42 2008 +0000
+++ b/info.c	Mon Jan 21 21:19:53 2008 +0000
@@ -211,7 +211,7 @@
 		free (clean);
 	}
 #ifdef ENABLE_DUID
-	else if (iface->duid_length > 0 && options->clientid_len != -1) {
+	else if (iface->duid_length > 0 && options->doduid) {
 		unsigned char *duid;
 		unsigned char *p;
 		uint32_t ul;
@@ -233,7 +233,8 @@
 		memcpy (p, iface->duid, iface->duid_length);
 		p += iface->duid_length;
 
-		fprintf (f, "CLIENTID='%s'\n", hwaddr_ntoa (duid, p - duid));
+		fprintf (f, "CLIENTID='%s'\n", hwaddr_ntoa (duid,
+							    (size_t) (p - duid)));
 		free (duid);
 	}
 #endif
--- a/interface.c	Mon Jan 21 16:08:42 2008 +0000
+++ b/interface.c	Mon Jan 21 21:19:53 2008 +0000
@@ -108,7 +108,7 @@
 
 	memset (addr, 0, sizeof (struct in_addr));
 	if (ocets > 0) {
-		memset (&addr->s_addr, 255, ocets - 1);
+		memset (&addr->s_addr, 255, (size_t) ocets - 1);
 		memset ((unsigned char *) &addr->s_addr + (ocets - 1),
 			(256 - (1 << (32 - cidr) % 8)), 1);
 	}
@@ -116,9 +116,9 @@
 	return (0);
 }
 
-unsigned long get_netmask (unsigned long addr)
+uint32_t get_netmask (uint32_t addr)
 {
-	unsigned long dst;
+	uint32_t dst;
 
 	if (addr == 0)
 		return (0);
@@ -134,11 +134,11 @@
 	return (0);
 }
 
-char *hwaddr_ntoa (const unsigned char *hwaddr, int hwlen)
+char *hwaddr_ntoa (const unsigned char *hwaddr, size_t hwlen)
 {
 	static char buffer[(HWADDR_LEN * 3) + 1];
 	char *p = buffer;
-	int i;
+	size_t i;
 
 	for (i = 0; i < hwlen && i < HWADDR_LEN; i++) {
 		if (i > 0)
@@ -152,7 +152,7 @@
 }
 
 static int _do_interface (const char *ifname,
-			  unsigned char *hwaddr, int *hwlen,
+			  unsigned char *hwaddr, size_t *hwlen,
 			  struct in_addr *addr,
 			  bool flush, bool get)
 {
@@ -173,7 +173,7 @@
 	memset (&ifc, 0, sizeof (struct ifconf));
 	for (;;) {
 		ifc.ifc_len = len;
-		ifc.ifc_buf = xmalloc (len);
+		ifc.ifc_buf = xmalloc ((size_t) len);
 		if (ioctl (s, SIOCGIFCONF, &ifc) == -1) {
 			if (errno != EINVAL || lastlen != 0) {
 				logger (LOG_ERR, "ioctl SIOCGIFCONF: %s",
@@ -227,7 +227,7 @@
 				sizeof (struct sockaddr_dl));
 			*hwlen = sdl.sdl_alen;
 			memcpy (hwaddr, sdl.sdl_data + sdl.sdl_nlen,
-				sdl.sdl_alen);
+				(size_t) sdl.sdl_alen);
 			retval = 1;
 			break;
 		}
@@ -275,7 +275,7 @@
 	struct ifreq ifr;
 	interface_t *iface = NULL;
 	unsigned char *hwaddr = NULL;
-	int hwlen = 0;
+	size_t hwlen = 0;
 	sa_family_t family = 0;
 	unsigned short mtu;
 #ifdef __linux__
@@ -454,7 +454,7 @@
 static void log_route (struct in_addr destination,
 		       struct in_addr netmask,
 		       struct in_addr gateway,
-		       int metric,
+		       __unused int metric,
 		       int change, int del)
 {
 	char *dstd = xstrdup (inet_ntoa (destination));
@@ -463,7 +463,6 @@
 #define METRIC " metric %d"
 #else
 #define METRIC ""
-	metric = 0;
 #endif
 
 	if (gateway.s_addr == destination.s_addr ||
@@ -576,7 +575,7 @@
 		struct sockaddr_storage ss;
 	} su;
 
-	int l;
+	size_t l;
 
 	if (! ifname)
 		return -1;
@@ -614,7 +613,7 @@
 	{
 		/* Make us a link layer socket */
 		unsigned char *hwaddr;
-		int hwlen = 0;
+		size_t hwlen = 0;
 
 		if (netmask.s_addr == INADDR_BROADCAST) 
 			rtm.hdr.rtm_flags |= RTF_HOST;
@@ -625,10 +624,10 @@
 		su.sdl.sdl_len = sizeof (struct sockaddr_dl);
 		su.sdl.sdl_family = AF_LINK;
 		su.sdl.sdl_nlen = strlen (ifname);
-		memcpy (&su.sdl.sdl_data, ifname, su.sdl.sdl_nlen);
+		memcpy (&su.sdl.sdl_data, ifname, (size_t) su.sdl.sdl_nlen);
 		su.sdl.sdl_alen = hwlen;
 		memcpy (((unsigned char *) &su.sdl.sdl_data) + su.sdl.sdl_nlen,
-			hwaddr, su.sdl.sdl_alen);
+			hwaddr, (size_t) su.sdl.sdl_alen);
 
 		l = SA_SIZE (&(su.sa));
 		memcpy (bp, &su, l);
@@ -960,10 +959,10 @@
 }
 
 #else
-# error "Platform not supported!"
-# error "We currently support BPF and Linux sockets."
-# error "Other platforms may work using BPF. If yours does, please let me know"
-# error "so I can add it to our list."
+ #error "Platform not supported!"
+ #error "We currently support BPF and Linux sockets."
+ #error "Other platforms may work using BPF. If yours does, please let me know"
+ #error "so I can add it to our list."
 #endif
 
 int add_address (const char *ifname, struct in_addr address,
@@ -1011,7 +1010,7 @@
 	return (_do_interface (ifname, NULL, NULL, NULL, true, false));
 }
 
-unsigned long get_address (const char *ifname)
+in_addr_t get_address (const char *ifname)
 {
 	struct in_addr address;
 	if (_do_interface (ifname, NULL, NULL, &address, false, true) > 0)
--- a/interface.h	Mon Jan 21 16:08:42 2008 +0000
+++ b/interface.h	Mon Jan 21 21:19:53 2008 +0000
@@ -97,12 +97,12 @@
 	char name[IF_NAMESIZE];
 	sa_family_t family;
 	unsigned char hwaddr[HWADDR_LEN];
-	int hwlen;
+	size_t hwlen;
 	bool arpable;
 	unsigned short mtu;
 
 	int fd;
-	int buffer_length;
+	size_t buffer_length;
 
 #ifdef __linux__
 	int socket_protocol;
@@ -119,26 +119,26 @@
 
 #ifdef ENABLE_DUID
 	unsigned char duid[DUID_LEN];
-	int duid_length;
+	size_t duid_length;
 #endif
 } interface_t;
 
 void free_address (address_t *addresses);
 void free_route (route_t *routes);
-unsigned long get_netmask (unsigned long addr);
-char *hwaddr_ntoa (const unsigned char *hwaddr, int hwlen);
+uint32_t get_netmask (uint32_t addr);
+char *hwaddr_ntoa (const unsigned char *hwaddr, size_t hwlen);
 
 interface_t *read_interface (const char *ifname, int metric);
 int get_mtu (const char *ifname);
 int set_mtu (const char *ifname, short int mtu);
 
 int add_address (const char *ifname, struct in_addr address,
-				 struct in_addr netmask, struct in_addr broadcast);
+		 struct in_addr netmask, struct in_addr broadcast);
 int del_address (const char *ifname, struct in_addr address,
 				 struct in_addr netmask);
 
 int flush_addresses (const char *ifname);
-unsigned long get_address (const char *ifname);
+in_addr_t get_address (const char *ifname);
 int has_address (const char *ifname, struct in_addr address);
 
 int add_route (const char *ifname, struct in_addr destination,
--- a/ipv4ll.c	Mon Jan 21 16:08:42 2008 +0000
+++ b/ipv4ll.c	Mon Jan 21 21:19:53 2008 +0000
@@ -35,7 +35,7 @@
 #ifdef ENABLE_IPV4LL
 
 #ifndef ENABLE_ARP
-#error IPV4LL requires ARP
+ # error IPV4LL requires ARP
 #endif
 
 #define IPV4LL_LEASETIME 20 
@@ -45,7 +45,8 @@
 
 	for (;;) {
 		addr.s_addr = htonl (LINKLOCAL_ADDR |
-				     ((abs (random ()) % 0xFD00) + 0x0100));
+				     (((uint32_t) abs ((int) random ())
+				       % 0xFD00) + 0x0100));
 		errno = 0;
 		if (! arp_claim (iface, addr))
 			break;
--- a/logger.c	Mon Jan 21 16:08:42 2008 +0000
+++ b/logger.c	Mon Jan 21 21:19:53 2008 +0000
@@ -96,8 +96,8 @@
 	}
 
 	if (level < LOG_DEBUG || level <= loglevel) {
-		int len = strlen (logprefix);
-		int fmt2len = strlen (fmt) + len + 1;
+		size_t len = strlen (logprefix);
+		size_t fmt2len = strlen (fmt) + len + 1;
 		char *fmt2 = malloc (sizeof (char) * fmt2len);
 		char *pf = fmt2;
 		if (fmt2) {
--- a/logger.h	Mon Jan 21 16:08:42 2008 +0000
+++ b/logger.h	Mon Jan 21 21:19:53 2008 +0000
@@ -30,6 +30,8 @@
 
 #ifdef __GNUC__
 #  define _PRINTF_LIKE(_one, _two)  __attribute__ ((__format__ (__printf__, _one, _two)))
+#else
+#  define _PRINTF_LIKE(_one, _two)
 #endif
 
 #include <syslog.h>
--- a/mk/prog.mk	Mon Jan 21 16:08:42 2008 +0000
+++ b/mk/prog.mk	Mon Jan 21 21:19:53 2008 +0000
@@ -25,3 +25,9 @@
 
 clean:
 	rm -f ${OBJS} ${PROG} ${CLEANFILES}
+
+LINTFLAGS?=	-hx
+LINTFLAGS+=	-X 159,247,352
+
+lint: ${SRCS:.c=.c}
+	${LINT} ${LINTFLAGS} ${CFLAGS:M-[DIU]*} $^ ${.ALLSRC}
--- a/socket.c	Mon Jan 21 16:08:42 2008 +0000
+++ b/socket.c	Mon Jan 21 21:19:53 2008 +0000
@@ -86,7 +86,7 @@
 }
 
 void make_dhcp_packet(struct udp_dhcp_packet *packet,
-		      const unsigned char *data, int length,
+		      const unsigned char *data, size_t length,
 		      struct in_addr source, struct in_addr dest)
 {
 	struct ip *ip = &packet->ip;
@@ -309,7 +309,7 @@
 }
 
 ssize_t send_packet (const interface_t *iface, int type,
-		     const unsigned char *data, int len)
+		     const unsigned char *data, size_t len)
 {
 	ssize_t retval = -1;
 	struct iovec iov[2];
@@ -338,7 +338,8 @@
 /* BPF requires that we read the entire buffer.
    So we pass the buffer in the API so we can loop on >1 dhcp packet. */
 ssize_t get_packet (const interface_t *iface, unsigned char *data,
-		    unsigned char *buffer, int *buffer_len, int *buffer_pos)
+		    unsigned char *buffer,
+		    size_t *buffer_len, size_t *buffer_pos)
 {
 	union
 	{
@@ -364,13 +365,14 @@
 		bpf.buffer += *buffer_pos;
 
 	while (bpf.packet) {
-		ssize_t len = -1;
+		size_t len = 0;
 		union
 		{
 			unsigned char *buffer;
 			struct ether_header *hw;
 		} hdr;
 		unsigned char *payload;
+		bool have_data = false;
 
 		/* Ensure that the entire packet is in our buffer */
 		if (*buffer_pos + bpf.packet->bh_hdrlen + bpf.packet->bh_caplen
@@ -385,6 +387,7 @@
 			len = bpf.packet->bh_caplen - 
 				sizeof (struct ether_header);
 			memcpy (data, payload, len);
+			have_data = true;
 		} else {
 			if (valid_dhcp_packet (payload) >= 0) {
 				union
@@ -397,18 +400,19 @@
 					sizeof (struct ip) -
 					sizeof (struct udphdr);
 				memcpy (data, &pay.packet->dhcp, len);
+				have_data = true;
 			}
 		}
 
 		/* Update the buffer_pos pointer */
 		bpf.buffer += BPF_WORDALIGN (bpf.packet->bh_hdrlen +
 					     bpf.packet->bh_caplen);
-		if (bpf.buffer - buffer <  *buffer_len)
+		if ((unsigned) (bpf.buffer - buffer) < *buffer_len)
 			*buffer_pos = bpf.buffer - buffer;
 		else
 			*buffer_pos = 0;
 
-		if (len != -1)
+		if (have_data)
 			return len;
 
 		if (*buffer_pos == 0)
@@ -478,8 +482,8 @@
 	return fd;
 }
 
-ssize_t send_packet (const interface_t *iface, const int type,
-		     const unsigned char *data, const int len)
+ssize_t send_packet (const interface_t *iface, int type,
+		     const unsigned char *data, size_t len)
 {
 	union sockunion {
 		struct sockaddr sa;
@@ -512,7 +516,8 @@
 /* Linux has no need for the buffer as we can read as much as we want.
    We only have the buffer listed to keep the same API. */
 ssize_t get_packet (const interface_t *iface, unsigned char *data,
-		    unsigned char *buffer, int *buffer_len, int *buffer_pos)
+		    unsigned char *buffer,
+		    size_t *buffer_len, size_t *buffer_pos)
 {
 	ssize_t bytes;
 	union
@@ -578,8 +583,8 @@
 }
 
 #else
-# error "Platform not supported!"
-# error "We currently support BPF and Linux sockets."
-# error "Other platforms may work using BPF. If yours does, please let me know"
-# error "so I can add it to our list."
+ #error "Platform not supported!"
+ #error "We currently support BPF and Linux sockets."
+ #error "Other platforms may work using BPF. If yours does, please let me know"
+ #error "so I can add it to our list."
 #endif
--- a/socket.h	Mon Jan 21 16:08:42 2008 +0000
+++ b/socket.h	Mon Jan 21 21:19:53 2008 +0000
@@ -34,12 +34,12 @@
 #include "interface.h"
 
 void make_dhcp_packet(struct udp_dhcp_packet *packet,
-		      const unsigned char *data, int length,
+		      const unsigned char *data, size_t length,
 		      struct in_addr source, struct in_addr dest);
 
 int open_socket (interface_t *iface, bool arp);
 ssize_t send_packet (const interface_t *iface, int type,
-		     const unsigned char *data, int len);
+		     const unsigned char *data, size_t len);
 ssize_t get_packet (const interface_t *iface, unsigned char *data,
-		    unsigned char *buffer, int *buffer_len, int *buffer_pos);
+		    unsigned char *buffer, size_t *buffer_len, size_t *buffer_pos);
 #endif