Page MenuHomeFreeBSD

Drop the ternary operator for calculating ssid display length in list_scan()
ClosedPublic

Authored by sevan on Aug 2 2018, 2:29 PM.
Tags
None
Referenced Files
F106181830: D16566.id46185.diff
Thu, Dec 26, 6:04 PM
Unknown Object (File)
Sat, Dec 21, 3:56 PM
Unknown Object (File)
Mon, Dec 9, 1:39 AM
Unknown Object (File)
Thu, Nov 28, 11:26 PM
Unknown Object (File)
Nov 16 2024, 3:33 AM
Unknown Object (File)
Oct 30 2024, 2:28 PM
Unknown Object (File)
Oct 8 2024, 7:50 AM
Unknown Object (File)
Oct 5 2024, 5:40 AM
Subscribers

Details

Summary

Regardless if a verbose scan is required or not, the answer is always 32 for now
and should IEEE80211_NWID_LEN be raised from the value of 32 we'd still want to
display the full SSID name by default as that is a common use case for invoking
a scan (finding out what networks are available).

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 18523
Build 18225: arc lint + arc unit

Event Timeline

You're right that the ternary operator is now redundant. I wonder if it wouldn't be better to just get rid of ssidmax and use IEEE80211_NWID_LEN everywhere in its place:

diff --git a/sbin/ifconfig/ifieee80211.c b/sbin/ifconfig/ifieee80211.c
index 57c904949d1..63347ed805e 100644
--- a/sbin/ifconfig/ifieee80211.c
+++ b/sbin/ifconfig/ifieee80211.c
@@ -3496,7 +3496,7 @@ list_scan(int s)
        uint8_t buf[24*1024];
        char ssid[IEEE80211_NWID_LEN+1];
        const uint8_t *cp;
-       int len, ssidmax, idlen;
+       int len, idlen;

        if (get80211len(s, IEEE80211_IOC_SCAN_RESULTS, buf, sizeof(buf), &len) < 0)
                errx(1, "unable to get scan results");
@@ -3505,9 +3505,8 @@ list_scan(int s)

        getchaninfo(s);

-       ssidmax = verbose ? IEEE80211_NWID_LEN : 32;
        printf("%-*.*s  %-17.17s  %4s %4s   %-7s  %3s %4s\n"
-               , ssidmax, ssidmax, "SSID/MESH ID"
+               , IEEE80211_NWID_LEN, IEEE80211_NWID_LEN, "SSID/MESH ID"
                , "BSSID"
                , "CHAN"
                , "RATE"
@@ -3530,8 +3529,8 @@ list_scan(int s)
                        idlen = sr->isr_ssid_len;
                }
                printf("%-*.*s  %s  %3d  %3dM %4d:%-4d %4d %-4.4s"
-                       , ssidmax
-                         , copy_essid(ssid, ssidmax, idp, idlen)
+                       , IEEE80211_NWID_LEN
+                         , copy_essid(ssid, IEEE80211_NWID_LEN, idp, idlen)
                          , ssid
                        , ether_ntoa((const struct ether_addr *) sr->isr_bssid)
                        , ieee80211_mhz2ieee(sr->isr_freq, sr->isr_flags)
This revision is now accepted and ready to land.Aug 11 2018, 10:08 AM
This revision was automatically updated to reflect the committed changes.