Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1650198 > unrolled thread

Re: [patch] compiler, clang: suppress warning for unused static inline functions

Started byIngo Molnar <mingo@kernel.org>
First post2017-05-25 08:00 +0200
Last post2017-05-25 20:00 +0200
Articles 4 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [patch] compiler, clang: suppress warning for unused static  inline functions Ingo Molnar <mingo@kernel.org> - 2017-05-25 08:00 +0200
    Re: [patch] compiler, clang: suppress warning for unused static  inline functions Matthias Kaehlcke <mka@chromium.org> - 2017-05-25 18:20 +0200
      Re: [patch] compiler, clang: suppress warning for unused static  inline functions Joe Perches <joe@perches.com> - 2017-05-25 18:50 +0200
        Re: [patch] compiler, clang: suppress warning for unused static  inline functions Matthias Kaehlcke <mka@chromium.org> - 2017-05-25 20:00 +0200

#1650198 — Re: [patch] compiler, clang: suppress warning for unused static inline functions

FromIngo Molnar <mingo@kernel.org>
Date2017-05-25 08:00 +0200
SubjectRe: [patch] compiler, clang: suppress warning for unused static inline functions
Message-ID<tKTYt-4c9-7@gated-at.bofh.it>
* Matthias Kaehlcke <mka@chromium.org> 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 <rientjes@google.com>
> > ---
> 
> 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.

Thanks,

	Ingo

[toc] | [next] | [standalone]


#1650630

FromMatthias Kaehlcke <mka@chromium.org>
Date2017-05-25 18:20 +0200
Message-ID<tL3Et-1ZE-13@gated-at.bofh.it>
In reply to#1650198
El Thu, May 25, 2017 at 07:52:07AM +0200 Ingo Molnar ha dit:

> 
> * Matthias Kaehlcke <mka@chromium.org> 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 <rientjes@google.com>
> > > ---
> > 
> > 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.

[toc] | [prev] | [next] | [standalone]


#1650642

FromJoe Perches <joe@perches.com>
Date2017-05-25 18:50 +0200
Message-ID<tL47w-29T-9@gated-at.bofh.it>
In reply to#1650630
On Thu, 2017-05-25 at 09:14 -0700, Matthias Kaehlcke wrote:
> clang doesn't raise
> warnings about unused static inline functions in headers.

Is any "#include" file a "header" to clang or only "*.h" files?

For instance:

The kernel has ~500 .c files that other .c files #include.
Are unused inline functions in those .c files reported?

[toc] | [prev] | [next] | [standalone]


#1650710

FromMatthias Kaehlcke <mka@chromium.org>
Date2017-05-25 20:00 +0200
Message-ID<tL5df-2O0-3@gated-at.bofh.it>
In reply to#1650642
Hi Joe,

El Thu, May 25, 2017 at 09:48:53AM -0700 Joe Perches ha dit:

> On Thu, 2017-05-25 at 09:14 -0700, Matthias Kaehlcke wrote:
> > clang doesn't raise
> > warnings about unused static inline functions in headers.
> 
> Is any "#include" file a "header" to clang or only "*.h" files?
> 
> For instance:
> 
> The kernel has ~500 .c files that other .c files #include.
> Are unused inline functions in those .c files reported?

Any "#include" file is a "header" to clang, no warnings are generated
for unused inline functions in included .c files.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web