From owner-freebsd-current@FreeBSD.ORG Mon Aug 21 03:30:42 2006 Return-Path: X-Original-To: freebsd-current@freebsd.org Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 3B64F16A4DF for ; Mon, 21 Aug 2006 03:30:42 +0000 (UTC) (envelope-from rnsanchez@gmail.com) Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.239]) by mx1.FreeBSD.org (Postfix) with ESMTP id A714243D55 for ; Mon, 21 Aug 2006 03:30:41 +0000 (GMT) (envelope-from rnsanchez@gmail.com) Received: by wx-out-0506.google.com with SMTP id i27so1413442wxd for ; Sun, 20 Aug 2006 20:30:41 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:date:from:to:subject:message-id:x-mailer:mime-version:content-type:content-transfer-encoding; b=qJTyS54EXo+bESzxzcaVbZQtnQpRJm7CyQfynSVyMg/LpIaZ3jzfFNqtkE9OO1UbAI8Us4c5HPOr15rZL/+KrOhfwFlLZUZs9l/Qq0FQeVvCSykEX5jz6+madyo8Z+DTHjEBY9S/Ifdf+qcUVs10tV13k5HxPSf0LgBlTd7L55E= Received: by 10.70.69.2 with SMTP id r2mr8795410wxa; Sun, 20 Aug 2006 20:29:00 -0700 (PDT) Received: from sauron.lan.box ( [200.180.187.110]) by mx.gmail.com with ESMTP id 33sm1002392wra.2006.08.20.20.28.58; Sun, 20 Aug 2006 20:29:00 -0700 (PDT) Date: Mon, 21 Aug 2006 00:28:56 -0300 From: Ricardo Nabinger Sanchez To: freebsd-current@freebsd.org Message-Id: <20060821002856.601c8dfd.rnsanchez@gmail.com> X-Mailer: Sylpheed version 2.2.7 (GTK+ 2.8.20; i386-portbld-freebsd6.1) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: [RFC] (very) small ifmedia.c cleanup X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Aug 2006 03:30:42 -0000 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(""); - return; + if (desc == NULL) { + printf(""); + 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(""); - return; + if (desc == NULL) { + printf(""); + 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 . -- Ricardo Nabinger Sanchez Powered by FreeBSD "Left to themselves, things tend to go from bad to worse."