Search Linux Wireless

[PATCH] iw: 'idby' might be used uninitialized in main function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx>
---
 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




[Index of Archives]     [Linux Host AP]     [ATH6KL]     [Linux Wireless Personal Area Network]     [Linux Bluetooth]     [Wireless Regulations]     [Linux Netdev]     [Kernel Newbies]     [Linux Kernel]     [IDE]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite Hiking]     [MIPS Linux]     [ARM Linux]     [Linux RAID]

  Powered by Linux