Received: by 10.223.164.202 with SMTP id h10csp3378596wrb; Tue, 28 Nov 2017 10:18:45 -0800 (PST) X-Google-Smtp-Source: AGs4zMbmjNNBbPdvmQYeHRX6Vy8USew0RdgeJLVfZcdoe/7wIuVI1Yn3oac3ieJJ3g2Q9OCWNRIk X-Received: by 10.98.196.77 with SMTP id y74mr51522pff.186.1511893125772; Tue, 28 Nov 2017 10:18:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511893125; cv=none; d=google.com; s=arc-20160816; b=Dh1nYlqFB6T7i2Ri8H0sONtVyS5uq7WKE7+fe+OfXwqKfz+rxhvs4mV10YPStQZeU1 mTS4T6dZM+Hon9PRAsUpJGSQLimKFcdemxTAryT23/nD6YsFolrM91v3JkFSHxzol5JT I2E511PQgm/UrxlOzz8qd9qrQeKGhNETLdkSO+KGBKHp8CIqIOBM4XCfijcvKVNKO9bc 8MIMe0DAw8+wq0wojvsEu4sa7F1Fiajlfs/DrRjUqLCRaZkQ8Twrmt0tgF/mTOz5ZUZY ZvATi2ko6FjYY/7/pN1VC1TNq8wm7e665AqcotII0gG6CBYWNaZ3MwVEI27rmaH+CIJm LC9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date :arc-authentication-results; bh=wqYUnBEZmxBZnowOnZY3cgMhVnsm6u1Vbi5mPIWxQCY=; b=FdeAXyT5J8WQWXIXMrJzK7uUZCN55seeDEGO03kX2eQoNzthkMHnGNhB6dFxHsqk6g TJLtGdRQLy1Q0TwG45S335SR4lmGkf3aji2YqT1Oez7ph6fi7Y3sOaiRpA6aqAZFnrnq n5ITmpx3Tsbe0vZWfVohe8YiCIm8P/R+8rqWdaSe5T4TumaFzcVbuF8uILFfwW1DN01h wN8lCT1UbUwmWMsRCkEXl8e5LvQK3KikG8U9W0Vc8YUFBdEKH/9czNWAFMEUrtkcO0aN AaaPPsCOoTyhcK/oJVtmDHycEEKEzuLNvwF6dR1ZVaIIFgXnhoqIU0b2PKgbxvwcfz7H /8yg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o128si27692863pfg.203.2017.11.28.10.18.33; Tue, 28 Nov 2017 10:18:45 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753441AbdK1SR4 (ORCPT + 78 others); Tue, 28 Nov 2017 13:17:56 -0500 Received: from Galois.linutronix.de ([146.0.238.70]:35017 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751932AbdK1SRx (ORCPT ); Tue, 28 Nov 2017 13:17:53 -0500 Received: from p4fea5f09.dip0.t-ipconnect.de ([79.234.95.9] helo=nanos) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1eJkQo-0004yR-4P; Tue, 28 Nov 2017 19:16:30 +0100 Date: Tue, 28 Nov 2017 19:17:37 +0100 (CET) From: Thomas Gleixner To: "Gustavo A. R. Silva" 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 In-Reply-To: Message-ID: References: <20171127235253.GA20384@embeddedor.com> <20171128120512.Horde.1mz61Up1PsNtyHbrjWmK8L7@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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. 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. Sure, but slapping a comment everywhere is just simpler than reading the documentation and make something useful and understandable. Thanks, tglx From 1585334479184006714@xxx Tue Nov 28 18:12:55 +0000 2017 X-GM-THRID: 1585265423856272058 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread