From nobody@FreeBSD.org  Mon Aug 21 16:44:25 2006
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 240FC16A4DA
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 21 Aug 2006 16:44:25 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 73B9843D49
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 21 Aug 2006 16:44:24 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id k7LGiOf3054408
	for <freebsd-gnats-submit@FreeBSD.org>; Mon, 21 Aug 2006 16:44:24 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id k7LGiODJ054406;
	Mon, 21 Aug 2006 16:44:24 GMT
	(envelope-from nobody)
Message-Id: <200608211644.k7LGiODJ054406@www.freebsd.org>
Date: Mon, 21 Aug 2006 16:44:24 GMT
From: Ricardo Nabinger Sanchez <rnsanchez@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Small cleanup for ifmedia.c
X-Send-Pr-Version: www-2.3

>Number:         102354
>Category:       bin
>Synopsis:       [patch] Small cleanup for ifmedia.c
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    thomas
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          update
>Submitter-Id:   current-users
>Arrival-Date:   Mon Aug 21 16:50:19 GMT 2006
>Closed-Date:    Mon Mar 26 08:11:29 GMT 2007
>Last-Modified:  Mon Mar 26 08:11:29 GMT 2007
>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@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:
Responsible-Changed-From-To: freebsd-bugs->thomas 
Responsible-Changed-By: thomas 
Responsible-Changed-When: Mon Aug 21 20:27:26 UTC 2006 
Responsible-Changed-Why:  
I'll take care of committing these changes. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=102354 
State-Changed-From-To: open->patched 
State-Changed-By: thomas 
State-Changed-When: Tue Aug 22 23:50:00 UTC 2006 
State-Changed-Why:  
Committed on HEAD as src/sbin/ifconfig/ifmedia.c rev. 1.21. 
Thanks! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=102354 
State-Changed-From-To: patched->closed 
State-Changed-By: thomas 
State-Changed-When: Mon Mar 26 08:10:31 UTC 2007 
State-Changed-Why:  
This change was MFC'd on RELENG_6 on 2006-08-31 (ifmedia.c rev. 1.19.2.2). 

http://www.freebsd.org/cgi/query-pr.cgi?pr=102354 
>Unformatted:
