From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751383AbdJ1K5P (ORCPT ); Sat, 28 Oct 2017 06:57:15 -0400 Received: from canardo.mork.no ([148.122.252.1]:58041 "EHLO canardo.mork.no" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751115AbdJ1K5N (ORCPT ); Sat, 28 Oct 2017 06:57:13 -0400 From: =?utf-8?Q?Bj=C3=B8rn_Mork?= To: "Gustavo A. R. Silva" Cc: Johan Hovold , Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] USB: serial: io_edgeport: mark expected switch fall-throughs Organization: m References: <20171027203906.GA7054@embeddedor.com> Date: Sat, 28 Oct 2017 12:56:51 +0200 In-Reply-To: <20171027203906.GA7054@embeddedor.com> (Gustavo A. R. Silva's message of "Fri, 27 Oct 2017 15:39:06 -0500") Message-ID: <87k1zf4k24.fsf@miraculix.mork.no> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by nfs id v9SAvL5f015801 "Gustavo A. R. Silva" writes: > In preparation to enabling -Wimplicit-fallthrough, mark switch cases > where we are expecting to fall through. > > Notice that in this particular case I replaced "...drop on through" > comments with a proper "fall through" comment on its own line, which > is what GCC is expecting to find. Sounds to me like GCC is the wrong tool for this. But I would of course not mind if it was *just* the text. However, as your patch cleary shows, the simplified logic leads to real problems: > @@ -1819,8 +1819,8 @@ static void process_rcvd_data(struct edgeport_serial *edge_serial, > edge_serial->rxState = EXPECT_DATA; > break; > } > - /* Else, drop through */ > } > + /* fall through */ > case EXPECT_DATA: /* Expect data */ > if (bufferLength < edge_serial->rxBytesRemaining) { > rxLen = bufferLength; The original comment clearly marked a *conditional* fall through at the correct place. Your patch makes it appear as if there is an unconditional fall through here. There is not. The fallthrough only applies to one of a number of nested if blocks. There are no less than 3 break statements in the same case block. Not a big deal maybe, just as the lack of any "fall through" comment isn't a big deal in the first place. But this change is clearly making this code harder to read, and the change is therefore harmful IMHO. If you can't make -Wimplicit-fallthrough work without removing such precise fallthrough markings, then my proposal is to drop it and use some other tool. Bjørn