Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 21 Aug 2006 00:28:56 -0300
From:      Ricardo Nabinger Sanchez <rnsanchez@gmail.com>
To:        freebsd-current@freebsd.org
Subject:   [RFC] (very) small ifmedia.c cleanup
Message-ID:  <20060821002856.601c8dfd.rnsanchez@gmail.com>

next in thread | raw e-mail | index | archive | help
Hello,

I was looking at src/sbin/ifconfig/ifmedia.c source, and noticed that the
handling of IFM_ETHER and IFM_ATM was identical.  Also noticed the use of
goto that, IMHO, could be clearer if made with a plain if (), very similar
to the condition a few lines above each occurence of the gotos.

Now I'm wondering if this diff looks good, as it is a first one I'm sending
over here.  The send-pr(1) seemed to be just too much noise, but if that's
the correct way, please let me know.  The diff is against -current.

Index: src/sbin/ifconfig/ifmedia.c
===================================================================
RCS file: /home/ncvs/src/sbin/ifconfig/ifmedia.c,v
retrieving revision 1.20
diff -u -r1.20 ifmedia.c
--- src/sbin/ifconfig/ifmedia.c	11 Jan 2006 22:37:59 -0000	1.20
+++ src/sbin/ifconfig/ifmedia.c	21 Aug 2006 03:16:44 -0000
@@ -145,6 +145,7 @@
 	if (ifmr.ifm_status & IFM_AVALID) {
 		printf("\tstatus: ");
 		switch (IFM_TYPE(ifmr.ifm_active)) {
+		case IFM_ATM:
 		case IFM_ETHER:
 			if (ifmr.ifm_status & IFM_ACTIVE)
 				printf("active");
@@ -160,13 +161,6 @@
 				printf("no ring");
 			break;
 
-		case IFM_ATM:
-			if (ifmr.ifm_status & IFM_ACTIVE)
-				printf("active");
-			else
-				printf("no carrier");
-			break;
-
 		case IFM_IEEE80211:
 			/* XXX: Different value for adhoc? */
 			if (ifmr.ifm_status & IFM_ACTIVE)
@@ -692,14 +686,11 @@
 
 	/* Find subtype. */
 	desc = get_subtype_desc(ifmw, ttos);
-	if (desc != NULL)
-		goto got_subtype;
-
-	/* Falling to here means unknown subtype. */
-	printf("<unknown subtype>");
-	return;
+	if (desc == NULL) {
+		printf("<unknown subtype>");
+		return;
+	}
 
- got_subtype:
 	if (print_toptype)
 		putchar(' ');
 
@@ -750,14 +741,11 @@
 
 	/* Find subtype. */
 	desc = get_subtype_desc(ifmw, ttos);
-	if (desc != NULL)
-		goto got_subtype;
-
-	/* Falling to here means unknown subtype. */
-	printf("<unknown subtype>");
-	return;
+	if (desc == NULL) {
+		printf("<unknown subtype>");
+		return;
+	}
 
- got_subtype:
 	printf("media %s", desc->ifmt_string);
 
 	desc = get_mode_desc(ifmw, ttos);


Thanks in advance.

ps: in case it is corrupted, it is also available at
<http://rnsanchez.wait4.org/FreeBSD/ifmedia_small_cleanup.diff>.

-- 
Ricardo Nabinger Sanchez     <rnsanchez@{gmail.com,wait4.org}>
Powered by FreeBSD

  "Left to themselves, things tend to go from bad to worse."




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