linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iw: 'idby' might be used uninitialized in main function
@ 2018-07-22 14:44 Omer Dagan
  0 siblings, 0 replies; only message in thread
From: Omer Dagan @ 2018-07-22 14:44 UTC (permalink / raw)
  To: johannes; +Cc: linux-wireless, Omer Dagan

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 initialiaztion will be skipped
The change puts the declaration of the 'idx' var and the enum at the
start of the main function and resets the enum value
at the original location in-order to maintain the current flow

Signed-off-by: Omer Dagan <omer.dagan@tandemg.com>
---
 iw.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/iw.c b/iw.c
index daa2a77..558cc9c 100644
--- a/iw.c
+++ b/iw.c
@@ -547,6 +547,8 @@ int main(int argc, char **argv)
 	struct nl80211_state nlstate;
 	int err;
 	const struct cmd *cmd = NULL;
+	int idx;
+	enum id_input idby = II_NONE;
 
 	/* calculate command size including padding */
 	cmd_size = labs((long)&__section_set - (long)&__section_get);
@@ -593,8 +595,7 @@ int main(int argc, char **argv)
 		argv++;
 		err = __handle_cmd(&nlstate, II_WDEV, argc, argv, &cmd);
 	} else {
-		int idx;
-		enum id_input idby = II_NONE;
+		idby = II_NONE;
  detect:
 		if ((idx = if_nametoindex(argv[0])) != 0)
 			idby = II_NETDEV;
-- 
2.17.1

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2018-07-22 15:42 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-22 14:44 [PATCH] iw: 'idby' might be used uninitialized in main function Omer Dagan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).