public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Checkpatch false positive: externs should be avoided in .c files
@ 2026-02-02 12:05 Nam Cao
  2026-02-02 15:24 ` Joe Perches
  2026-02-03  5:57 ` Joe Perches
  0 siblings, 2 replies; 4+ messages in thread
From: Nam Cao @ 2026-02-02 12:05 UTC (permalink / raw)
  To: Andy Whitcroft, Joe Perches, Dwaipayan Ray, Lukas Bulwahn,
	linux-kernel

Hi,

checkpatch seems to give a wrong warning about this patch:
https://lore.kernel.org/linux-riscv/20260202115403.2119218-1-namcao@linutronix.de/T/#u

WARNING: externs should be avoided in .c files
#663: FILE: arch/riscv/kernel/setup.c:49:
+atomic_t hart_lottery __section(".sdata");

I think this is wrong, because 'extern' does not even appear anywhere in
that part of the diff.

I attempted to look into checkpatch, but my perl knowledge is not
sufficient to dig deeper into this issue. Can you please have a look?

Best regards,
Nam

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

* Re: Checkpatch false positive: externs should be avoided in .c files
  2026-02-02 12:05 Checkpatch false positive: externs should be avoided in .c files Nam Cao
@ 2026-02-02 15:24 ` Joe Perches
  2026-02-03  5:57 ` Joe Perches
  1 sibling, 0 replies; 4+ messages in thread
From: Joe Perches @ 2026-02-02 15:24 UTC (permalink / raw)
  To: Nam Cao, Andy Whitcroft, Dwaipayan Ray, Lukas Bulwahn,
	linux-kernel

On Mon, 2026-02-02 at 13:05 +0100, Nam Cao wrote:
> Hi,

Hi Nam.

I was very confused for a second.
I have a friend with your name.
He's not someone who would use checkpatch.

I'll look at it.

cheers, Joe

> checkpatch seems to give a wrong warning about this patch:
> https://lore.kernel.org/linux-riscv/20260202115403.2119218-1-namcao@linutronix.de/T/#u
> 
> WARNING: externs should be avoided in .c files
> #663: FILE: arch/riscv/kernel/setup.c:49:
> +atomic_t hart_lottery __section(".sdata");
> 
> I think this is wrong, because 'extern' does not even appear anywhere in
> that part of the diff.
> 
> I attempted to look into checkpatch, but my perl knowledge is not
> sufficient to dig deeper into this issue. Can you please have a look?
> 
> Best regards,
> Nam

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

* Re: Checkpatch false positive: externs should be avoided in .c files
  2026-02-02 12:05 Checkpatch false positive: externs should be avoided in .c files Nam Cao
  2026-02-02 15:24 ` Joe Perches
@ 2026-02-03  5:57 ` Joe Perches
  2026-02-04  7:28   ` Nam Cao
  1 sibling, 1 reply; 4+ messages in thread
From: Joe Perches @ 2026-02-03  5:57 UTC (permalink / raw)
  To: Nam Cao, Andy Whitcroft, Dwaipayan Ray, Lukas Bulwahn,
	linux-kernel

On Mon, 2026-02-02 at 13:05 +0100, Nam Cao wrote:
> Hi,
> 
> checkpatch seems to give a wrong warning about this patch:
> https://lore.kernel.org/linux-riscv/20260202115403.2119218-1-namcao@linutronix.de/T/#u
> 
> WARNING: externs should be avoided in .c files
> #663: FILE: arch/riscv/kernel/setup.c:49:
> +atomic_t hart_lottery __section(".sdata");
> 
> I think this is wrong, because 'extern' does not even appear anywhere in
> that part of the diff.
> 
> I attempted to look into checkpatch, but my perl knowledge is not
> sufficient to dig deeper into this issue. Can you please have a look?

Please use the more common style like:

atomic_t __section(".sdata") hart_lottery;
---
diff --git a/arch/riscv/kernel/setup.c b/arch/riscv/kernel/setup.c
index b5bc5fc65cea..c89cc272440b 100644
--- a/arch/riscv/kernel/setup.c
+++ b/arch/riscv/kernel/setup.c
@@ -46,11 +46,7 @@
  * This is used before the kernel initializes the BSS so it can't be in the
  * BSS.
  */
-atomic_t hart_lottery __section(".sdata")
-#ifdef CONFIG_XIP_KERNEL
-= ATOMIC_INIT(0xC001BEEF)
-#endif
-;
+atomic_t hart_lottery __section(".sdata");
 unsigned long boot_cpu_hartid;
 EXPORT_SYMBOL_GPL(boot_cpu_hartid);
 

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

* Re: Checkpatch false positive: externs should be avoided in .c files
  2026-02-03  5:57 ` Joe Perches
@ 2026-02-04  7:28   ` Nam Cao
  0 siblings, 0 replies; 4+ messages in thread
From: Nam Cao @ 2026-02-04  7:28 UTC (permalink / raw)
  To: Joe Perches, Andy Whitcroft, Dwaipayan Ray, Lukas Bulwahn,
	linux-kernel

Joe Perches <joe@perches.com> writes:
> Please use the more common style like:
>
> atomic_t __section(".sdata") hart_lottery;

Ah, thanks! Will do that along with v2 patch.

Nam

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

end of thread, other threads:[~2026-02-04  7:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-02 12:05 Checkpatch false positive: externs should be avoided in .c files Nam Cao
2026-02-02 15:24 ` Joe Perches
2026-02-03  5:57 ` Joe Perches
2026-02-04  7:28   ` Nam Cao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox