From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752945AbdK1SWh (ORCPT ); Tue, 28 Nov 2017 13:22:37 -0500 Received: from gateway36.websitewelcome.com ([192.185.193.12]:14105 "EHLO gateway36.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751781AbdK1SWg (ORCPT ); Tue, 28 Nov 2017 13:22:36 -0500 Date: Tue, 28 Nov 2017 12:22:35 -0600 Message-ID: <20171128122235.Horde.vFP-9ZfAP0f9BFNePB8Z8xi@gator4166.hostgator.com> From: "Gustavo A. R. Silva" To: Thomas Gleixner Cc: Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, linux-kernel@vger.kernel.org, Kees Cook Subject: Re: [PATCH] x86/syscalls: Mark expected switch fall-throughs References: <20171127235253.GA20384@embeddedor.com> <20171128120512.Horde.1mz61Up1PsNtyHbrjWmK8L7@gator4166.hostgator.com> In-Reply-To: User-Agent: Horde Application Framework 5 Content-Type: text/plain; charset=utf-8; format=flowed; DelSp=Yes MIME-Version: 1.0 Content-Disposition: inline X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 108.167.133.22 X-Source-L: Yes X-Exim-ID: 1eJkWh-002JNj-6V X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: gator4166.hostgator.com [108.167.133.22]:39076 X-Source-Auth: garsilva@embeddedor.com X-Email-Count: 8 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Quoting Thomas Gleixner : > On Tue, 28 Nov 2017, Thomas Gleixner wrote: >> On Tue, 28 Nov 2017, Gustavo A. R. Silva wrote: >> > Quoting Thomas Gleixner : >> > >> > > On Mon, 27 Nov 2017, Gustavo A. R. Silva wrote: >> > > >> > > > In preparation to enabling -Wimplicit-fallthrough, mark switch cases >> > > > where we are expecting to fall through. >> > > >> > > > case 0: >> > > > if (!n--) break; >> > > > *args++ = regs->bx; >> > > > + /* fall through */ >> > > >> > > And these gazillions of pointless comments help enabling of >> > > -Wimplicit-fallthrough in which way? >> > > >> > >> > The -Wimplicit-fallthrough option was added to GCC 7. We want to add that >> > option to the top-level Makefile so we can have the compiler help >> us not make >> > mistakes as missing "break"s or "continue"s. This also documents >> the intention >> > for humans and provides a way for analyzers to report issues or >> ignore False >> > Positives. >> > >> > So prior to adding such option to the Makefile, we have to >> properly add a code >> > comment wherever the code is intended to fall through. >> > >> > During the process of placing these comments I have identified actual bugs >> > (missing "break"s/"continue"s) in a variety of components in the >> kernel, so I >> > think this effort is valuable. Lastly, such a simple comment in >> the code can >> > save a person plenty of time during a code review. >> >> To be honest, such comments annoy me during a code review especially when >> the fallthrough is so obvious as in this case. There might be cases where >> its worth to document because it's non obvious, but documenting the obvious >> just for the sake of documenting it is just wrong. > I understand that and I agree that in this particular case it is just obvious. The thing is that if we want to benefit from having the compiler help us to spot these kind of issues before committing our code, we have to address every place in the whole code-base. > And _IF_ at all then you want a fixed macro for this and not a comment > which will be formatted as people see it fit. > > GCC supports: __attribute__ ((fallthrough)) which we can wrap into a macro, > e.g. falltrough() > > That'd be useful, but adding all these comments and then having to chase a > gazillion of warning instances to figure out whether there is a comment or > not is just backwards. > I have run into this before and people find what you suggest even uglier. Thanks -- Gustavo A. R. Silva