Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 14 Mar 2021 09:09:45 GMT
From:      Ryan Moeller <freqlabs@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: caab2f4c89ba - stable/13 - sbin/ifconfig: Minor housekeeping
Message-ID:  <202103140909.12E99jFd078314@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by freqlabs:

URL: https://cgit.FreeBSD.org/src/commit/?id=caab2f4c89bae2c44dc056d82e445cc71c183406

commit caab2f4c89bae2c44dc056d82e445cc71c183406
Author:     Ryan Moeller <freqlabs@FreeBSD.org>
AuthorDate: 2021-02-28 02:08:43 +0000
Commit:     Ryan Moeller <freqlabs@FreeBSD.org>
CommitDate: 2021-03-14 08:07:06 +0000

    sbin/ifconfig: Minor housekeeping
    
    Coalesce adjacent lint ifdefs.
    Fix spelling of nitems.
    
    Reviewed by:    kp
    Differential Revision:  https://reviews.freebsd.org/D29022
    
    (cherry picked from commit 88832d59dec10e97dd64b44391606776b20e782b)
---
 sbin/ifconfig/ifconfig.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c
index 451532246d40..c99602dd0d84 100644
--- a/sbin/ifconfig/ifconfig.c
+++ b/sbin/ifconfig/ifconfig.c
@@ -33,9 +33,6 @@
 static const char copyright[] =
 "@(#) Copyright (c) 1983, 1993\n\
 	The Regents of the University of California.  All rights reserved.\n";
-#endif /* not lint */
-
-#ifndef lint
 #if 0
 static char sccsid[] = "@(#)ifconfig.c	8.2 (Berkeley) 2/16/94";
 #endif
@@ -211,8 +208,6 @@ ioctl_ifcreate(int s, struct ifreq *ifr)
 	}
 }
 
-#define ORDERS_SIZE(x) sizeof(x) / sizeof(x[0])
-
 static int
 calcorders(struct ifaddrs *ifa, struct ifa_queue *q)
 {
@@ -242,7 +237,7 @@ calcorders(struct ifaddrs *ifa, struct ifa_queue *q)
 		if (ifa->ifa_addr) {
 			af = ifa->ifa_addr->sa_family;
 
-			if (af < ORDERS_SIZE(cur->af_orders) &&
+			if (af < nitems(cur->af_orders) &&
 			    cur->af_orders[af] == 0)
 				cur->af_orders[af] = ++ord;
 		}
@@ -293,8 +288,7 @@ cmpifaddrs(struct ifaddrs *a, struct ifaddrs *b, struct ifa_queue *q)
 		af1 = a->ifa_addr->sa_family;
 		af2 = b->ifa_addr->sa_family;
 
-		if (af1 < ORDERS_SIZE(e1->af_orders) &&
-		    af2 < ORDERS_SIZE(e1->af_orders))
+		if (af1 < nitems(e1->af_orders) && af2 < nitems(e1->af_orders))
 			return (e1->af_orders[af1] - e1->af_orders[af2]);
 	}
 
@@ -343,8 +337,6 @@ static void setformat(char *input)
 	free(formatstr);
 }
 
-#undef ORDERS_SIZE
-
 static struct ifaddrs *
 sortifaddrs(struct ifaddrs *list,
     int (*compare)(struct ifaddrs *, struct ifaddrs *, struct ifa_queue *),



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