All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masahiro Yamada <masahiroy@kernel.org>
To: Nathan Chancellor <nathan@kernel.org>
Cc: Steven Rostedt <rostedt@goodmis.org>,
	kernel test robot <lkp@intel.com>,
	chongjiapeng <jiapeng.chong@linux.alibaba.com>,
	llvm@lists.linux.dev, kbuild-all@lists.01.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: kernel/trace/ftrace.c:7157:20: error: unused function 'ftrace_startup_enable'
Date: Tue, 15 Feb 2022 01:28:53 +0900	[thread overview]
Message-ID: <CAK7LNAQmztEn7nN_R05zhXWc-5S44Y5nGQQjzdByTPxgDH13wA@mail.gmail.com> (raw)
In-Reply-To: <Ygp64CsyyKyRykqE@dev-arch.archlinux-ax161>

On Tue, Feb 15, 2022 at 12:53 AM Nathan Chancellor <nathan@kernel.org> wrote:
>
> Hi Steve,
>
> On Mon, Feb 14, 2022 at 10:20:00AM -0500, Steven Rostedt wrote:
> > On Sun, 13 Feb 2022 21:03:29 +0800
> > kernel test robot <lkp@intel.com> wrote:
> >
> > > All errors (new ones prefixed by >>):
> > >
> > > >> kernel/trace/ftrace.c:7157:20: error: unused function 'ftrace_startup_enable' [-Werror,-Wunused-function]
> > >    static inline void ftrace_startup_enable(int command) { }
> > >                       ^
> > >    1 error generated.
> >
> > Strange. I always thought that static inline functions do not cause
> > warnings when not used? Especially, since they are often in headers when
> > things are turned off. Or is it because this is in a C file?
>
> With -Wunused-function, clang will warn about unused static inline
> functions within a .c file (but not .h), whereas GCC will not warn for
> either. The unused attribute was added to the definition of inline to
> make clang's behavior match GCC's.
>
> > Is this a new warning caused by a commit, or is it a new warning because
> > the compiler now complains about it?
>
> However, in commit 6863f5643dd7 ("kbuild: allow Clang to find unused
> static inline functions for W=1 build"), Masahiro made it so that the
> unused attribute does not get added at W=1 so that instances of unused
> static inline functions can be caught and eliminated (or put into use,
> if the function should have been used), hence this report.

BTW, my hope was to move this warning to W=0 someday.
(that is, remove __inline_maybe_unused entirely).

I do not know how many warnings are still remaining, though.
Is it now more difficult due to CONFIG_WERROR?



> I will be honest, I don't know why the robot flagged 172f7ba9772c as the
> commit that introduced this warning but it seems legitimate if
> CONFIG_DYNAMIC_FTRACE is not enabled, since ftrace_startup_enable() is
> only ever used within an '#ifdef CONFIG_DYNAMIC_FTRACE' block so I guess
> the stub is unnecessary?
>
> Cheers,
> Nathan



-- 
Best Regards
Masahiro Yamada

WARNING: multiple messages have this Message-ID (diff)
From: Masahiro Yamada <masahiroy@kernel.org>
To: kbuild-all@lists.01.org
Subject: Re: kernel/trace/ftrace.c:7157:20: error: unused function 'ftrace_startup_enable'
Date: Tue, 15 Feb 2022 01:28:53 +0900	[thread overview]
Message-ID: <CAK7LNAQmztEn7nN_R05zhXWc-5S44Y5nGQQjzdByTPxgDH13wA@mail.gmail.com> (raw)
In-Reply-To: <Ygp64CsyyKyRykqE@dev-arch.archlinux-ax161>

[-- Attachment #1: Type: text/plain, Size: 2123 bytes --]

On Tue, Feb 15, 2022 at 12:53 AM Nathan Chancellor <nathan@kernel.org> wrote:
>
> Hi Steve,
>
> On Mon, Feb 14, 2022 at 10:20:00AM -0500, Steven Rostedt wrote:
> > On Sun, 13 Feb 2022 21:03:29 +0800
> > kernel test robot <lkp@intel.com> wrote:
> >
> > > All errors (new ones prefixed by >>):
> > >
> > > >> kernel/trace/ftrace.c:7157:20: error: unused function 'ftrace_startup_enable' [-Werror,-Wunused-function]
> > >    static inline void ftrace_startup_enable(int command) { }
> > >                       ^
> > >    1 error generated.
> >
> > Strange. I always thought that static inline functions do not cause
> > warnings when not used? Especially, since they are often in headers when
> > things are turned off. Or is it because this is in a C file?
>
> With -Wunused-function, clang will warn about unused static inline
> functions within a .c file (but not .h), whereas GCC will not warn for
> either. The unused attribute was added to the definition of inline to
> make clang's behavior match GCC's.
>
> > Is this a new warning caused by a commit, or is it a new warning because
> > the compiler now complains about it?
>
> However, in commit 6863f5643dd7 ("kbuild: allow Clang to find unused
> static inline functions for W=1 build"), Masahiro made it so that the
> unused attribute does not get added at W=1 so that instances of unused
> static inline functions can be caught and eliminated (or put into use,
> if the function should have been used), hence this report.

BTW, my hope was to move this warning to W=0 someday.
(that is, remove __inline_maybe_unused entirely).

I do not know how many warnings are still remaining, though.
Is it now more difficult due to CONFIG_WERROR?



> I will be honest, I don't know why the robot flagged 172f7ba9772c as the
> commit that introduced this warning but it seems legitimate if
> CONFIG_DYNAMIC_FTRACE is not enabled, since ftrace_startup_enable() is
> only ever used within an '#ifdef CONFIG_DYNAMIC_FTRACE' block so I guess
> the stub is unnecessary?
>
> Cheers,
> Nathan



-- 
Best Regards
Masahiro Yamada

  reply	other threads:[~2022-02-14 16:38 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-13 13:03 kernel/trace/ftrace.c:7157:20: error: unused function 'ftrace_startup_enable' kernel test robot
2022-02-13 13:03 ` kernel test robot
2022-02-14 15:20 ` Steven Rostedt
2022-02-14 15:20   ` Steven Rostedt
2022-02-14 15:53   ` Nathan Chancellor
2022-02-14 15:53     ` Nathan Chancellor
2022-02-14 16:28     ` Masahiro Yamada [this message]
2022-02-14 16:28       ` Masahiro Yamada
2022-02-14 17:00       ` Nathan Chancellor
2022-02-14 17:00         ` Nathan Chancellor
2022-02-14 18:57     ` Steven Rostedt
2022-02-14 18:57       ` Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAK7LNAQmztEn7nN_R05zhXWc-5S44Y5nGQQjzdByTPxgDH13wA@mail.gmail.com \
    --to=masahiroy@kernel.org \
    --cc=jiapeng.chong@linux.alibaba.com \
    --cc=kbuild-all@lists.01.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=llvm@lists.linux.dev \
    --cc=nathan@kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.