svn commit: r196931 - head/sbin/ifconfig

Hiroki Sato hrs at FreeBSD.org
Mon Sep 7 15:52:15 UTC 2009


Author: hrs
Date: Mon Sep  7 15:52:15 2009
New Revision: 196931
URL: http://svn.freebsd.org/changeset/base/196931

Log:
  Use printb() instead of rolling its own routine to display
  bits in options=<>.
  
  Pointed out by:	ume
  MFC after:	3 days

Modified:
  head/sbin/ifconfig/ifgif.c

Modified: head/sbin/ifconfig/ifgif.c
==============================================================================
--- head/sbin/ifconfig/ifgif.c	Mon Sep  7 15:43:09 2009	(r196930)
+++ head/sbin/ifconfig/ifgif.c	Mon Sep  7 15:52:15 2009	(r196931)
@@ -51,38 +51,22 @@ static const char rcsid[] =
 
 #include "ifconfig.h"
 
-static void	gif_status(int);
+#define	GIFBITS	"\020\1ACCEPT_REV_ETHIP_VER\5SEND_REV_ETHIP_VER"
 
-static struct {
-	const char	*label;
-	u_int		mask;
-} gif_opts[] = {
-	{ "ACCEPT_REV_ETHIP_VER",	GIF_ACCEPT_REVETHIP	},
-	{ "SEND_REV_ETHIP_VER",		GIF_SEND_REVETHIP	},
-};
+static void	gif_status(int);
 
 static void
 gif_status(int s)
 {
 	int opts;
-	int nopts = 0;
-	size_t i;
 
 	ifr.ifr_data = (caddr_t)&opts;
 	if (ioctl(s, GIFGOPTS, &ifr) == -1)
 		return;
 	if (opts == 0)
 		return;
-
-	printf("\toptions=%d<", opts);
-	for (i=0; i < sizeof(gif_opts)/sizeof(gif_opts[0]); i++) {
-		if (opts & gif_opts[i].mask) {
-			if (nopts++)
-				printf(",");
-			printf("%s", gif_opts[i].label);
-		}
-	}
-	printf(">\n");
+	printb("\toptions", opts, GIFBITS);
+	putchar('\n');
 }
 
 static void


More information about the svn-src-head mailing list