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 _at__at_ -145,6 +145,7 _at__at_ 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"); _at__at_ -160,13 +161,6 _at__at_ 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) _at__at_ -692,14 +686,11 _at__at_ /* 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(' '); _at__at_ -750,14 +741,11 _at__at_ /* 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_at_{gmail.com,wait4.org}> Powered by FreeBSD "Left to themselves, things tend to go from bad to worse."Received on Mon Aug 21 2006 - 01:30:42 UTC
This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:59 UTC