]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
wifi-scripts: iwinfo scan() must not abort the interpreter on failure
authorJohn Crispin <john@phrozen.org>
Tue, 14 Apr 2026 11:30:41 +0000 (13:30 +0200)
committerFelix Fietkau <nbd@nbd.name>
Fri, 22 May 2026 12:54:34 +0000 (14:54 +0200)
Replace exit(1) on every failure path with return null so callers that
iterate over multiple radios can collect results from the radios that
did succeed instead of aborting on the first one that refuses an
off-channel scan.

Route diagnostics to stderr via warn() so stdout stays clean for
callers parsing JSON output, and include the device name in each
message to disambiguate per-radio failures.

Signed-off-by: John Crispin <john@phrozen.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
package/network/config/wifi-scripts/files-ucode/usr/share/ucode/iwinfo.uc

index 3dfad25523bb04e1d89aa70c2f1ded9a0a53969a..c56026f10453bc4660f9fef9e73c6d6c4ab4c2a8 100644 (file)
@@ -577,23 +577,24 @@ export function scan(dev) {
                scan_ssids: [ '' ],
        };
 
-       let res = nl80211.request(nl80211.const.NL80211_CMD_TRIGGER_SCAN, 0, params);
-       if (res === false) {
-               printf("Unable to trigger scan: " + nl80211.error() + "\n");
-               exit(1);
+       nl80211.request(nl80211.const.NL80211_CMD_TRIGGER_SCAN, 0, params);
+       let err = nl80211.error();
+       if (err) {
+               warn("Unable to trigger scan on " + dev + ": " + err + "\n");
+               return null;
        }
 
-       res = nl80211.waitfor([
+       let res = nl80211.waitfor([
                nl80211.const.NL80211_CMD_NEW_SCAN_RESULTS,
                nl80211.const.NL80211_CMD_SCAN_ABORTED
        ], 5000);
 
        if (!res) {
-               printf("Netlink error while awaiting scan results: " + nl80211.error() + "\n");
-               exit(1);
+               warn("Netlink error while awaiting scan results on " + dev + ": " + nl80211.error() + "\n");
+               return null;
        } else if (res.cmd == nl80211.const.NL80211_CMD_SCAN_ABORTED) {
-               printf("Scan aborted by kernel\n");
-               exit(1);
+               warn("Scan aborted by kernel on " + dev + "\n");
+               return null;
        }
 
        let scan = nl80211.request(nl80211.const.NL80211_CMD_GET_SCAN, nl80211.const.NLM_F_DUMP, { dev });