From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1424543AbdEYQOJ (ORCPT ); Thu, 25 May 2017 12:14:09 -0400 Received: from mail-pf0-f176.google.com ([209.85.192.176]:34496 "EHLO mail-pf0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758135AbdEYQOI (ORCPT ); Thu, 25 May 2017 12:14:08 -0400 Date: Thu, 25 May 2017 09:14:06 -0700 From: Matthias Kaehlcke To: Ingo Molnar Cc: David Rientjes , Andrew Morton , Christoph Lameter , Pekka Enberg , Joonsoo Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Douglas Anderson , Mark Brown , David Miller Subject: Re: [patch] compiler, clang: suppress warning for unused static inline functions Message-ID: <20170525161406.GT141096@google.com> References: <20170524212229.GR141096@google.com> <20170525055207.udcphnshuzl2gkps@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20170525055207.udcphnshuzl2gkps@gmail.com> 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 Thu, May 25, 2017 at 07:52:07AM +0200 Ingo Molnar ha dit: > > * Matthias Kaehlcke wrote: > > > El Wed, May 24, 2017 at 02:01:15PM -0700 David Rientjes ha dit: > > > > > GCC explicitly does not warn for unused static inline functions for > > > -Wunused-function. The manual states: > > > > > > Warn whenever a static function is declared but not defined or > > > a non-inline static function is unused. > > > > > > Clang does warn for static inline functions that are unused. > > > > > > It turns out that suppressing the warnings avoids potentially complex > > > #ifdef directives, which also reduces LOC. > > > > > > Supress the warning for clang. > > > > > > Signed-off-by: David Rientjes > > > --- > > > > As expressed earlier in other threads, I don't think gcc's behavior is > > preferable in this case. The warning on static inline functions (only > > in .c files) allows to detect truly unused code. About 50% of the > > warnings I have looked into so far fall into this category. > > > > In my opinion it is more valuable to detect dead code than not having > > a few more __maybe_unused attributes (there aren't really that many > > instances, at least with x86 and arm64 defconfig). In most cases it is > > not necessary to use #ifdef, it is an option which is preferred by > > some maintainers. The reduced LOC is arguable, since dectecting dead > > code allows to remove it. > > Static inline functions in headers are often not dead code. Sure, there is no intention to delete these and clang doesn't raise warnings about unused static inline functions in headers. From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f198.google.com (mail-pf0-f198.google.com [209.85.192.198]) by kanga.kvack.org (Postfix) with ESMTP id 9F8316B0279 for ; Thu, 25 May 2017 12:14:08 -0400 (EDT) Received: by mail-pf0-f198.google.com with SMTP id m5so234788093pfc.1 for ; Thu, 25 May 2017 09:14:08 -0700 (PDT) Received: from mail-pf0-x232.google.com (mail-pf0-x232.google.com. [2607:f8b0:400e:c00::232]) by mx.google.com with ESMTPS id a8si28278219plt.238.2017.05.25.09.14.07 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 May 2017 09:14:07 -0700 (PDT) Received: by mail-pf0-x232.google.com with SMTP id m17so171520784pfg.3 for ; Thu, 25 May 2017 09:14:07 -0700 (PDT) Date: Thu, 25 May 2017 09:14:06 -0700 From: Matthias Kaehlcke Subject: Re: [patch] compiler, clang: suppress warning for unused static inline functions Message-ID: <20170525161406.GT141096@google.com> References: <20170524212229.GR141096@google.com> <20170525055207.udcphnshuzl2gkps@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20170525055207.udcphnshuzl2gkps@gmail.com> Sender: owner-linux-mm@kvack.org List-ID: To: Ingo Molnar Cc: David Rientjes , Andrew Morton , Christoph Lameter , Pekka Enberg , Joonsoo Kim , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Douglas Anderson , Mark Brown , David Miller El Thu, May 25, 2017 at 07:52:07AM +0200 Ingo Molnar ha dit: > > * Matthias Kaehlcke wrote: > > > El Wed, May 24, 2017 at 02:01:15PM -0700 David Rientjes ha dit: > > > > > GCC explicitly does not warn for unused static inline functions for > > > -Wunused-function. The manual states: > > > > > > Warn whenever a static function is declared but not defined or > > > a non-inline static function is unused. > > > > > > Clang does warn for static inline functions that are unused. > > > > > > It turns out that suppressing the warnings avoids potentially complex > > > #ifdef directives, which also reduces LOC. > > > > > > Supress the warning for clang. > > > > > > Signed-off-by: David Rientjes > > > --- > > > > As expressed earlier in other threads, I don't think gcc's behavior is > > preferable in this case. The warning on static inline functions (only > > in .c files) allows to detect truly unused code. About 50% of the > > warnings I have looked into so far fall into this category. > > > > In my opinion it is more valuable to detect dead code than not having > > a few more __maybe_unused attributes (there aren't really that many > > instances, at least with x86 and arm64 defconfig). In most cases it is > > not necessary to use #ifdef, it is an option which is preferred by > > some maintainers. The reduced LOC is arguable, since dectecting dead > > code allows to remove it. > > Static inline functions in headers are often not dead code. Sure, there is no intention to delete these and clang doesn't raise warnings about unused static inline functions in headers. -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org