From: Sami Kerola Date: Fri, 23 Oct 2020 19:39:24 +0000 (+0100) Subject: rfkill: stop execution when rfkill device cannot be opened X-Git-Tag: v2.37-rc1~275^2~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=06229abccf69cfc01d2ba05331832850130ee75b;p=thirdparty%2Futil-linux.git rfkill: stop execution when rfkill device cannot be opened 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 --- diff --git a/sys-utils/rfkill.c b/sys-utils/rfkill.c index b00bf753e3..73fb4bab40 100644 --- a/sys-utils/rfkill.c +++ b/sys-utils/rfkill.c @@ -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);