bin/102354: Small cleanup for ifmedia.c

Ricardo Nabinger Sanchez rnsanchez at gmail.com
Mon Aug 21 16:50:26 UTC 2006


>Number:         102354
>Category:       bin
>Synopsis:       Small cleanup for ifmedia.c
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Mon Aug 21 16:50:19 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator:     Ricardo Nabinger Sanchez
>Release:        FreeBSD-6.1-RELEASE
>Organization:
>Environment:
FreeBSD sauron.lan.box 6.1-RELEASE FreeBSD 6.1-RELEASE #0: Sun May  7 04:32:43 UTC 2006     root at opus.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  i386
>Description:
Just a small cleanup for ifmedia, covering:

* removing a redundant case, consolidating IFM_ETHER and IFM_ATM together.
* removing unnecessary gotos, in the sense that a simple if () does the same thing, preserving the style (each goto is preceeded by a similar condition modelled with if (), as this patch also does).

In case the fix is mangled, the patch is available at:

http://rnsanchez.wait4.org/FreeBSD/ifmedia_small_cleanup.diff
>How-To-Repeat:

>Fix:
This patch 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);
>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list