staging: speakup: Remove unnecessary 'else' after a 'return' statement
PATCH 1/1 staging: speakup: Remove unnecessary 'else' after a 'return' statement
This patch resolves the following issue detected by checkpatch.pl:
WARNING: else is not generally useful after a break or return.
--- drivers/staging/speakup/keyhelp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/staging/speakup/keyhelp.c +2 -2
@@ -178,7 +178,7 @@ int spk_handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key)synth_printf ("%s\n" ,spk_msg_get (MSG_HELP_INFO ));build_key_data ();/* rebuild each time in case new mapping */ return 1 ; - }else { + } name =NULL ;if ((type !=KT_SPKUP ) && (key >0 ) && (key <= num_key_names)) { synth_printf("%s\n",
@@ -201,7 +201,7 @@ int spk_handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key)synth_printf (spk_msg_get (MSG_KEYDESC ), name);synth_printf ("\n" );return 1 ; - } + name =spk_msg_get (MSG_FUNCNAMES_START + cur_item); func = funcvals[cur_item];synth_printf ("%s" , name);
Signature · 1 line
2.7.4
Quoted 13 lines · sayli karnik
This patch resolves the following issue detected by checkpatch.pl:
WARNING: else is not generally useful after a break or return.Signed-off-by sayli karnik <[email protected]>--- drivers/staging/speakup/keyhelp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/staging/speakup/keyhelp.c +0
-0
drivers/staging/speakup/keyhelp.c int spk_handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key) · line 182
Quoted 6 lines
drivers/staging/speakup/keyhelp.c +1
-1@@ -178,7 +178,7 @@ int spk_handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key)synth_printf ("%s\n" ,spk_msg_get (MSG_HELP_INFO ));build_key_data ();/* rebuild each time in case new mapping */ return 1 ; - }else { + } name =NULL ;
This looks suspicious. If you drop the else, then the code afterwards should be less indented.
drivers/staging/speakup/keyhelp.c int spk_handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key) · line 204
Quoted 8 lines
drivers/staging/speakup/keyhelp.c +1
-1if ((type !=KT_SPKUP ) && (key >0 ) && (key <= num_key_names)) { synth_printf("%s\n",@@ -201,7 +201,7 @@ int spk_handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key)synth_printf (spk_msg_get (MSG_KEYDESC ), name);synth_printf ("\n" );return 1 ; - } +
Now you will end up with a return followed by an assignment. So that would be dead code. You need to check carefully that the transformation makes sense with regards to the code that is actually in the else branch.
julia
Quoted 13 lines
drivers/staging/speakup/keyhelp.c +0
-1name =spk_msg_get (MSG_FUNCNAMES_START + cur_item); func = funcvals[cur_item];synth_printf ("%s" , name); --2.7.4
--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20160915183258.GA13583%40sayli-HP-15-Notebook-PC.
For more options, visit https://groups.google.com/d/optout.
Quoted 40 lines · Julia Lawall
Quoted 13 lines · sayli karnik
This patch resolves the following issue detected by checkpatch.pl:
WARNING: else is not generally useful after a break or return.Signed-off-by sayli karnik <[email protected]>--- drivers/staging/speakup/keyhelp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/staging/speakup/keyhelp.c +0
-0drivers/staging/speakup/keyhelp.c int spk_handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key) · line 182
Quoted 6 lines
drivers/staging/speakup/keyhelp.c +1
-1@@ -178,7 +178,7 @@ int spk_handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key)synth_printf ("%s\n" ,spk_msg_get (MSG_HELP_INFO ));build_key_data ();/* rebuild each time in case new mapping */ return 1 ; - }else { + } name =NULL ;This looks suspicious. If you drop the else, then the code afterwards should be less indented.
drivers/staging/speakup/keyhelp.c int spk_handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key) · line 204
Quoted 8 lines
drivers/staging/speakup/keyhelp.c +1
-1if ((type !=KT_SPKUP ) && (key >0 ) && (key <= num_key_names)) { synth_printf("%s\n",@@ -201,7 +201,7 @@ int spk_handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key)synth_printf (spk_msg_get (MSG_KEYDESC ), name);synth_printf ("\n" );return 1 ; - } +Now you will end up with a return followed by an assignment. So that would be dead code. You need to check carefully that the transformation makes sense with regards to the code that is actually in the else branch.
Quoted 2 lines
julia
Yes, this will lead to dead code. My bad!
Thanks!
Quoted 13 lines
Quoted 13 lines
drivers/staging/speakup/keyhelp.c +0
-1name =spk_msg_get (MSG_FUNCNAMES_START + cur_item); func = funcvals[cur_item];synth_printf ("%s" , name); --2.7.4
--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20160915183258.GA13583%40sayli-HP-15-Notebook-PC.
For more options, visit https://groups.google.com/d/optout.