From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751494AbdFFVX6 (ORCPT ); Tue, 6 Jun 2017 17:23:58 -0400 Received: from mail-pf0-f173.google.com ([209.85.192.173]:36803 "EHLO mail-pf0-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751247AbdFFVX4 (ORCPT ); Tue, 6 Jun 2017 17:23:56 -0400 Date: Tue, 6 Jun 2017 14:23:54 -0700 From: Matthias Kaehlcke To: Linus Torvalds Cc: Arnd Bergmann , Linux Kernel Mailing List , Andrew Morton , Greg Kroah-Hartman , Ingo Molnar , Thomas Gleixner , Christoph Hellwig , Jens Axboe , Steven Rostedt , David Rientjes , Douglas Anderson , Guenter Roeck , Mark Brown , David Miller Subject: Re: [RFC] clang: 'unused-function' warning on static inline functions Message-ID: <20170606212354.GZ141096@google.com> References: <20170530181306.GV141096@google.com> <20170531235519.GX141096@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org El Tue, Jun 06, 2017 at 09:32:35AM -0700 Linus Torvalds ha dit: > On Tue, Jun 6, 2017 at 4:16 AM, Arnd Bergmann wrote: > > > > Those should all be fairly easy to address, I'd vote for leaving the > > warning enabled > > in clang, and possibly asking the gcc maintainers to add a similar feature for > > warning about it. > > Hell no. That warning is pointless shit. I tend to disagree, the warning is useful to detect truly unused static inline functions, which should be removed, rather than be carried around/maintained for often long periods of time. Also lets not forget that the kernel is somewhat special with its heavy use of #ifdefs , which leads to the larger number of false positives. At least for many other projects the warning makes perfect sense IMO. A switch to enable/disable it could be interesting. > The function is inlined. If it's not used, why the f*ck should you get > a warning? To detect dead code? > Just to add more pointless #ifdef'fery around a function that is > perhaps only used under certain circumstances? The vast majority of instances could be fixed by simply marking the function as __maybe_unused, which is already widely used in the kernel. I don't fully understand why adding the attribute to static inline functions (in .c files) is considered an offense, while it is a standard practice for non-inline function. Granted, unused static inline functions don't waste (binary) space, but doesn't the extra capability to detect dead code also have a value?