svn commit: r256506 - in head: sbin/nos-tun usr.bin/rpcinfo usr.bin/systat usr.sbin/bootparamd/bootparamd usr.sbin/bootparamd/callbootd usr.sbin/ypset

Kevin Lo kevlo at FreeBSD.org
Tue Oct 15 07:37:32 UTC 2013


Author: kevlo
Date: Tue Oct 15 07:37:30 2013
New Revision: 256506
URL: http://svnweb.freebsd.org/changeset/base/256506

Log:
  Use INADDR_NONE instead of -1 to check inet_addr() result.
  
  Reviewed by:	glebius

Modified:
  head/sbin/nos-tun/nos-tun.c
  head/usr.bin/rpcinfo/rpcinfo.c
  head/usr.bin/systat/netcmds.c
  head/usr.sbin/bootparamd/bootparamd/main.c
  head/usr.sbin/bootparamd/callbootd/callbootd.c
  head/usr.sbin/ypset/ypset.c

Modified: head/sbin/nos-tun/nos-tun.c
==============================================================================
--- head/sbin/nos-tun/nos-tun.c	Tue Oct 15 07:35:39 2013	(r256505)
+++ head/sbin/nos-tun/nos-tun.c	Tue Oct 15 07:37:30 2013	(r256506)
@@ -96,7 +96,7 @@ Set_address(char *addr, struct sockaddr_
 
   bzero((char *)sin, sizeof(struct sockaddr));
   sin->sin_family = AF_INET;
-  if((sin->sin_addr.s_addr = inet_addr(addr)) == (in_addr_t)-1) {
+  if((sin->sin_addr.s_addr = inet_addr(addr)) == INADDR_NONE) {
     hp = gethostbyname(addr);
     if (!hp) {
       syslog(LOG_ERR,"unknown host %s", addr);

Modified: head/usr.bin/rpcinfo/rpcinfo.c
==============================================================================
--- head/usr.bin/rpcinfo/rpcinfo.c	Tue Oct 15 07:35:39 2013	(r256505)
+++ head/usr.bin/rpcinfo/rpcinfo.c	Tue Oct 15 07:37:30 2013	(r256506)
@@ -563,7 +563,8 @@ get_inet_address(struct sockaddr_in *add
 
 	(void) memset((char *)addr, 0, sizeof (*addr));
 	addr->sin_addr.s_addr = inet_addr(host);
-	if (addr->sin_addr.s_addr == -1 || addr->sin_addr.s_addr == 0) {
+	if (addr->sin_addr.s_addr == INADDR_NONE ||
+	    addr->sin_addr.s_addr == INADDR_ANY) {
 		if ((nconf = __rpc_getconfip("udp")) == NULL &&
 		    (nconf = __rpc_getconfip("tcp")) == NULL)
 			errx(1, "couldn't find a suitable transport");

Modified: head/usr.bin/systat/netcmds.c
==============================================================================
--- head/usr.bin/systat/netcmds.c	Tue Oct 15 07:35:39 2013	(r256505)
+++ head/usr.bin/systat/netcmds.c	Tue Oct 15 07:37:30 2013	(r256506)
@@ -152,7 +152,7 @@ changeitems(const char *args, int onoff)
 		hp = gethostbyname(tmpstr1);
 		if (hp == 0) {
 			in.s_addr = inet_addr(tmpstr1);
-			if ((int)in.s_addr == -1) {
+			if (in.s_addr == INADDR_NONE) {
 				error("%s: unknown host or port", tmpstr1);
 				continue;
 			}

Modified: head/usr.sbin/bootparamd/bootparamd/main.c
==============================================================================
--- head/usr.sbin/bootparamd/bootparamd/main.c	Tue Oct 15 07:35:39 2013	(r256505)
+++ head/usr.sbin/bootparamd/bootparamd/main.c	Tue Oct 15 07:37:30 2013	(r256506)
@@ -86,7 +86,7 @@ char **argv;
 	if ( stat(bootpfile, &buf ) )
 	  err(1, "%s", bootpfile);
 
-	if (route_addr == -1) {
+	if (route_addr == INADDR_NONE) {
 	  get_myaddress(&my_addr);
 	  bcopy(&my_addr.sin_addr.s_addr, &route_addr, sizeof (route_addr));
 	}

Modified: head/usr.sbin/bootparamd/callbootd/callbootd.c
==============================================================================
--- head/usr.sbin/bootparamd/callbootd/callbootd.c	Tue Oct 15 07:35:39 2013	(r256505)
+++ head/usr.sbin/bootparamd/callbootd/callbootd.c	Tue Oct 15 07:37:30 2013	(r256506)
@@ -104,7 +104,7 @@ char **argv;
   case 3:
     whoami_arg.client_address.address_type = IP_ADDR_TYPE;
     the_inet_addr = inet_addr(argv[2]);
-    if ( the_inet_addr == -1)
+    if ( the_inet_addr == INADDR_NONE)
       errx(2, "bogus addr %s", argv[2]);
     bcopy(&the_inet_addr,&whoami_arg.client_address.bp_address_u.ip_addr,4);
 

Modified: head/usr.sbin/ypset/ypset.c
==============================================================================
--- head/usr.sbin/ypset/ypset.c	Tue Oct 15 07:35:39 2013	(r256505)
+++ head/usr.sbin/ypset/ypset.c	Tue Oct 15 07:37:30 2013	(r256506)
@@ -75,7 +75,7 @@ bind_tohost(struct sockaddr_in *sin, cha
 		bcopy (hp->h_addr_list[0],
 		       (u_long *)&ypsd.ypsetdom_binding.ypbind_binding_addr,
 		       sizeof (unsigned long));
-	} else if ((long)(server_addr = inet_addr (server)) == -1) {
+	} else if ((server_addr = inet_addr(server)) == INADDR_NONE) {
 		errx(1, "can't find address for %s", server);
 	} else
 		bcopy (&server_addr,
@@ -129,7 +129,8 @@ main(int argc, char *argv[])
 			domainname = optarg;
 			break;
 		case 'h':
-			if ((sin.sin_addr.s_addr = inet_addr(optarg)) == -1) {
+			if ((sin.sin_addr.s_addr = inet_addr(optarg)) ==
+			    INADDR_NONE) {
 				hent = gethostbyname(optarg);
 				if (hent == NULL)
 					errx(1, "host %s unknown", optarg);


More information about the svn-src-head mailing list