Skip to contentSkip to conversation

Prevent unnecessary iteration in __handle_cmd

PATCH In review Sunil Shahu 2 participants 2 messages Apr 1, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Prevent unnecessary iteration in __handle_cmd

Break the loop after matching sectcmd is found. Remove redundant variable copying.

---
 iw.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
iw.c +1 -3
index 0f511d9..73ae347 100644
@@ -376,11 +376,9 @@ static int __handle_cmd(struct nl80211_state *state, enum id_input idby,
 		if (match && sectcmd->idby != command_idby)
 			continue;
 		if (strcmp(sectcmd->name, section) == 0)
-			match = sectcmd;
+			break;
 	}
 
-	sectcmd = match;
-	match = NULL;
 	if (!sectcmd)
 		return 1;
 
Signature · 1 line
1.9.1
#1 lore raw
Quoted 22 lines · Sunil Shahu

Break the loop after matching sectcmd is found. Remove redundant variable copying.

---
 iw.c | 4 +---

 1 file changed, 1 insertion(+), 3 deletions(-)
iw.c +1 -1
index 0f511d9..73ae347 100644
@@ -376,11 +376,9 @@ static int __handle_cmd(struct nl80211_state
 *state, enum id_input idby,
  		if (match && sectcmd->idby != command_idby)
  			continue;
  		if (strcmp(sectcmd->name, section) == 0)
-			match = sectcmd;
+			break;
  	}

iw.c static int __handle_cmd(struct nl80211_state *state, enum id_input idby, · line 383

Quoted 2 lines
iw.c +0 -2
-	sectcmd = match;
-	match = NULL;

I don't think this works - what if you reach the end of the loop?

johannes