From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753243AbdK1Spk (ORCPT ); Tue, 28 Nov 2017 13:45:40 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:35190 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751701AbdK1Spj (ORCPT ); Tue, 28 Nov 2017 13:45:39 -0500 Date: Tue, 28 Nov 2017 19:45:23 +0100 (CET) From: Thomas Gleixner To: "Gustavo A. R. Silva" cc: Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, LKML , Kees Cook , Linus Torvalds Subject: Re: [PATCH] x86/syscalls: Mark expected switch fall-throughs In-Reply-To: Message-ID: References: <20171127235253.GA20384@embeddedor.com> <20171128120512.Horde.1mz61Up1PsNtyHbrjWmK8L7@gator4166.hostgator.com> <20171128122235.Horde.vFP-9ZfAP0f9BFNePB8Z8xi@gator4166.hostgator.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 28 Nov 2017, Thomas Gleixner wrote: +CC Linus. > On Tue, 28 Nov 2017, Thomas Gleixner wrote: > > > On Tue, 28 Nov 2017, Gustavo A. R. Silva wrote: > > > Quoting Thomas Gleixner : > > > > > 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. > > > > It's not about ugly. It's about _USEFULL_. > > > > The comments are ugly AND completely useless for the compiler and they are > > going to be malformatted so checker tools can't differentiate the false > > positives. > > > > The macro, in which more or less ugly form written, is both documentation > > and helps the compiler NOT to emit the same crap over and over. > > Just checked and GCC really supports analyzing the comment to some extent. > > But just look at > > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77817 > > " It is not really possible. __attribute__((fallthrough)) has precise > rules on where it can appear, while /* FALLTHRU */ comments, being > comments, can appear anywhere. Especially with -Wimplicit-fallthrough=1 > when all comments are considered fallthru comments... " > > I have no idea who came up with that brilliant idea of parsing comments in > the code. It's so simple to make this parser completely fail that it's not > even funny anymore. > > I don't care what other people prefer. The code base I'm responsible for > gets either proper annotations or nothing. And in fact we want ONE solution for the whole kernel. And comments are obviously the wrong one. Thanks, tglx