From: Omer Dagan Date: Sun, 22 Jul 2018 14:44:36 +0000 (+0300) Subject: iw: 'idby' might be used uninitialized in main function X-Git-Tag: v5.0~31 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8a2dfd51ff9ea8f493933a9184c61a8ee7e73dd1;p=thirdparty%2Fiw.git iw: 'idby' might be used uninitialized in main function During static-analysis of the code, a message appeared stating that 'idby' enum might be used un-initialized. It described a case in which the 'goto detect' statment occurred and that means that the enum initialization will be skipped. Johannes: just move the initialization after the label, instead of moving the variable as Omer's patch had it since we always just want it to be II_NONE to start with and don't need it in any other scope. Signed-off-by: Omer Dagan Signed-off-by: Johannes Berg --- diff --git a/iw.c b/iw.c index daa2a77..76f152d 100644 --- a/iw.c +++ b/iw.c @@ -594,8 +594,9 @@ int main(int argc, char **argv) err = __handle_cmd(&nlstate, II_WDEV, argc, argv, &cmd); } else { int idx; - enum id_input idby = II_NONE; + enum id_input idby; detect: + idby = II_NONE; if ((idx = if_nametoindex(argv[0])) != 0) idby = II_NETDEV; else if ((idx = phy_lookup(argv[0])) >= 0)