]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
rfkill: stop execution when rfkill device cannot be opened
authorSami Kerola <kerolasa@iki.fi>
Fri, 23 Oct 2020 19:39:24 +0000 (20:39 +0100)
committerSami Kerola <kerolasa@iki.fi>
Sat, 14 Nov 2020 15:22:34 +0000 (15:22 +0000)
Without this two error messages are printed when rfkill device
cannot be opened.

    $ rfkill
    rfkill: cannot open /dev/rfkill: No such file or directory
    rfkill: cannot read /dev/rfkill: Bad file descriptor

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
sys-utils/rfkill.c

index b00bf753e379f668d436fdc32e3fffe6285c64f8..73fb4bab408346b1a955dec4b9dcc0affe63ee89 100644 (file)
@@ -420,6 +420,8 @@ static int rfkill_list_old(const char *param)
        }
 
        fd = rfkill_ro_open(1);
+       if (fd < 0)
+               return -errno;
 
        while (1) {
                rc = rfkill_read_event(fd, &event);
@@ -492,6 +494,8 @@ static int rfkill_list_fill(struct control const *ctrl, const char *param)
        }
 
        fd = rfkill_ro_open(1);
+       if (fd < 0)
+               return -errno;
 
        while (1) {
                rc = rfkill_read_event(fd, &event);