Building the Linux kernel with Clang and LLVM
 help / color / mirror / Atom feed
* [trace:probes/for-next 17/17] kernel/kprobes.c:1141:24: error: a function declaration without a prototype is deprecated in all versions of C
@ 2024-05-16 19:15 kernel test robot
  2024-05-16 20:50 ` Stephen Brennan
  0 siblings, 1 reply; 4+ messages in thread
From: kernel test robot @ 2024-05-16 19:15 UTC (permalink / raw
  To: Stephen Brennan
  Cc: llvm, oe-kbuild-all, Masami Hiramatsu (Google),
	Steven Rostedt (Google)

tree:   git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace probes/for-next
head:   1a7d0890dd4a502a202aaec792a6c04e6e049547
commit: 1a7d0890dd4a502a202aaec792a6c04e6e049547 [17/17] kprobe/ftrace: bail out if ftrace was killed
config: s390-defconfig (https://download.01.org/0day-ci/archive/20240517/202405170340.eyEMhYvc-lkp@intel.com/config)
compiler: clang version 19.0.0git (https://github.com/llvm/llvm-project d3455f4ddd16811401fa153298fadd2f59f6914e)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240517/202405170340.eyEMhYvc-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202405170340.eyEMhYvc-lkp@intel.com/

All errors (new ones prefixed by >>):

   In file included from kernel/kprobes.c:23:
   In file included from include/linux/kprobes.h:28:
   In file included from include/linux/ftrace.h:13:
   In file included from include/linux/kallsyms.h:13:
   In file included from include/linux/mm.h:2210:
   include/linux/vmstat.h:508:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     508 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     509 |                            item];
         |                            ~~~~
   include/linux/vmstat.h:515:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     515 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     516 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
   include/linux/vmstat.h:522:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
     522 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
         |                               ~~~~~~~~~~~ ^ ~~~
   include/linux/vmstat.h:527:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     527 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     528 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
   include/linux/vmstat.h:536:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
     536 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~ ^
     537 |                            NR_VM_NUMA_EVENT_ITEMS +
         |                            ~~~~~~~~~~~~~~~~~~~~~~
>> kernel/kprobes.c:1141:24: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
    1141 | void kprobe_ftrace_kill()
         |                        ^
         |                         void
   5 warnings and 1 error generated.


vim +1141 kernel/kprobes.c

  1140	
> 1141	void kprobe_ftrace_kill()
  1142	{
  1143		kprobe_ftrace_disabled = true;
  1144	}
  1145	#else	/* !CONFIG_KPROBES_ON_FTRACE */
  1146	static inline int arm_kprobe_ftrace(struct kprobe *p)
  1147	{
  1148		return -ENODEV;
  1149	}
  1150	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [trace:probes/for-next 17/17] kernel/kprobes.c:1141:24: error: a function declaration without a prototype is deprecated in all versions of C
  2024-05-16 19:15 [trace:probes/for-next 17/17] kernel/kprobes.c:1141:24: error: a function declaration without a prototype is deprecated in all versions of C kernel test robot
@ 2024-05-16 20:50 ` Stephen Brennan
  2024-05-17 16:40   ` Nathan Chancellor
  2024-05-18 14:50   ` Masami Hiramatsu
  0 siblings, 2 replies; 4+ messages in thread
From: Stephen Brennan @ 2024-05-16 20:50 UTC (permalink / raw
  To: kernel test robot
  Cc: llvm, oe-kbuild-all, Masami Hiramatsu (Google),
	Steven Rostedt (Google)

kernel test robot <lkp@intel.com> writes:
> tree:   git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace probes/for-next
> head:   1a7d0890dd4a502a202aaec792a6c04e6e049547
> commit: 1a7d0890dd4a502a202aaec792a6c04e6e049547 [17/17] kprobe/ftrace: bail out if ftrace was killed
> config: s390-defconfig (https://download.01.org/0day-ci/archive/20240517/202405170340.eyEMhYvc-lkp@intel.com/config)
> compiler: clang version 19.0.0git (https://github.com/llvm/llvm-project d3455f4ddd16811401fa153298fadd2f59f6914e)
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240517/202405170340.eyEMhYvc-lkp@intel.com/reproduce)
>
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202405170340.eyEMhYvc-lkp@intel.com/
>
> All errors (new ones prefixed by >>):
>
>    In file included from kernel/kprobes.c:23:
>    In file included from include/linux/kprobes.h:28:
>    In file included from include/linux/ftrace.h:13:
>    In file included from include/linux/kallsyms.h:13:
>    In file included from include/linux/mm.h:2210:
>    include/linux/vmstat.h:508:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
>      508 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
>          |                            ~~~~~~~~~~~~~~~~~~~~~ ^
>      509 |                            item];
>          |                            ~~~~
>    include/linux/vmstat.h:515:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
>      515 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
>          |                            ~~~~~~~~~~~~~~~~~~~~~ ^
>      516 |                            NR_VM_NUMA_EVENT_ITEMS +
>          |                            ~~~~~~~~~~~~~~~~~~~~~~
>    include/linux/vmstat.h:522:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
>      522 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
>          |                               ~~~~~~~~~~~ ^ ~~~
>    include/linux/vmstat.h:527:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
>      527 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
>          |                            ~~~~~~~~~~~~~~~~~~~~~ ^
>      528 |                            NR_VM_NUMA_EVENT_ITEMS +
>          |                            ~~~~~~~~~~~~~~~~~~~~~~
>    include/linux/vmstat.h:536:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
>      536 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
>          |                            ~~~~~~~~~~~~~~~~~~~~~ ^
>      537 |                            NR_VM_NUMA_EVENT_ITEMS +
>          |                            ~~~~~~~~~~~~~~~~~~~~~~
>>> kernel/kprobes.c:1141:24: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
>     1141 | void kprobe_ftrace_kill()
>          |                        ^
>          |                         void
>    5 warnings and 1 error generated.

This certainly reads as an error in my patch. I tried to carefully
include three declarations:

1. CONFIG_KPROBES && CONFIG_KPROBES_ON_FTRACE (the extern decl)
2. CONFIG_KPROBES && !CONFIG_KPROBES_ON_FTRACE (a static inline)
3. !CONFIG_KPROBES (a static inline)

To double check, I actually used an ifdef visualizer[1] (written by a
coworker) and as far as I can see, I did this correctly...

When I pull probes/for-next and the 0day compiler configuration, I do
reproduce the build error.

However, I'm not 100% confident that this is a real error. I ran the
build with make V=1, and found the clang build command to build the
kernel/kprobes.c command. I replaced the "-c -o kernel/kprobes.o" with
"-E", so that I could simply browse the preprocessed source code. I cd
into the build directory and do:

$extremely_long_clang_command ... -E $srcdir/kernel/kprobes.o \
    | grep kprobe_ftrace_kill
extern void kprobe_ftrace_kill(void);
void kprobe_ftrace_kill()

---

When I do a GCC cross compile (s390x-linux-gnu-gcc) using the same
configuration file, with "W=1 V=1" I do see:

/home/stepbren/repos/linux-upstream/kernel/kprobes.c: In function ‘kprobe_ftrace_kill’:
/home/stepbren/repos/linux-upstream/kernel/kprobes.c:1141:6: warning: old-style function definition [-Wold-style-definition]
 1141 | void kprobe_ftrace_kill()
      |      ^~~~~~~~~~~~~~~~~~

I'm guessing that what's happening here is that Clang is categorizing
the old-style declaration as a different function for which there was no
prior declaration. When I add the "void" here, the clang error goes
away.

In any case, the warning is right, and I should have used the correct
declaration here. The below patch will shut this up. If there's any
possibility of improving the error message clang gives us here, it would
be appreciated though.

Masami, would you like me to send this to the list, or do you just want
to fix up the commit? My apologies for this, I should have run the "make
W=1" prior to submission.

Thanks,
Stephen

From 324849fd366b8d2d4367ed2cd6f74621099439e1 Mon Sep 17 00:00:00 2001
From: Stephen Brennan <stephen.s.brennan@oracle.com>
Date: Thu, 16 May 2024 13:48:32 -0700
Subject: [PATCH] kprobes/ftrace: fix old-style function declaration

Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
---
 kernel/kprobes.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 166ebf81dc450..4f917bdad1e11 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -1138,7 +1138,7 @@ static int disarm_kprobe_ftrace(struct kprobe *p)
                ipmodify ? &kprobe_ipmodify_enabled : &kprobe_ftrace_enabled);
 }

-void kprobe_ftrace_kill()
+void kprobe_ftrace_kill(void)
 {
        kprobe_ftrace_disabled = true;
 }
--
2.43.0

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [trace:probes/for-next 17/17] kernel/kprobes.c:1141:24: error: a function declaration without a prototype is deprecated in all versions of C
  2024-05-16 20:50 ` Stephen Brennan
@ 2024-05-17 16:40   ` Nathan Chancellor
  2024-05-18 14:50   ` Masami Hiramatsu
  1 sibling, 0 replies; 4+ messages in thread
From: Nathan Chancellor @ 2024-05-17 16:40 UTC (permalink / raw
  To: Stephen Brennan
  Cc: kernel test robot, llvm, oe-kbuild-all, Masami Hiramatsu (Google),
	Steven Rostedt (Google)

Hi Stephen,

On Thu, May 16, 2024 at 01:50:31PM -0700, Stephen Brennan wrote:
> kernel test robot <lkp@intel.com> writes:
> >>> kernel/kprobes.c:1141:24: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
> >     1141 | void kprobe_ftrace_kill()
> >          |                        ^
> >          |                         void
> >    5 warnings and 1 error generated.
...
> I'm guessing that what's happening here is that Clang is categorizing
> the old-style declaration as a different function for which there was no
> prior declaration. When I add the "void" here, the clang error goes
> away.

I believe you are right.

> In any case, the warning is right, and I should have used the correct
> declaration here. The below patch will shut this up. If there's any
> possibility of improving the error message clang gives us here, it would
> be appreciated though.

I think Aaron Ballman, one of the clang code owners, commented on this
exact situation recently, in the larger context of addressing some of
the wording issues with this warning if I am understanding that issue
correctly:
https://github.com/llvm/llvm-project/issues/90596#issuecomment-2096081580

Cheers,
Nathan

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [trace:probes/for-next 17/17] kernel/kprobes.c:1141:24: error: a function declaration without a prototype is deprecated in all versions of C
  2024-05-16 20:50 ` Stephen Brennan
  2024-05-17 16:40   ` Nathan Chancellor
@ 2024-05-18 14:50   ` Masami Hiramatsu
  1 sibling, 0 replies; 4+ messages in thread
From: Masami Hiramatsu @ 2024-05-18 14:50 UTC (permalink / raw
  To: Stephen Brennan
  Cc: kernel test robot, llvm, oe-kbuild-all, Masami Hiramatsu (Google),
	Steven Rostedt (Google)

On Thu, 16 May 2024 13:50:31 -0700
Stephen Brennan <stephen.s.brennan@oracle.com> wrote:

> kernel test robot <lkp@intel.com> writes:
> > tree:   git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace probes/for-next
> > head:   1a7d0890dd4a502a202aaec792a6c04e6e049547
> > commit: 1a7d0890dd4a502a202aaec792a6c04e6e049547 [17/17] kprobe/ftrace: bail out if ftrace was killed
> > config: s390-defconfig (https://download.01.org/0day-ci/archive/20240517/202405170340.eyEMhYvc-lkp@intel.com/config)
> > compiler: clang version 19.0.0git (https://github.com/llvm/llvm-project d3455f4ddd16811401fa153298fadd2f59f6914e)
> > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240517/202405170340.eyEMhYvc-lkp@intel.com/reproduce)
> >
> > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > the same patch/commit), kindly add following tags
> > | Reported-by: kernel test robot <lkp@intel.com>
> > | Closes: https://lore.kernel.org/oe-kbuild-all/202405170340.eyEMhYvc-lkp@intel.com/
> >
> > All errors (new ones prefixed by >>):
> >
> >    In file included from kernel/kprobes.c:23:
> >    In file included from include/linux/kprobes.h:28:
> >    In file included from include/linux/ftrace.h:13:
> >    In file included from include/linux/kallsyms.h:13:
> >    In file included from include/linux/mm.h:2210:
> >    include/linux/vmstat.h:508:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
> >      508 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
> >          |                            ~~~~~~~~~~~~~~~~~~~~~ ^
> >      509 |                            item];
> >          |                            ~~~~
> >    include/linux/vmstat.h:515:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
> >      515 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
> >          |                            ~~~~~~~~~~~~~~~~~~~~~ ^
> >      516 |                            NR_VM_NUMA_EVENT_ITEMS +
> >          |                            ~~~~~~~~~~~~~~~~~~~~~~
> >    include/linux/vmstat.h:522:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
> >      522 |         return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
> >          |                               ~~~~~~~~~~~ ^ ~~~
> >    include/linux/vmstat.h:527:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
> >      527 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
> >          |                            ~~~~~~~~~~~~~~~~~~~~~ ^
> >      528 |                            NR_VM_NUMA_EVENT_ITEMS +
> >          |                            ~~~~~~~~~~~~~~~~~~~~~~
> >    include/linux/vmstat.h:536:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
> >      536 |         return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
> >          |                            ~~~~~~~~~~~~~~~~~~~~~ ^
> >      537 |                            NR_VM_NUMA_EVENT_ITEMS +
> >          |                            ~~~~~~~~~~~~~~~~~~~~~~
> >>> kernel/kprobes.c:1141:24: error: a function declaration without a prototype is deprecated in all versions of C [-Werror,-Wstrict-prototypes]
> >     1141 | void kprobe_ftrace_kill()
> >          |                        ^
> >          |                         void
> >    5 warnings and 1 error generated.
> 
> This certainly reads as an error in my patch. I tried to carefully
> include three declarations:
> 
> 1. CONFIG_KPROBES && CONFIG_KPROBES_ON_FTRACE (the extern decl)
> 2. CONFIG_KPROBES && !CONFIG_KPROBES_ON_FTRACE (a static inline)
> 3. !CONFIG_KPROBES (a static inline)
> 
> To double check, I actually used an ifdef visualizer[1] (written by a
> coworker) and as far as I can see, I did this correctly...
> 
> When I pull probes/for-next and the 0day compiler configuration, I do
> reproduce the build error.
> 
> However, I'm not 100% confident that this is a real error. I ran the
> build with make V=1, and found the clang build command to build the
> kernel/kprobes.c command. I replaced the "-c -o kernel/kprobes.o" with
> "-E", so that I could simply browse the preprocessed source code. I cd
> into the build directory and do:
> 
> $extremely_long_clang_command ... -E $srcdir/kernel/kprobes.o \
>     | grep kprobe_ftrace_kill
> extern void kprobe_ftrace_kill(void);
> void kprobe_ftrace_kill()
> 
> ---
> 
> When I do a GCC cross compile (s390x-linux-gnu-gcc) using the same
> configuration file, with "W=1 V=1" I do see:
> 
> /home/stepbren/repos/linux-upstream/kernel/kprobes.c: In function ‘kprobe_ftrace_kill’:
> /home/stepbren/repos/linux-upstream/kernel/kprobes.c:1141:6: warning: old-style function definition [-Wold-style-definition]
>  1141 | void kprobe_ftrace_kill()
>       |      ^~~~~~~~~~~~~~~~~~
> 
> I'm guessing that what's happening here is that Clang is categorizing
> the old-style declaration as a different function for which there was no
> prior declaration. When I add the "void" here, the clang error goes
> away.
> 
> In any case, the warning is right, and I should have used the correct
> declaration here. The below patch will shut this up. If there's any
> possibility of improving the error message clang gives us here, it would
> be appreciated though.
> 
> Masami, would you like me to send this to the list, or do you just want
> to fix up the commit? My apologies for this, I should have run the "make
> W=1" prior to submission.

Sorry, that is my mistake to missed the issue. Linus alreay fixed the
error (I confirmed).
I also forgot to run W=1 build. Let me fix my process.

Thank you,

> 
> Thanks,
> Stephen
> 
> From 324849fd366b8d2d4367ed2cd6f74621099439e1 Mon Sep 17 00:00:00 2001
> From: Stephen Brennan <stephen.s.brennan@oracle.com>
> Date: Thu, 16 May 2024 13:48:32 -0700
> Subject: [PATCH] kprobes/ftrace: fix old-style function declaration
> 
> Signed-off-by: Stephen Brennan <stephen.s.brennan@oracle.com>
> ---
>  kernel/kprobes.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/kprobes.c b/kernel/kprobes.c
> index 166ebf81dc450..4f917bdad1e11 100644
> --- a/kernel/kprobes.c
> +++ b/kernel/kprobes.c
> @@ -1138,7 +1138,7 @@ static int disarm_kprobe_ftrace(struct kprobe *p)
>                 ipmodify ? &kprobe_ipmodify_enabled : &kprobe_ftrace_enabled);
>  }
> 
> -void kprobe_ftrace_kill()
> +void kprobe_ftrace_kill(void)
>  {
>         kprobe_ftrace_disabled = true;
>  }
> --
> 2.43.0


-- 
Masami Hiramatsu (Google) <mhiramat@kernel.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-05-18 14:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-16 19:15 [trace:probes/for-next 17/17] kernel/kprobes.c:1141:24: error: a function declaration without a prototype is deprecated in all versions of C kernel test robot
2024-05-16 20:50 ` Stephen Brennan
2024-05-17 16:40   ` Nathan Chancellor
2024-05-18 14:50   ` Masami Hiramatsu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).