From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752047AbdCCQz7 (ORCPT ); Fri, 3 Mar 2017 11:55:59 -0500 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:11645 "EHLO mail3-relais-sop.national.inria.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751660AbdCCQzY (ORCPT ); Fri, 3 Mar 2017 11:55:24 -0500 X-IronPort-AV: E=Sophos;i="5.35,237,1484002800"; d="scan'208";a="215493420" Date: Fri, 3 Mar 2017 17:54:02 +0100 (CET) From: Julia Lawall X-X-Sender: jll@hadrien To: Arushi Singhal cc: outreachy-kernel , w.d.hubbs@gmail.com, chris@the-brannons.com, kirk@reisers.ca, samuel.thibault@ens-lyon.org, gregkh@linuxfoundation.org, speakup@linux-speakup.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: Re: [Outreachy kernel] [PATCH] staging: speakup: else is not generally useful after a break or return In-Reply-To: Message-ID: References: <20170303155557.GA23744@arushi-HP-Pavilion-Notebook> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: multipart/mixed; BOUNDARY="8323329-2105888337-1488560043=:3490" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323329-2105888337-1488560043=:3490 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT 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 > > --- > >  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...@googlegroups.com. > > To post to this group, send email to > outreach...@googlegroups.com. > > 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@googlegroups.com. > To post to this group, send email to outreachy-kernel@googlegroups.com. > 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. > > --8323329-2105888337-1488560043=:3490--