Unify RSSI check
authorkn <kn@openbsd.org>
Sun, 18 Dec 2022 18:56:38 +0000 (18:56 +0000)
committerkn <kn@openbsd.org>
Sun, 18 Dec 2022 18:56:38 +0000 (18:56 +0000)
Two spots in ifconfig print the signal strength, one for the "ieee80211: "
line and one for each SSID in scan output.

Only the former checks nr_rssi, which is not needed as nr_max_rssi alone
indicates whether the driver reports signal strength in percentage or dBm.

Zap the nr_rssi check to simplify;  "worst case" we display 0% or 0dBm
instead of nothing.

Feedback OK stsp

sbin/ifconfig/ifconfig.c

index 1f69932..0675315 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: ifconfig.c,v 1.459 2022/11/26 07:26:43 jmc Exp $      */
+/*     $OpenBSD: ifconfig.c,v 1.460 2022/12/18 18:56:38 kn Exp $       */
 /*     $NetBSD: ifconfig.c,v 1.40 1997/10/01 02:19:43 enami Exp $      */
 
 /*
@@ -2522,13 +2522,10 @@ ieee80211_status(void)
                bcopy(bssid.i_bssid, &nr.nr_macaddr, sizeof(nr.nr_macaddr));
                strlcpy(nr.nr_ifname, ifname, sizeof(nr.nr_ifname));
                if (ioctl(sock, SIOCG80211NODE, &nr) == 0) {
-                       if (nr.nr_rssi) {
-                               if (nr.nr_max_rssi)
-                                       printf(" %u%%",
-                                           IEEE80211_NODEREQ_RSSI(&nr));
-                               else
-                                       printf(" %ddBm", nr.nr_rssi);
-                       }
+                       if (nr.nr_max_rssi)
+                               printf(" %u%%", IEEE80211_NODEREQ_RSSI(&nr));
+                       else
+                               printf(" %ddBm", nr.nr_rssi);
                        assocfail = nr.nr_assoc_fail;
                }
        }