From mboxrd@z Thu Jan 1 00:00:00 1970 X-GM-THRID: 6394100888766513152 X-Received: by 10.46.7.10 with SMTP id 10mr2197672ljh.1.1488800489826; Mon, 06 Mar 2017 03:41:29 -0800 (PST) X-BeenThere: outreachy-kernel@googlegroups.com Received: by 10.25.72.196 with SMTP id v187ls321823lfa.52.gmail; Mon, 06 Mar 2017 03:41:28 -0800 (PST) X-Received: by 10.46.78.9 with SMTP id c9mr2253009ljb.20.1488800488593; Mon, 06 Mar 2017 03:41:28 -0800 (PST) Return-Path: Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr. [192.134.164.104]) by gmr-mx.google.com with ESMTPS id h198si1039246wmg.1.2017.03.06.03.41.28 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Mar 2017 03:41:28 -0800 (PST) Received-SPF: neutral (google.com: 192.134.164.104 is neither permitted nor denied by domain of julia.lawall@lip6.fr) client-ip=192.134.164.104; Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 192.134.164.104 is neither permitted nor denied by domain of julia.lawall@lip6.fr) smtp.mailfrom=julia.lawall@lip6.fr X-IronPort-AV: E=Sophos;i="5.35,253,1484002800"; d="scan'208";a="215716987" Received: from vaio-julia.rsr.lip6.fr ([132.227.76.33]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 06 Mar 2017 12:41:27 +0100 Date: Mon, 6 Mar 2017 12:41:15 +0100 (CET) From: Julia Lawall X-X-Sender: jll@hadrien To: Tamara Diaconita cc: outreachy-kernel , w.d.hubbs@gmail.com, chris@the-brannons.com, kirk@reisers.ca, samuel.thibault@ens-lyon.org, gregkh@linuxfoundation.org, diaconita.tamara@gmail.com Subject: Re: [Outreachy kernel] Re: [PATCH 3/3] staging:speakup:keyhelp.c: Remove unnecessary else In-Reply-To: Message-ID: References: <20170305193701.20390-1-diaconita.tamara@gmail.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: multipart/mixed; BOUNDARY="8323329-634729139-1488800476=:3078" 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-634729139-1488800476=:3078 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT On Mon, 6 Mar 2017, Tamara Diaconita wrote: > Did I do something wrong? In this case I see that the if statement finish > with a return. The structure is complex is this case. For a simpler example, suppose you have if (x) print "hello" else if (y) return; else print "goodbye" The original program prints hello or goodbye (or nothing), but not both. If you remove the final else, it may print hello goodbye. The structure of your code is like this. The KT_LATIN and KT_CUR cases might not return. Chckpatch just looks at very local structure. It doesn't follow the entire control flow, so it can have false positives like this. julia > > duminică, 5 martie 2017, 21:37:05 UTC+2, Tamara Diaconita a scris: > Fixed the checkpath.pl WARNING: > Else is not generally useful after a break return. > > Deleted the 'else' structure. > Deleted extra tabs which remained after the 'else' structure was > removed. > > Signed-off-by: Tamara Diaconita > --- >  drivers/staging/speakup/keyhelp.c | 44 > +++++++++++++++++++-------------------- >  1 file changed, 22 insertions(+), 22 deletions(-) > > diff --git a/drivers/staging/speakup/keyhelp.c > b/drivers/staging/speakup/keyhelp.c > index 2ef7370..0e0efc46 100644 > --- a/drivers/staging/speakup/keyhelp.c > +++ b/drivers/staging/speakup/keyhelp.c > @@ -176,30 +176,30 @@ 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"); > +        } > +        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); > -- > 2.9.3 > > -- > 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/ae948b29-c3d0-40d3-94a0- > 31df90500e76%40googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > > --8323329-634729139-1488800476=:3078--