staging: speakup: else is not generally useful after a break or return
PATCH 1/1 staging: speakup: else is not generally useful after a break or return
fixed checkpatch.pl warning: else is not generally useful after a break or return.
Removed the else without affecting the logic.
Dead code is also eliminated.
--- drivers/staging/speakup/keyhelp.c | 53 ++++++++++++++------------------------- 1 file changed, 19 insertions(+), 34 deletions(-)
drivers/staging/speakup/keyhelp.c +19 -34
@@ -176,43 +176,28 @@ 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" , -spk_msg_get (MSG_KEYNAMES_START + key -1 )); -return 1 ; - } -for (i =0 ; funcvals[i] !=0 && !name; i++) { -if (ch == funcvals[i]) - name =spk_msg_get (MSG_FUNCNAMES_START + i); - } -if (!name) -return -1 ; - kp = spk_our_keys[key] +1 ; -for (i =0 ; i < nstates; i++) { -if (ch == kp[i]) -break ; - } - key += (state_tbl[i] <<8 ); -say_key (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); -if (key_offsets[func] ==0 ) { -synth_printf (" %s\n" ,spk_msg_get (MSG_IS_UNASSIGNED )); + + name =NULL ; +if ((type !=KT_SPKUP ) && (key >0 ) && (key <= num_key_names)) { +synth_printf ("%s\n" , +spk_msg_get (MSG_KEYNAMES_START + key -1 ));return 1 ; } - p_keys = key_data + key_offsets[func]; -for (n =0 ; p_keys[n]; n++) { - val = p_keys[n]; -if (n >0 ) -synth_printf ("%s " ,spk_msg_get (MSG_DISJUNCTION )); -say_key (val); +for (i =0 ; funcvals[i] !=0 && !name; i++) { +if (ch == funcvals[i]) + name =spk_msg_get (MSG_FUNCNAMES_START + i); + } +if (!name) +return -1 ; + kp = spk_our_keys[key] +1 ; +for (i =0 ; i < nstates; i++) { +if (ch == kp[i]) +break ; } + key += (state_tbl[i] <<8 ); +say_key (key); +synth_printf (spk_msg_get (MSG_KEYDESC ), name); +synth_printf ("\n" );return 1 ; }
Signature · 1 line
2.11.0
Quoted 4 lines · Arushi Singhal
fixed checkpatch.pl warning: else is not generally useful after a break or return.
Removed the else without affecting the logic.
Dead code is also eliminated.
The chhange is not correct. There is a big chain of if/else if. The if (type == KT_LATIN) can reach the code at the end of the file.
julia
Quoted 83 lines
Signed-off-by Arushi Singhal <[email protected]>--- drivers/staging/speakup/keyhelp.c | 53 ++++++++++++++------------------------- 1 file changed, 19 insertions(+), 34 deletions(-)drivers/staging/speakup/keyhelp.c +19
-35@@ -176,43 +176,28 @@ 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" , -spk_msg_get (MSG_KEYNAMES_START + key -1 )); -return 1 ; - } -for (i =0 ; funcvals[i] !=0 && !name; i++) { -if (ch == funcvals[i]) - name =spk_msg_get (MSG_FUNCNAMES_START + i); - } -if (!name) -return -1 ; - kp = spk_our_keys[key] +1 ; -for (i =0 ; i < nstates; i++) { -if (ch == kp[i]) -break ; - } - key += (state_tbl[i] <<8 ); -say_key (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); -if (key_offsets[func] ==0 ) { -synth_printf (" %s\n" ,spk_msg_get (MSG_IS_UNASSIGNED )); + + name =NULL ; +if ((type !=KT_SPKUP ) && (key >0 ) && (key <= num_key_names)) { +synth_printf ("%s\n" , +spk_msg_get (MSG_KEYNAMES_START + key -1 ));return 1 ; } - p_keys = key_data + key_offsets[func]; -for (n =0 ; p_keys[n]; n++) { - val = p_keys[n]; -if (n >0 ) -synth_printf ("%s " ,spk_msg_get (MSG_DISJUNCTION )); -say_key (val); +for (i =0 ; funcvals[i] !=0 && !name; i++) { +if (ch == funcvals[i]) + name =spk_msg_get (MSG_FUNCNAMES_START + i); + } +if (!name) +return -1 ; + kp = spk_our_keys[key] +1 ; +for (i =0 ; i < nstates; i++) { +if (ch == kp[i]) +break ; } + key += (state_tbl[i] <<8 ); +say_key (key); +synth_printf (spk_msg_get (MSG_KEYDESC ), name); +synth_printf ("\n" );return 1 ; } --2.11.0
--
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/20170303155557.GA23744%40arushi-HP-Pavilion-Notebook.
For more options, visit https://groups.google.com/d/optout.
Quoted 5 lines · Julia Lawall
On Fri, 3 Mar 2017, Arushi Singhal wrote:
Quoted 8 lines
Quoted 4 lines
fixed checkpatch.pl warning: else is not generally useful after a break or return.
Removed the else without affecting the logic.
Dead code is also eliminated.The chhange is not correct. There is a big chain of if/else if. The if (type ==
KT_LATIN) can reach the code at the end of the file.
If there is else and all if/else have return statement so then the code will not reach at the end.
Thanks
Aruhsi
Quoted 102 lines
\
juliaQuoted 4 lines
Signed-off-by Arushi Singhal <[email protected] <javascript:>>---
drivers/staging/speakup/keyhelp.c | 53++++++++++++++-------------------------
Review
Quoted 3 lines
1 file changed, 19 insertions(+), 34 deletions(-)(quoted diff) +0
-0
b/drivers/staging/speakup/keyhelp.cdrivers/staging/speakup/keyhelp.c int spk_handle_help(struct vc_data *vc, u_char
Quoted 4 lines
index
4e6e5daba50c..ad3efded37c1100644drivers/staging/speakup/keyhelp.c +0
-0@@ -176,43 +176,28 @@ int spk_handle_help(struct vc_data *vc, u_chartype,
u_charch,u_shortkey)drivers/staging/speakup/keyhelp.c int spk_handle_help(struct vc_data *vc, u_char · line 177
Quoted 2 lines
drivers/staging/speakup/keyhelp.c +0
-0synth_printf ("%s\n" ,spk_msg_get (MSG_HELP_INFO ));build_key_data ();/* rebuild each time in case new mapping */
drivers/staging/speakup/keyhelp.c int spk_handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key)
Quoted 4 lines
drivers/staging/speakup/keyhelp.c +0
-3return 1 ; - }else { - name =NULL ; - if ((type != KT_SPKUP) && (key > 0) && (key <=
num_key_names)) {drivers/staging/speakup/keyhelp.c int spk_handle_help(struct vc_data *vc, u_char · line 183
Quoted 2 lines
drivers/staging/speakup/keyhelp.c +0
-2- synth_printf("%s\n", - spk_msg_get(MSG_KEYNAMES_START +key - 1));
drivers/staging/speakup/keyhelp.c int spk_handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key)
Quoted 5 lines
drivers/staging/speakup/keyhelp.c +0
-5-return 1 ; - } -for (i =0 ; funcvals[i] !=0 && !name; i++) { -if (ch == funcvals[i]) - name = spk_msg_get(MSG_FUNCNAMES_START+ i);
Quoted 12 lines
drivers/staging/speakup/keyhelp.c +0
-12- } -if (!name) -return -1 ; - kp = spk_our_keys[key] +1 ; -for (i =0 ; i < nstates; i++) { -if (ch == kp[i]) -break ; - } - key += (state_tbl[i] <<8 ); -say_key (key); -synth_printf (spk_msg_get (MSG_KEYDESC ), name); -synth_printf ("\n" );drivers/staging/speakup/keyhelp.c int spk_handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key)
Quoted 10 lines
drivers/staging/speakup/keyhelp.c +3
-6-return 1 ; } - name =spk_msg_get (MSG_FUNCNAMES_START + cur_item); - func = funcvals[cur_item]; -synth_printf ("%s" , name); -if (key_offsets[func] ==0 ) { -synth_printf (" %s\n" ,spk_msg_get (MSG_IS_UNASSIGNED )); + + name =NULL ; +if ((type !=KT_SPKUP ) && (key >0 ) && (key <= num_key_names)){
drivers/staging/speakup/keyhelp.c int spk_handle_help(struct vc_data *vc, u_char · line 184
Quoted 2 lines
drivers/staging/speakup/keyhelp.c +2
-0+ synth_printf("%s\n", + spk_msg_get(MSG_KEYNAMES_START + key -1));
drivers/staging/speakup/keyhelp.c int spk_handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key)
Quoted 7 lines
drivers/staging/speakup/keyhelp.c +0
-5return 1 ; } - p_keys = key_data + key_offsets[func]; -for (n =0 ; p_keys[n]; n++) { - val = p_keys[n]; -if (n >0 ) - synth_printf("%s ",
spk_msg_get(MSG_DISJUNCTION));Quoted 23 lines
drivers/staging/speakup/keyhelp.c +14
-1-say_key (val); +for (i =0 ; funcvals[i] !=0 && !name; i++) { +if (ch == funcvals[i]) + name =spk_msg_get (MSG_FUNCNAMES_START + i); + } +if (!name) +return -1 ; + kp = spk_our_keys[key] +1 ; +for (i =0 ; i < nstates; i++) { +if (ch == kp[i]) +break ; } + key += (state_tbl[i] <<8 ); +say_key (key); +synth_printf (spk_msg_get (MSG_KEYDESC ), name); +synth_printf ("\n" );return 1 ; }Signature · 4 lines
2.11.0 -- You received this message because you are subscribed to the GoogleGroups "outreachy-kernel" group.
Quoted 1 line
To unsubscribe from this group and stop receiving emails from it, send
an email to [email protected] <javascript:>.
Quoted 1 line
To post to this group, send email to [email protected]
<javascript:>.
Quoted 1 line
To view this discussion on the web visit
Quoted 2 lines
For more options, visit https://groups.google.com/d/optout.
Quoted 13 lines · Arushi Singhal
On Friday, March 3, 2017 at 9:33:22 PM UTC+5:30, Julia Lawall wrote:
On Fri, 3 Mar 2017, Arushi Singhal wrote:
> fixed checkpatch.pl warning: else is not generally useful after a break
> or return.
> Removed the else without affecting the logic.
> Dead code is also eliminated.
Quoted 6 lines
The chhange is not correct. There is a big chain of if/else if. The if
(type ==KT_LATIN) can reach the code at the end of the file.If there is else and all if/else have return statement so then the code will not reach at the end.
The first one does not end in a return.
julia
Quoted 117 lines
Thanks
Aruhsi\ julia > > Signed-off-by: Arushi Singhal <[email protected]> > --- > drivers/staging/speakup/keyhelp.c | 53 ++++++++++++++------------------------- > 1 file changed, 19 insertions(+), 34 deletions(-) > > diff --git a/drivers/staging/speakup/keyhelp.c b/drivers/staging/speakup/keyhelp.c > index 4e6e5daba50c..ad3efded37c1 100644 > --- a/drivers/staging/speakup/keyhelp.c > +++ b/drivers/staging/speakup/keyhelp.c > @@ -176,43 +176,28 @@ 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", > - spk_msg_get(MSG_KEYNAMES_START + key - 1)); > - return 1; > - } > - for (i = 0; funcvals[i] != 0 && !name; i++) { > - if (ch == funcvals[i]) > - name = spk_msg_get(MSG_FUNCNAMES_START + i); > - } > - if (!name) > - return -1; > - kp = spk_our_keys[key] + 1; > - for (i = 0; i < nstates; i++) { > - if (ch == kp[i]) > - break; > - } > - key += (state_tbl[i] << 8); > - say_key(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); > - if (key_offsets[func] == 0) { > - synth_printf(" %s\n", spk_msg_get(MSG_IS_UNASSIGNED)); > + > + name = NULL; > + if ((type != KT_SPKUP) && (key > 0) && (key <= num_key_names)) { > + synth_printf("%s\n", > + spk_msg_get(MSG_KEYNAMES_START + key - 1)); > return 1; > } > - p_keys = key_data + key_offsets[func]; > - for (n = 0; p_keys[n]; n++) { > - val = p_keys[n]; > - if (n > 0) > - synth_printf("%s ", spk_msg_get(MSG_DISJUNCTION)); > - say_key(val); > + for (i = 0; funcvals[i] != 0 && !name; i++) { > + if (ch == funcvals[i]) > + name = spk_msg_get(MSG_FUNCNAMES_START + i); > + } > + if (!name) > + return -1; > + kp = spk_our_keys[key] + 1; > + for (i = 0; i < nstates; i++) { > + if (ch == kp[i]) > + break; > } > + key += (state_tbl[i] << 8); > + say_key(key); > + synth_printf(spk_msg_get(MSG_KEYDESC), name); > + synth_printf("\n"); > return 1; > } > -- > 2.11.0 > > -- > 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 visithttps://groups.google.com/d/msgid/outreachy-kernel/20170303155557.GA23744%4 0arushi-HP-Pavilion-Notebook. > For more options, visit https://groups.google.com/d/optout. >--
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 visithttps://groups.google.com/d/msgid/outreachy-kernel/cc06f004-d16e-4e67-86fb- 5e1b099c811a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Quoted 22 lines · Julia Lawall
Quoted 17 lines · Arushi Singhal
On Friday, March 3, 2017 at 9:33:22 PM UTC+5:30, Julia Lawall wrote:
On Fri, 3 Mar 2017, Arushi Singhal wrote:
> fixed checkpatch.pl warning: else is not generally useful after a break
> or return.
> Removed the else without affecting the logic.
> Dead code is also eliminated.The chhange is not correct. There is a big chain of if/else if.
The if
(type ==KT_LATIN) can reach the code at the end of the file.
Quoted 6 lines
Quoted 1 line
If there is else and all if/else have return statement so then the code
will
Quoted 1 line
not reach at the end.
The first one does not end in a return.
Thanks I got my mistake.
Regards
Arushi
Quoted 125 lines
julia
Quoted 94 lines
Thanks
Aruhsi\ julia > > Signed-off-by: Arushi Singhal <[email protected]> > --- > drivers/staging/speakup/keyhelp.c | 53 ++++++++++++++------------------------- > 1 file changed, 19 insertions(+), 34 deletions(-) > > diff --git a/drivers/staging/speakup/keyhelp.c b/drivers/staging/speakup/keyhelp.c > index 4e6e5daba50c..ad3efded37c1 100644 > --- a/drivers/staging/speakup/keyhelp.c > +++ b/drivers/staging/speakup/keyhelp.c > @@ -176,43 +176,28 @@ 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", > - spk_msg_get(MSG_KEYNAMES_START + key - 1)); > - return 1; > - } > - for (i = 0; funcvals[i] != 0 && !name; i++) { > - if (ch == funcvals[i]) > - name = spk_msg_get(MSG_FUNCNAMES_START + i); > - } > - if (!name) > - return -1; > - kp = spk_our_keys[key] + 1; > - for (i = 0; i < nstates; i++) { > - if (ch == kp[i]) > - break; > - } > - key += (state_tbl[i] << 8); > - say_key(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); > - if (key_offsets[func] == 0) { > - synth_printf(" %s\n", spk_msg_get(MSG_IS_UNASSIGNED)); > + > + name = NULL; > + if ((type != KT_SPKUP) && (key > 0) && (key <= num_key_names)) { > + synth_printf("%s\n", > + spk_msg_get(MSG_KEYNAMES_START + key - 1)); > return 1; > } > - p_keys = key_data + key_offsets[func]; > - for (n = 0; p_keys[n]; n++) { > - val = p_keys[n]; > - if (n > 0) > - synth_printf("%s ", spk_msg_get(MSG_DISJUNCTION)); > - say_key(val); > + for (i = 0; funcvals[i] != 0 && !name; i++) { > + if (ch == funcvals[i]) > + name = spk_msg_get(MSG_FUNCNAMES_START + i); > + } > + if (!name) > + return -1; > + kp = spk_our_keys[key] + 1; > + for (i = 0; i < nstates; i++) { > + if (ch == kp[i]) > + break; > } > + key += (state_tbl[i] << 8); > + say_key(key); > + synth_printf(spk_msg_get(MSG_KEYDESC), name); > + synth_printf("\n"); > return 1; > } > -- > 2.11.0 >Quoted 8 lines
> -- > 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 visithttps://groups.google.com/d/msgid/outreachy-kernel/20170303155557.GA23744%4
Quoted 6 lines
0arushi-HP-Pavilion-Notebook.
> For more options, visit https://groups.google.com/d/optout.
>Signature · 1 line
You received this message because you are subscribed to the GoogleGroups
Quoted 2 lines
"outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, sendan
Quoted 2 lines
email to [email protected] <javascript:>. To post to this group, send email to [email protected]
<javascript:>.
Quoted 1 line
To view this discussion on the web visithttps://
groups.google.com/d/msgid/outreachy-kernel/cc06f004-d16e-4e67-86fb-
Quoted 4 lines
5e1b099c811a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Quoted 4 lines · Julia Lawall
On Fri, 3 Mar 2017, Arushi Singhal wrote:
Quoted 8 lines
Quoted 4 lines
fixed checkpatch.pl warning: else is not generally useful after a break or return.
Removed the else without affecting the logic.
Dead code is also eliminated.The chhange is not correct. There is a big chain of if/else if. The if (type ==
KT_LATIN) can reach the code at the end of the file.
Yeah. And KT_CUR as well.
regards,
dan carpenter
kbuild test robot
build boturl: https://github.com/0day-ci/linux/commits/Arushi-Singhal/staging-speakup-else-is-not-generally-useful-after-a-break-or-return/20170306-072009 config: openrisc-allmodconfig (attached as .config)…
Hi Arushi,
[auto build test WARNING on staging/staging-testing]
[cannot apply to v4.11-rc1 next-20170306]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Arushi-Singhal/staging-speakup-else-is-not-generally-useful-after-a-break-or-return/20170306-072009
config: openrisc-allmodconfig (attached as .config)
compiler: or32-linux-gcc (GCC) 4.5.1-or32-1.0rc1
reproduce:
wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=openrisc
All warnings (new ones prefixed by >>):
drivers/staging/speakup/keyhelp.c: In function 'spk_handle_help':
>> drivers/staging/speakup/keyhelp.c:146:19: warning: unused variable 'val' >> drivers/staging/speakup/keyhelp.c:146:11: warning: unused variable 'p_keys' >> drivers/staging/speakup/keyhelp.c:145:9: warning: unused variable 'func' >> drivers/staging/speakup/keyhelp.c:143:9: warning: unused variable 'n'
vim +/val +146 drivers/staging/speakup/keyhelp.c
c6e3fd22c William Hubbs 2010-10-07 137 }
c6e3fd22c William Hubbs 2010-10-07 138 return 0;
c6e3fd22c William Hubbs 2010-10-07 139 }
c6e3fd22c William Hubbs 2010-10-07 140
ca2beaf84 Samuel Thibault 2013-01-02 141 int spk_handle_help(struct vc_data *vc, u_char type, u_char ch, u_short key)
c6e3fd22c William Hubbs 2010-10-07 142 {
c6e3fd22c William Hubbs 2010-10-07 @143 int i, n;
c6e3fd22c William Hubbs 2010-10-07 144 char *name;
c6e3fd22c William Hubbs 2010-10-07 @145 u_char func, *kp;
c6e3fd22c William Hubbs 2010-10-07 @146 u_short *p_keys, val;
8e69a8110 Domagoj Trsan 2014-09-09 147
c6e3fd22c William Hubbs 2010-10-07 148 if (letter_offsets[0] == -1)
c6e3fd22c William Hubbs 2010-10-07 149 help_init();:::::: The code at line 146 was first introduced by commit
:::::: c6e3fd22cd538365bfeb82997d5b89562e077d42 Staging: add speakup to the staging directory
:::::: TO: William Hubbs <[email protected]> :::::: CC: Greg Kroah-Hartman <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation