Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 10 Jun 2003 20:16:13 +0100
From:      Mark Murray <mark@grondar.org>
To:        audit@freebsd.org
Subject:   libatm cleanup.
Message-ID:  <200306101916.h5AJGDHh072147@grimreaper.grondar.org>

next in thread | raw e-mail | index | archive | help
------- =_aaaaaaaaaa0
Content-Type: text/plain; charset="us-ascii"
Content-ID: <72128.1055272499.1@grondar.org>

Hi all

Any objections to me committing the attached patch? This is a big
linting of the code, which leaves it WARNS=9 clean ;-). ANSIfication
is also done.

This does NOT affect build infrastructure. It just makes the
build cleaner.

(YeahYeahYeah. I know the highest WARNS is less than that).

M
--
Mark Murray
iumop ap!sdn w,I idlaH

------- =_aaaaaaaaaa0
Content-Type: text/plain; charset="us-ascii"
Content-ID: <72128.1055272499.2@grondar.org>
Content-Description: libatm.diff

Index: atm_addr.c
===================================================================
RCS file: /home/ncvs/src/lib/libatm/atm_addr.c,v
retrieving revision 1.10
diff -u -d -r1.10 atm_addr.c
--- atm_addr.c	20 Apr 2003 18:41:16 -0000	1.10
+++ atm_addr.c	10 Jun 2003 18:42:29 -0000
@@ -29,6 +29,7 @@
 static char *RCSid = "@(#) $Id: atm_addr.c,v 1.1 1998/07/09 21:45:18 johnc Exp $";
 #endif
 #endif
+
 #include <sys/cdefs.h>
 __FBSDID("$FreeBSD: src/lib/libatm/atm_addr.c,v 1.10 2003/04/20 18:41:16 obrien Exp $");
 
@@ -45,7 +46,6 @@
 #include <sys/socket.h>
 #include <net/if.h>
 #include <netinet/in.h>
-#include <netatm/port.h>
 #include <netatm/atm.h>
 #include <netatm/atm_if.h>
 #include <netatm/atm_sap.h>
@@ -57,8 +57,6 @@
 
 #include "libatm.h"
 
-extern char	*prog;
-
 /*
  * Get NSAP, NSAP prefix or MAC address
  *
@@ -72,11 +70,9 @@
  *	len	the length of the data in the output buffer
  *
  */
+/* ARGSUSED */
 int
-get_hex_atm_addr(in, out, len)
-	char	*in;
-	u_char	*out;
-	int	len;
+get_hex_atm_addr(char *in, u_char *out, int len __unused)
 {
 	int	c_type, c_value, i, out_len, state, val = 0;
 
@@ -140,7 +136,7 @@
 	/*
 	 * Loop through input until state table says to return
 	 */
-	while (1) {
+	for (;;) {
 		/*
 		 * Get the character type and value
 		 */
@@ -219,8 +215,7 @@
  *
  */
 char *
-format_atm_addr(addr)
-	Atm_addr *addr;
+format_atm_addr(Atm_addr *addr)
 {
 	int		i;
 	char		*nsap_format;
@@ -231,7 +226,7 @@
 	static char	str[256];
 	union {
 		int	w;
-		char	c[4];
+		u_char	c[4];
 	} u1, u2;
 
 	static char	nsap_format_DCC[] = "0x%02x.%02x%02x.%02x.%02x%02x%02x.%02x%02x.%02x%02x.%02x%02x.%02x%02x%02x%02x%02x%02x.%02x";
@@ -310,7 +305,8 @@
 
 		if (!(u1.w == 0 && u2.w == 0))
 			sprintf(str, "0x%08lx.%08lx",
-				(u_long)ntohl(u1.w), (u_long)ntohl(u2.w));
+				(u_long)ntohl((u_int)u1.w),
+				(u_long)ntohl((u_int)u2.w));
 		break;
 
 	case T_ATM_PVC_ADDR:
Index: cache_key.c
===================================================================
RCS file: /home/ncvs/src/lib/libatm/cache_key.c,v
retrieving revision 1.8
diff -u -d -r1.8 cache_key.c
--- cache_key.c	25 Mar 2003 04:29:26 -0000	1.8
+++ cache_key.c	10 Jun 2003 18:43:25 -0000
@@ -40,7 +40,6 @@
 #include <sys/socket.h>
 #include <net/if.h>
 #include <netinet/in.h>
-#include <netatm/port.h>
 #include <netatm/atm.h>
 #include <netatm/atm_if.h>
 #include <netatm/atm_sap.h>
@@ -66,14 +65,11 @@
  *
  */
 void
-scsp_cache_key(ap, ip, ol, op)
-	Atm_addr	*ap;
-	struct in_addr	*ip;
-	int		ol;
-	char 		*op;
+scsp_cache_key(Atm_addr *ap, struct in_addr *ip, int ol, char *op)
 {
-	int	i, len;
-	char	buff[32], digest[16];
+	int	i;
+	size_t	len;
+	u_char	buff[32], digest[16];
 	MD5_CTX	context;
 
 	/*
@@ -101,7 +97,7 @@
 	/*
 	 * Fold the 16-byte digest to the required length
 	 */
-	bzero((caddr_t)op, ol);
+	bzero((caddr_t)op, (size_t)ol);
 	for (i = 0; i < 16; i++) {
 		op[i % ol] = op[i % ol] ^ digest[i];
 	}
Index: ioctl_subr.c
===================================================================
RCS file: /home/ncvs/src/lib/libatm/ioctl_subr.c,v
retrieving revision 1.8
diff -u -d -r1.8 ioctl_subr.c
--- ioctl_subr.c	30 Sep 2002 09:18:54 -0000	1.8
+++ ioctl_subr.c	10 Jun 2003 19:08:14 -0000
@@ -41,7 +41,6 @@
 #include <sys/sockio.h>
 #include <net/if.h>
 #include <netinet/in.h>
-#include <netatm/port.h>
 #include <netatm/atm.h>
 #include <netatm/atm_if.h>
 #include <netatm/atm_sap.h>
@@ -63,9 +62,6 @@
 #define	FALSE	0
 #endif
 
-extern char	*prog;
-
-
 /*
  * Issue an informational IOCTL
  * 
@@ -85,9 +81,7 @@
  *
  */
 int
-do_info_ioctl(req, buf_len)
-	struct atminfreq	*req;
-	int 			buf_len;
+do_info_ioctl(struct atminfreq *req, int buf_len)
 {
 	int	rc, s;
 	caddr_t	buf;
@@ -104,18 +98,18 @@
 	 * Get memory for returned information
 	 */
 mem_retry:
-	buf = malloc(buf_len);
+	buf = malloc((size_t)buf_len);
 	if (buf == NULL) {
 		errno = ENOMEM;
 		return(-1);
 	}
-	bzero(buf, buf_len);
+	bzero(buf, (size_t)buf_len);
 
 	/*
 	 * Set the buffer address and length in the request
 	 */
 	req->air_buf_addr = buf;
-	req->air_buf_len = buf_len;
+	req->air_buf_len = (int)buf_len;
 
 	/*
 	 * Issue the IOCTL
@@ -152,11 +146,9 @@
  *
  */
 int
-get_vcc_info(intf, vccp)
-	char			*intf;
-	struct air_vcc_rsp	**vccp;
+get_vcc_info(const char *intf, struct air_vcc_rsp **vccp)
 {
-	int	buf_len = sizeof(struct air_vcc_rsp) * 100;
+	int	buf_len = (int)sizeof(struct air_vcc_rsp) * 100;
 	struct atminfreq	air;
 
 	/*
@@ -190,9 +182,7 @@
  *
  */
 int
-get_subnet_mask(intf, mask)
-	char			*intf;
-	struct sockaddr_in	*mask;
+get_subnet_mask(const char *intf, struct sockaddr_in *mask)
 {
 	int			rc, s;
 	struct ifreq		req;
@@ -247,8 +237,7 @@
  *
  */
 int
-get_mtu(intf)
-	char	*intf;
+get_mtu(const char *intf)
 {
 	int			rc, s;
 	struct ifreq		req;
@@ -281,7 +270,7 @@
 	if (rc)
 		return(-1);
 	else
-	return(req.ifr_mtu);
+		return(req.ifr_mtu);
 }
 
 
@@ -301,8 +290,7 @@
  *
  */
 int
-verify_nif_name(name)
-	char *name;
+verify_nif_name(const char *name)
 {
 	int	rc, s;
 	struct atminfreq	air;
@@ -372,11 +360,9 @@
  *
  */
 int
-get_cfg_info ( intf, cfgp )
-        char                    *intf;
-        struct air_cfg_rsp      **cfgp;
+get_cfg_info (const char *intf, struct air_cfg_rsp **cfgp)
 {
-        int     buf_len = sizeof(struct air_cfg_rsp) * 4;
+        int     buf_len = (int)sizeof(struct air_cfg_rsp) * 4;
         struct atminfreq air;
 
         /*
@@ -410,11 +396,9 @@
  *
  */
 int
-get_intf_info ( intf, intp )
-        char                    *intf;
-        struct air_int_rsp      **intp;
+get_intf_info (const char *intf, struct air_int_rsp **intp)
 {
-        int     buf_len = sizeof(struct air_int_rsp) * 4;
+        int     buf_len = (int)sizeof(struct air_int_rsp) * 4;
         struct atminfreq air;
 
         /*
@@ -449,11 +433,9 @@
  *
  */
 int
-get_netif_info ( intf, netp )
-        char                    *intf;
-        struct air_netif_rsp    **netp;
+get_netif_info (const char *intf, struct air_netif_rsp **netp)
 {
-        int     buf_len = sizeof(struct air_netif_rsp) * 10;
+        int     buf_len = (int)sizeof(struct air_netif_rsp) * 10;
         struct atminfreq air;
 
         /*
Index: ip_addr.c
===================================================================
RCS file: /home/ncvs/src/lib/libatm/ip_addr.c,v
retrieving revision 1.8
diff -u -d -r1.8 ip_addr.c
--- ip_addr.c	25 Mar 2003 04:29:26 -0000	1.8
+++ ip_addr.c	10 Jun 2003 18:52:34 -0000
@@ -41,7 +41,6 @@
 #include <net/if.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
-#include <netatm/port.h>
 #include <netatm/atm.h>
 #include <netatm/atm_if.h>
 #include <netatm/atm_sap.h>
@@ -69,11 +68,11 @@
  *
  */
 struct sockaddr_in *
-get_ip_addr(p)
-	char	*p;
+get_ip_addr(const char *p)
 {
 	struct hostent			*ip_host;
 	static struct sockaddr_in	s;
+	u_long				*temp;
 
 	/*
 	 * Get IP address of specified host name
@@ -96,7 +95,8 @@
 				ip_host->h_addrtype != AF_INET) {
 			return((struct sockaddr_in *)0);
 		}
-		s.sin_addr.s_addr = *(u_long *)ip_host->h_addr_list[0];
+		temp = (u_long *)(void *)ip_host->h_addr_list[0];
+		s.sin_addr.s_addr = (u_int)*temp;
 	}
 	return(&s);
 }
@@ -116,8 +116,7 @@
  *
  */
 const char *
-format_ip_addr(addr)
-	struct in_addr	*addr;
+format_ip_addr(const struct in_addr *addr)
 {
 	static char	host_name[128];
 	char		*ip_num;
@@ -132,7 +131,8 @@
 	 * Check for a zero address
 	 */
 	if (!addr || addr->s_addr == 0) {
-		return("-");
+		strcpy(host_name, "-");
+		return(host_name);
 	}
 
 	/*
@@ -143,7 +143,7 @@
 	/*
 	 * Look up name in DNS
 	 */
-	ip_host = gethostbyaddr((char *)addr, sizeof(addr), AF_INET);
+	ip_host = gethostbyaddr((const char *)addr, sizeof(addr), AF_INET);
 	if (ip_host && ip_host->h_name &&
 			strlen(ip_host->h_name)) {
 		/*
Index: ip_checksum.c
===================================================================
RCS file: /home/ncvs/src/lib/libatm/ip_checksum.c,v
retrieving revision 1.7
diff -u -d -r1.7 ip_checksum.c
--- ip_checksum.c	21 Mar 2002 23:35:20 -0000	1.7
+++ ip_checksum.c	10 Jun 2003 18:48:34 -0000
@@ -40,7 +40,6 @@
 #include <sys/socket.h>
 #include <net/if.h>
 #include <netinet/in.h>
-#include <netatm/port.h>
 #include <netatm/atm.h>
 #include <netatm/atm_if.h>
 #include <netatm/atm_sap.h>
@@ -66,25 +65,24 @@
  *
  */
 short
-ip_checksum(addr, count)
-	char 	*addr;
-	int	count;
+ip_checksum(char *addr, int count)
 {
 	/* Compute Internet Checksum for "count" bytes
 	 * beginning at location "addr".
 	 */
-	long sum = 0;
+	unsigned long sum = 0;
+	unsigned short *laddr;
 
+	laddr = (unsigned short *)(void *)addr;
 	while( count > 1 ) {
 		/* This is the inner loop */
-		sum += ntohs(* (unsigned short *) addr);
-		addr += sizeof(unsigned short);
-		count -= sizeof(unsigned short);
+		sum += ntohs(*(laddr++));
+		count -= (int)sizeof(unsigned short);
 	}
 
 	/* Add left-over byte, if any */
 	if( count > 0 )
-		sum += * (unsigned char *) addr;
+		sum += *laddr;
 
 	/* Fold 32-bit sum to 16 bits */
 	while (sum>>16)
Index: libatm.h
===================================================================
RCS file: /home/ncvs/src/lib/libatm/libatm.h,v
retrieving revision 1.6
diff -u -d -r1.6 libatm.h
--- libatm.h	25 Mar 2003 04:29:26 -0000	1.6
+++ libatm.h	10 Jun 2003 19:07:29 -0000
@@ -90,17 +90,17 @@
 
 /* ioctl_subr.c */
 extern int		do_info_ioctl(struct atminfreq *, int);
-extern int		get_vcc_info(char *, struct air_vcc_rsp **);
-extern int		get_subnet_mask(char *, struct sockaddr_in *);
-extern int		get_mtu(char *);
-extern int		verify_nif_name(char *);
-extern int		get_cfg_info(char *, struct air_cfg_rsp **);
-extern int		get_intf_info(char *, struct air_int_rsp **);
-extern int		get_netif_info(char *, struct air_netif_rsp **);
+extern int		get_vcc_info(const char *, struct air_vcc_rsp **);
+extern int		get_subnet_mask(const char *, struct sockaddr_in *);
+extern int		get_mtu(const char *);
+extern int		verify_nif_name(const char *);
+extern int		get_cfg_info(const char *, struct air_cfg_rsp **);
+extern int		get_intf_info(const char *, struct air_int_rsp **);
+extern int		get_netif_info(const char *, struct air_netif_rsp **);
 
 /* ip_addr.c */
-extern struct sockaddr_in	*get_ip_addr(char *);
-extern const char		*format_ip_addr(struct in_addr *);
+extern struct sockaddr_in	*get_ip_addr(const char *);
+extern const char		*format_ip_addr(const struct in_addr *);
 
 /* ip_checksum.c */
 extern short		ip_checksum(char *, int);
Index: timer.c
===================================================================
RCS file: /home/ncvs/src/lib/libatm/timer.c,v
retrieving revision 1.8
diff -u -d -r1.8 timer.c
--- timer.c	25 Mar 2003 04:29:26 -0000	1.8
+++ timer.c	10 Jun 2003 18:49:18 -0000
@@ -40,7 +40,6 @@
 #include <sys/socket.h>
 #include <net/if.h>
 #include <netinet/in.h>
-#include <netatm/port.h>
 #include <netatm/queue.h>
 #include <netatm/atm.h>
 #include <netatm/atm_if.h>
@@ -175,7 +174,7 @@
  *
  */
 int
-init_timer()
+init_timer(void)
 {
 	int			rc = 0;
 	struct itimerval	timeval;
@@ -223,7 +222,7 @@
  *
  */
 int
-block_timer()
+block_timer(void)
 {
 	/*
 	 * Block the SIGALRM signal
@@ -246,8 +245,7 @@
  *
  */
 void
-enable_timer(mask)
-	int	mask;
+enable_timer(int mask)
 {
 	/*
 	 * Set the signal mask

------- =_aaaaaaaaaa0--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200306101916.h5AJGDHh072147>