]> git.ipfire.org Git - thirdparty/iw.git/commitdiff
iw: 'idby' might be used uninitialized in main function
authorOmer Dagan <omer.dagan@tandemg.com>
Sun, 22 Jul 2018 14:44:36 +0000 (17:44 +0300)
committerJohannes Berg <johannes.berg@intel.com>
Tue, 14 Aug 2018 11:21:35 +0000 (13:21 +0200)
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 <omer.dagan@tandemg.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
iw.c

diff --git a/iw.c b/iw.c
index daa2a77008667fd806c9d694d113783cb09387ab..76f152d775d8af83be3b7be6a2356c50c9719214 100644 (file)
--- 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)