From 9768475eb08a6ebd8c937c81835c2cc55018fc3f Mon Sep 17 00:00:00 2001 From: Kevin Lo Date: Sat, 19 Oct 2013 18:13:32 +0000 Subject: [PATCH] - Add parentheses to all internet addresses - All the casts to uint32_t should be to in_addr_t Suggested by: bde Reviewed by: bde --- sys/netinet/in.h | 52 ++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/sys/netinet/in.h b/sys/netinet/in.h index deb74192bceb..2eb3609b34cb 100644 --- a/sys/netinet/in.h +++ b/sys/netinet/in.h @@ -43,8 +43,8 @@ #define IPPROTO_TCP 6 /* tcp */ #define IPPROTO_UDP 17 /* user datagram protocol */ -#define INADDR_ANY (u_int32_t)0x00000000 -#define INADDR_BROADCAST (u_int32_t)0xffffffff /* must be masked */ +#define INADDR_ANY ((in_addr_t)0x00000000) +#define INADDR_BROADCAST ((in_addr_t)0xffffffff) /* must be masked */ #ifndef _UINT8_T_DECLARED typedef __uint8_t uint8_t; @@ -339,61 +339,61 @@ __END_DECLS * On subnets, the decomposition of addresses to host and net parts * is done according to subnet mask, not the masks here. */ -#define IN_CLASSA(i) (((u_int32_t)(i) & 0x80000000) == 0) +#define IN_CLASSA(i) (((in_addr_t)(i) & 0x80000000) == 0) #define IN_CLASSA_NET 0xff000000 #define IN_CLASSA_NSHIFT 24 #define IN_CLASSA_HOST 0x00ffffff #define IN_CLASSA_MAX 128 -#define IN_CLASSB(i) (((u_int32_t)(i) & 0xc0000000) == 0x80000000) +#define IN_CLASSB(i) (((in_addr_t)(i) & 0xc0000000) == 0x80000000) #define IN_CLASSB_NET 0xffff0000 #define IN_CLASSB_NSHIFT 16 #define IN_CLASSB_HOST 0x0000ffff #define IN_CLASSB_MAX 65536 -#define IN_CLASSC(i) (((u_int32_t)(i) & 0xe0000000) == 0xc0000000) +#define IN_CLASSC(i) (((in_addr_t)(i) & 0xe0000000) == 0xc0000000) #define IN_CLASSC_NET 0xffffff00 #define IN_CLASSC_NSHIFT 8 #define IN_CLASSC_HOST 0x000000ff -#define IN_CLASSD(i) (((u_int32_t)(i) & 0xf0000000) == 0xe0000000) +#define IN_CLASSD(i) (((in_addr_t)(i) & 0xf0000000) == 0xe0000000) #define IN_CLASSD_NET 0xf0000000 /* These ones aren't really */ #define IN_CLASSD_NSHIFT 28 /* net and host fields, but */ #define IN_CLASSD_HOST 0x0fffffff /* routing needn't know. */ #define IN_MULTICAST(i) IN_CLASSD(i) -#define IN_EXPERIMENTAL(i) (((u_int32_t)(i) & 0xf0000000) == 0xf0000000) -#define IN_BADCLASS(i) (((u_int32_t)(i) & 0xf0000000) == 0xf0000000) +#define IN_EXPERIMENTAL(i) (((in_addr_t)(i) & 0xf0000000) == 0xf0000000) +#define IN_BADCLASS(i) (((in_addr_t)(i) & 0xf0000000) == 0xf0000000) -#define IN_LINKLOCAL(i) (((u_int32_t)(i) & 0xffff0000) == 0xa9fe0000) -#define IN_LOOPBACK(i) (((u_int32_t)(i) & 0xff000000) == 0x7f000000) -#define IN_ZERONET(i) (((u_int32_t)(i) & 0xff000000) == 0) +#define IN_LINKLOCAL(i) (((in_addr_t)(i) & 0xffff0000) == 0xa9fe0000) +#define IN_LOOPBACK(i) (((in_addr_t)(i) & 0xff000000) == 0x7f000000) +#define IN_ZERONET(i) (((in_addr_t)(i) & 0xff000000) == 0) -#define IN_PRIVATE(i) ((((u_int32_t)(i) & 0xff000000) == 0x0a000000) || \ - (((u_int32_t)(i) & 0xfff00000) == 0xac100000) || \ - (((u_int32_t)(i) & 0xffff0000) == 0xc0a80000)) +#define IN_PRIVATE(i) ((((in_addr_t)(i) & 0xff000000) == 0x0a000000) || \ + (((in_addr_t)(i) & 0xfff00000) == 0xac100000) || \ + (((in_addr_t)(i) & 0xffff0000) == 0xc0a80000)) -#define IN_LOCAL_GROUP(i) (((u_int32_t)(i) & 0xffffff00) == 0xe0000000) +#define IN_LOCAL_GROUP(i) (((in_addr_t)(i) & 0xffffff00) == 0xe0000000) #define IN_ANY_LOCAL(i) (IN_LINKLOCAL(i) || IN_LOCAL_GROUP(i)) -#define INADDR_LOOPBACK (u_int32_t)0x7f000001 +#define INADDR_LOOPBACK ((in_addr_t)0x7f000001) #ifndef _KERNEL -#define INADDR_NONE (uint32_t)0xffffffff /* -1 return */ +#define INADDR_NONE ((in_addr_t)0xffffffff) /* -1 return */ #endif -#define INADDR_UNSPEC_GROUP (u_int32_t)0xe0000000 /* 224.0.0.0 */ -#define INADDR_ALLHOSTS_GROUP (u_int32_t)0xe0000001 /* 224.0.0.1 */ -#define INADDR_ALLRTRS_GROUP (u_int32_t)0xe0000002 /* 224.0.0.2 */ -#define INADDR_ALLRPTS_GROUP (u_int32_t)0xe0000016 /* 224.0.0.22, IGMPv3 */ -#define INADDR_CARP_GROUP (u_int32_t)0xe0000012 /* 224.0.0.18 */ -#define INADDR_PFSYNC_GROUP (u_int32_t)0xe00000f0 /* 224.0.0.240 */ -#define INADDR_ALLMDNS_GROUP (u_int32_t)0xe00000fb /* 224.0.0.251 */ -#define INADDR_MAX_LOCAL_GROUP (u_int32_t)0xe00000ff /* 224.0.0.255 */ +#define INADDR_UNSPEC_GROUP ((in_addr_t)0xe0000000) /* 224.0.0.0 */ +#define INADDR_ALLHOSTS_GROUP ((in_addr_t)0xe0000001) /* 224.0.0.1 */ +#define INADDR_ALLRTRS_GROUP ((in_addr_t)0xe0000002) /* 224.0.0.2 */ +#define INADDR_ALLRPTS_GROUP ((in_addr_t)0xe0000016) /* 224.0.0.22, IGMPv3 */ +#define INADDR_CARP_GROUP ((in_addr_t)0xe0000012) /* 224.0.0.18 */ +#define INADDR_PFSYNC_GROUP ((in_addr_t)0xe00000f0) /* 224.0.0.240 */ +#define INADDR_ALLMDNS_GROUP ((in_addr_t)0xe00000fb) /* 224.0.0.251 */ +#define INADDR_MAX_LOCAL_GROUP ((in_addr_t)0xe00000ff) /* 224.0.0.255 */ #define IN_LOOPBACKNET 127 /* official! */ -#define IN_RFC3021_MASK (u_int32_t)0xfffffffe +#define IN_RFC3021_MASK ((in_addr_t)0xfffffffe) /* * Options for use with [gs]etsockopt at the IP level.