Prevent unnecessary iteration in __handle_cmd
PATCH 1/1 Prevent unnecessary iteration in __handle_cmd
Break the loop after matching sectcmd is found. Remove redundant variable copying.
Signed-off-by Sunil Shahu <[email protected]>
--- iw.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
iw.c +1 -3
@@ -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
Quoted 22 lines · Sunil Shahu
Break the loop after matching sectcmd is found. Remove redundant variable copying.
Signed-off-by Sunil Shahu <[email protected]>---
iw.c | 4 +---1 file changed, 1 insertion(+), 3 deletions(-)iw.c +1
-1@@ -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