Skip to contentSkip to conversation

Checkpatch false positive: externs should be avoided in .c files

DISCUSSION Nam Cao 2 participants 4 messages Feb 2 – Feb 4 RISC-V

lore
Share & tools
lore

Nam Cao

author
#0 lore raw

Hi,

checkpatch seems to give a wrong warning about this patch:
https://lore.kernel.org/linux-riscv/[email protected]/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

#1 lore raw
Quoted 1 line · Nam Cao

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

Quoted 15 lines

checkpatch seems to give a wrong warning about this patch:
https://lore.kernel.org/linux-riscv/[email protected]/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

#2 lore raw
In reply to Nam Cao
Quoted 9 lines · Nam Cao

Hi,

checkpatch seems to give a wrong warning about this patch:
https://lore.kernel.org/linux-riscv/[email protected]/T/#u

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

Quoted 5 lines

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;
---

arch/riscv/kernel/setup.c +1 -5
index b5bc5fc65cea..c89cc272440b 100644
@@ -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);
 
author
#3 lore raw
Quoted 3 lines · Joe Perches

Please use the more common style like:

atomic_t __section(".sdata") hart_lottery;

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

Nam