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


Groups > linux.kernel > #1659506

Re: [RFC] clang: 'unused-function' warning on static inline functions

From Arnd Bergmann <arnd@arndb.de>
Newsgroups linux.kernel
Subject Re: [RFC] clang: 'unused-function' warning on static inline functions
Date 2017-06-07 10:20 +0200
Message-ID <tPEm5-44h-5@gated-at.bofh.it> (permalink)
References (1 earlier) <tNlGW-3j8-3@gated-at.bofh.it> <tPkGJ-82Q-5@gated-at.bofh.it> <tPpGq-2N6-17@gated-at.bofh.it> <tPud4-5O1-17@gated-at.bofh.it> <tPud4-5O1-31@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Tue, Jun 6, 2017 at 11:29 PM, Jens Axboe <axboe@kernel.dk> wrote:
> On 06/06/2017 03:23 PM, Matthias Kaehlcke wrote:
>> 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 <arnd@arndb.de> 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.
>
> One example is the patch sent for CFQ, which has macros for define
> functions for setting/clearing bits on the queue:
>
> #define CFQ_CFQQ_FNS(name)
>
> for one bit, we never clear the bit after we set it, we only set it and
> later test for it. Hence the clear variant of that function is unused.
>
> Now I get a warning. The fix to that would be to define a new variant of
> CFQ_CFQQ_FNS() that only declares the exact one I need for the version
> that is never cleared.
>
> Or the fix is to just ignore the bogus warning on an unused inline.  I
> greatly prefer the latter.
>
> The counter example is this one:
>
> http://git.kernel.dk/cgit/linux-block/commit/?id=03ea8ad78cfb2910862c8dfcd2a627fc04097db2
>
> where it is truly just dead junk. I'd rather just leave the dead junk
> than have pointless warnings, if I have to choose one of the two
> outcomes.

This is a relatively rare case, with an inline function defined by a macro, and
I sent a patch for a similar one in 1f318a8bafcf ("modules: mark
__inittest/__exittest
as __maybe_unused"). I think this is a case where the __maybe_unused
annotation is reasonable, though for the other instances of unused inline
functions in .c files, there is often a better way: typically the only caller
of a function is inside of an #ifdef and moving the inline function definition
into the same #ifdef block makes it clearer what is going on.

      Arnd

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[RFC] clang: 'unused-function' warning on static inline functions Matthias Kaehlcke <mka@chromium.org> - 2017-05-30 20:20 +0200
  Re: [RFC] clang: 'unused-function' warning on static inline functions Matthias Kaehlcke <mka@chromium.org> - 2017-06-01 02:00 +0200
    Re: [RFC] clang: 'unused-function' warning on static inline functions Arnd Bergmann <arnd@arndb.de> - 2017-06-06 13:20 +0200
      Re: [RFC] clang: 'unused-function' warning on static inline functions Linus Torvalds <torvalds@linux-foundation.org> - 2017-06-06 18:40 +0200
        Re: [RFC] clang: 'unused-function' warning on static inline functions Matthias Kaehlcke <mka@chromium.org> - 2017-06-06 23:30 +0200
          Re: [RFC] clang: 'unused-function' warning on static inline functions Linus Torvalds <torvalds@linux-foundation.org> - 2017-06-06 23:30 +0200
            Re: [RFC] clang: 'unused-function' warning on static inline functions Matthias Kaehlcke <mka@chromium.org> - 2017-06-07 02:30 +0200
              Re: [RFC] clang: 'unused-function' warning on static inline  functions David Rientjes <rientjes@google.com> - 2017-06-07 08:00 +0200
            Re: [RFC] clang: 'unused-function' warning on static inline functions Arnd Bergmann <arnd@arndb.de> - 2017-06-07 21:50 +0200
              Re: [RFC] clang: 'unused-function' warning on static inline functions Linus Torvalds <torvalds@linux-foundation.org> - 2017-06-07 22:40 +0200
                Re: [RFC] clang: 'unused-function' warning on static inline  functions Steven Rostedt <rostedt@goodmis.org> - 2017-06-07 23:30 +0200
              Re: [RFC] clang: 'unused-function' warning on static inline functions Arnd Bergmann <arnd@arndb.de> - 2017-06-08 11:00 +0200
          Re: [RFC] clang: 'unused-function' warning on static inline functions Jens Axboe <axboe@kernel.dk> - 2017-06-06 23:30 +0200
            Re: [RFC] clang: 'unused-function' warning on static inline functions Arnd Bergmann <arnd@arndb.de> - 2017-06-07 10:20 +0200
              Re: [RFC] clang: 'unused-function' warning on static inline  functions Steven Rostedt <rostedt@goodmis.org> - 2017-06-07 15:00 +0200
                Re: [RFC] clang: 'unused-function' warning on static inline functions Arnd Bergmann <arnd@arndb.de> - 2017-06-07 15:20 +0200

csiph-web