Skip to contentSkip to conversation

x86/pci: Add missing forward declaration for pci_numachip_init()

PATCH Superseded Krzysztof Wilczyński 3 participants 5 messages Jul 29, 2021 – Aug 12, 2021

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/pci: Add missing forward declaration for pci_numachip_init()

At the moment, the function pci_numachip_init() is defined in the numachip.c file. Since this function has users outside of this file, add missing foward declaration to the pci_x86.h file.

This resolves the following sparse and compile time warning:

arch/x86/pci/numachip.c:108:12: warning: no previous prototype for function 'pci_numachip_init' [-Wmissing-prototypes] arch/x86/pci/numachip.c:108:12: warning: symbol 'pci_numachip_init' was not declared. Should it be static?

---
 arch/x86/include/asm/pci_x86.h | 4 ++++
 1 file changed, 4 insertions(+)
arch/x86/include/asm/pci_x86.h +4 -0
index 490411dba438..906f40cae3fc 100644
@@ -50,6 +50,10 @@ enum pci_bf_sort_state {
 	pci_dmi_bf,
 };
 
+/* numachip.c */
+
+int pci_numachip_init(void);
+
 /* pci-i386.c */
 
 void pcibios_resource_survey(void);
Signature · 1 line
2.32.0
#1 lore raw
Quoted 8 lines · Krzysztof Wilczyński

At the moment, the function pci_numachip_init() is defined in the numachip.c file. Since this function has users outside of this file, add missing foward declaration to the pci_x86.h file.

This resolves the following sparse and compile time warning:

arch/x86/pci/numachip.c:108:12: warning: no previous prototype for function 'pci_numachip_init' [-Wmissing-prototypes] arch/x86/pci/numachip.c:108:12: warning: symbol 'pci_numachip_init' was not declared. Should it be static?

Thanks for worrying about warnings like this. They're small but important.

What should be done with the pci_numachip_init() declaration in arch/x86/include/asm/numachip/numachip.h? It doesn't seem like we should have *two* declarations.

The one in arch/x86/include/asm/numachip/numachip.h is:

  extern int __init pci_numachip_init(void);

I'm not enough of a C language lawyer to know whether "__init" in a declaration is useful. It doesn't *seem* like it would be useful since this is not a definition and the compiler isn't generating code here. But "git grep __init include/ arch/*/include" finds quite a few of them.

Quoted 23 lines
---
 arch/x86/include/asm/pci_x86.h | 4 ++++
 1 file changed, 4 insertions(+)
arch/x86/include/asm/pci_x86.h +4 -0
index 490411dba438..906f40cae3fc 100644
@@ -50,6 +50,10 @@ enum pci_bf_sort_state {
 	pci_dmi_bf,
 };
 
+/* numachip.c */
+
+int pci_numachip_init(void);
+
 /* pci-i386.c */
 
 void pcibios_resource_survey(void);
Signature · 1 line
2.32.0
#2 lore raw
Quoted 4 lines · Bjorn Helgaas

On Thu, Jul 29, 2021 at 11:40:59PM +0000, Krzysztof Wilczyński wrote:
What should be done with the pci_numachip_init() declaration in arch/x86/include/asm/numachip/numachip.h? It doesn't seem like we should have *two* declarations.

Right. Include that file in the C file and be done with it.

Quoted 9 lines

The one in arch/x86/include/asm/numachip/numachip.h is:

  extern int __init pci_numachip_init(void);

I'm not enough of a C language lawyer to know whether "__init" in a declaration is useful. It doesn't *seem* like it would be useful since this is not a definition and the compiler isn't generating code here. But "git grep __init include/ arch/*/include" finds quite a few of them.

__init on the prototype is not having any effect except perhaps documentary value at least with current compilers.

The attribute magic is vague in both the C specification and the compiler manuals, but that might change some day in the future. But in which direction is unknown :)

Thanks,

tglx

#3 lore raw

Hi Thomas,

[...]

Quoted 5 lines
Quoted 3 lines

What should be done with the pci_numachip_init() declaration in arch/x86/include/asm/numachip/numachip.h? It doesn't seem like we should have *two* declarations.

Right. Include that file in the C file and be done with it.

I will send v2 shortly with the correct header file included.

Thank you both!

Krzysztof

#4 lore raw
In reply to Krzysztof Wilczyński
Quoted 9 lines · Krzysztof Wilczyński

At the moment, the function pci_numachip_init() is defined in the numachip.c file. Since this function has users outside of this file, add missing foward declaration to the pci_x86.h file.

This resolves the following sparse and compile time warning:

arch/x86/pci/numachip.c:108:12: warning: no previous prototype for function 'pci_numachip_init' [-Wmissing-prototypes] arch/x86/pci/numachip.c:108:12: warning: symbol 'pci_numachip_init'
was not declared. Should it be static?

No. arch/x86/pci/numachip.c simply lacks

#include <asm/numachip/numachip.h>

Thanks,

tglx