Re: [Outreachy kernel] [PATCH] staging: speakup: else is not generally useful after a break or return
From: Julia Lawall
Date: Fri Mar 03 2017 - 11:56:33 EST
On Fri, 3 Mar 2017, Arushi Singhal wrote:
>
>
> 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.
>
> 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
> ÂThanks
> Aruhsi
> \
> julia
>
> >
> > Signed-off-by: Arushi Singhal <arushising...@xxxxxxxxx>
> > ---
> > Â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 outreachy-kern...@xxxxxxxxxxxxxxxxx
> > To post to this group, send email to
> outreach...@xxxxxxxxxxxxxxxxx
> > 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 outreachy-kernel+unsubscribe@xxxxxxxxxxxxxxxxx
> To post to this group, send email to outreachy-kernel@xxxxxxxxxxxxxxxxx
> 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.
>
>