Skip to contentSkip to conversation

header guards: further cleanup

PATCH Applied Cornelia Huck 3 participants 6 messages Jun 10, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover header guards: further cleanup

Laurent had notices some further issues in my header guards series, so I
- fixed some header guards I missed initially
- added header guards to some headers that actually define something (and don't just include another header)

I did not actually remove any header guards that might be unneeded.

Cornelia Huck (2):
header guards: clean up some stragglers
add header guards for non-trivial headers

 configure             | 4 ++--
 lib/argv.h            | 5 +++++
 lib/arm/asm/mmu-api.h | 4 ++--
 lib/arm/asm/mmu.h     | 6 +++---
 lib/arm/io.h          | 5 +++++
 lib/arm64/asm/mmu.h   | 6 +++---
 lib/pci.h             | 6 +++---
 lib/powerpc/io.h      | 5 +++++
 8 files changed, 28 insertions(+), 13 deletions(-)
Signature · 1 line
2.31.1
#1 lore raw

PATCH 1/2 header guards: clean up some stragglers

Some headers had been missed during the initial header guard standardization.

---
 configure             | 4 ++--
 lib/arm/asm/mmu-api.h | 4 ++--
 lib/arm/asm/mmu.h     | 6 +++---
 lib/arm64/asm/mmu.h   | 6 +++---
 lib/pci.h             | 6 +++---
 5 files changed, 13 insertions(+), 13 deletions(-)
configure +2 -2
index 4ad5a4bcd782..b8442d61fb60 100755
@@ -332,8 +332,8 @@ if [ "$arch" = "arm" ] || [ "$arch" = "arm64" ]; then
 fi
 
 cat <<EOF > lib/config.h
-#ifndef CONFIG_H
-#define CONFIG_H 1
+#ifndef _CONFIG_H_
+#define _CONFIG_H_
 /*
  * Generated file. DO NOT MODIFY.
  *
lib/arm/asm/mmu-api.h +2 -2
index 05fc12b5afb8..3d77cbfd8b24 100644
@@ -1,5 +1,5 @@
-#ifndef __ASMARM_MMU_API_H_
-#define __ASMARM_MMU_API_H_
+#ifndef _ASMARM_MMU_API_H_
+#define _ASMARM_MMU_API_H_
 
 #include <asm/page.h>
 #include <stdbool.h>
lib/arm/asm/mmu.h +3 -3
index 94e70f0a84bf..b24b97e554e2 100644
@@ -1,5 +1,5 @@
-#ifndef __ASMARM_MMU_H_
-#define __ASMARM_MMU_H_
+#ifndef _ASMARM_MMU_H_
+#define _ASMARM_MMU_H_
 /*
  * Copyright (C) 2014, Red Hat Inc, Andrew Jones <[email protected]>
  *
@@ -53,4 +53,4 @@ static inline void flush_dcache_addr(unsigned long vaddr)
 
 #include <asm/mmu-api.h>
 
-#endif /* __ASMARM_MMU_H_ */
+#endif /* _ASMARM_MMU_H_ */
lib/arm64/asm/mmu.h +3 -3
index 72371b2d9fe3..5c27edb24d2e 100644
@@ -1,5 +1,5 @@
-#ifndef __ASMARM64_MMU_H_
-#define __ASMARM64_MMU_H_
+#ifndef _ASMARM64_MMU_H_
+#define _ASMARM64_MMU_H_
 /*
  * Copyright (C) 2014, Red Hat Inc, Andrew Jones <[email protected]>
  *
@@ -35,4 +35,4 @@ static inline void flush_dcache_addr(unsigned long vaddr)
 
 #include <asm/mmu-api.h>
 
-#endif /* __ASMARM64_MMU_H_ */
+#endif /* _ASMARM64_MMU_H_ */
lib/pci.h +3 -3
index 689f03ca7647..e201711dfe18 100644
@@ -1,5 +1,5 @@
-#ifndef PCI_H
-#define PCI_H
+#ifndef _PCI_H_
+#define _PCI_H_
 /*
  * API for scanning a PCI bus for a given device, as well to access
  * BAR registers.
@@ -102,4 +102,4 @@ struct pci_test_dev_hdr {
 
 #define  PCI_HEADER_TYPE_MASK		0x7f
 
-#endif /* PCI_H */
+#endif /* _PCI_H_ */
Signature · 1 line
2.31.1
Reviewed-by on v1 1/2
#2 lore raw

Re: [kvm-unit-tests PATCH 1/2] header guards: clean up some stragglers

Quoted 89 lines · Cornelia Huck

Some headers had been missed during the initial header guard standardization.

---
 configure             | 4 ++--
 lib/arm/asm/mmu-api.h | 4 ++--
 lib/arm/asm/mmu.h     | 6 +++---
 lib/arm64/asm/mmu.h   | 6 +++---
 lib/pci.h             | 6 +++---
 5 files changed, 13 insertions(+), 13 deletions(-)
configure +2 -2
index 4ad5a4bcd782..b8442d61fb60 100755
@@ -332,8 +332,8 @@ if [ "$arch" = "arm" ] || [ "$arch" = "arm64" ]; then
 fi
 
 cat <<EOF > lib/config.h
-#ifndef CONFIG_H
-#define CONFIG_H 1
+#ifndef _CONFIG_H_
+#define _CONFIG_H_
 /*
  * Generated file. DO NOT MODIFY.
  *
lib/arm/asm/mmu-api.h +2 -2
index 05fc12b5afb8..3d77cbfd8b24 100644
@@ -1,5 +1,5 @@
-#ifndef __ASMARM_MMU_API_H_
-#define __ASMARM_MMU_API_H_
+#ifndef _ASMARM_MMU_API_H_
+#define _ASMARM_MMU_API_H_
 
 #include <asm/page.h>
 #include <stdbool.h>
lib/arm/asm/mmu.h +3 -3
index 94e70f0a84bf..b24b97e554e2 100644
@@ -1,5 +1,5 @@
-#ifndef __ASMARM_MMU_H_
-#define __ASMARM_MMU_H_
+#ifndef _ASMARM_MMU_H_
+#define _ASMARM_MMU_H_
 /*
  * Copyright (C) 2014, Red Hat Inc, Andrew Jones <[email protected]>
  *
@@ -53,4 +53,4 @@ static inline void flush_dcache_addr(unsigned long vaddr)
 
 #include <asm/mmu-api.h>
 
-#endif /* __ASMARM_MMU_H_ */
+#endif /* _ASMARM_MMU_H_ */
lib/arm64/asm/mmu.h +3 -3
index 72371b2d9fe3..5c27edb24d2e 100644
@@ -1,5 +1,5 @@
-#ifndef __ASMARM64_MMU_H_
-#define __ASMARM64_MMU_H_
+#ifndef _ASMARM64_MMU_H_
+#define _ASMARM64_MMU_H_
 /*
  * Copyright (C) 2014, Red Hat Inc, Andrew Jones <[email protected]>
  *
@@ -35,4 +35,4 @@ static inline void flush_dcache_addr(unsigned long vaddr)
 
 #include <asm/mmu-api.h>
 
-#endif /* __ASMARM64_MMU_H_ */
+#endif /* _ASMARM64_MMU_H_ */
lib/pci.h +2 -2
index 689f03ca7647..e201711dfe18 100644
@@ -1,5 +1,5 @@
-#ifndef PCI_H
-#define PCI_H
+#ifndef _PCI_H_
+#define _PCI_H_
 /*
  * API for scanning a PCI bus for a given device, as well to access
  * BAR registers.

lib/pci.h struct pci_test_dev_hdr { · line 105

Quoted 5 lines
lib/pci.h +1 -1
@@ -102,4 +102,4 @@ struct pci_test_dev_hdr {
 
 #define  PCI_HEADER_TYPE_MASK		0x7f
 
-#endif /* PCI_H */
+#endif /* _PCI_H_ */
#3 lore raw

PATCH 2/2 add header guards for non-trivial headers

In reply to Cornelia Huck

Add header guards to headers that do not simply include another one.

---
 lib/argv.h       | 5 +++++
 lib/arm/io.h     | 5 +++++
 lib/powerpc/io.h | 5 +++++
 3 files changed, 15 insertions(+)
lib/argv.h +5 -0
index e5fcf8482ca8..1fd746dc2177 100644
@@ -5,7 +5,12 @@
  * under the terms of the GNU Library General Public License version 2.
  */
 
+#ifndef _ARGV_H_
+#define _ARGV_H_
+
 extern void __setup_args(void);
 extern void setup_args_progname(const char *args);
 extern void setup_env(char *env, int size);
 extern void add_setup_arg(const char *arg);
+
+#endif
lib/arm/io.h +5 -0
index 2746d72e8280..183479c899a9 100644
@@ -4,4 +4,9 @@
  * This work is licensed under the terms of the GNU GPL, version 2.
  */
 
+#ifndef _ARM_IO_H_
+#define _ARM_IO_H_
+
 extern void io_init(void);
+
+#endif
lib/powerpc/io.h +5 -0
index 1f5a7bd6d745..d4f21ba15a54 100644
@@ -4,5 +4,10 @@
  * This work is licensed under the terms of the GNU GPL, version 2.
  */
 
+#ifndef _POWERPC_IO_H_
+#define _POWERPC_IO_H_
+
 extern void io_init(void);
 extern void putchar(int c);
+
+#endif
Signature · 1 line
2.31.1
Reviewed-by on v1 2/2
#4 lore raw

Re: [kvm-unit-tests PATCH 2/2] add header guards for non-trivial headers

Quoted 46 lines · Cornelia Huck

Add header guards to headers that do not simply include another one.

---
 lib/argv.h       | 5 +++++
 lib/arm/io.h     | 5 +++++
 lib/powerpc/io.h | 5 +++++
 3 files changed, 15 insertions(+)
lib/argv.h +5 -0
index e5fcf8482ca8..1fd746dc2177 100644
@@ -5,7 +5,12 @@
  * under the terms of the GNU Library General Public License version 2.
  */
 
+#ifndef _ARGV_H_
+#define _ARGV_H_
+
 extern void __setup_args(void);
 extern void setup_args_progname(const char *args);
 extern void setup_env(char *env, int size);
 extern void add_setup_arg(const char *arg);
+
+#endif
lib/arm/io.h +5 -0
index 2746d72e8280..183479c899a9 100644
@@ -4,4 +4,9 @@
  * This work is licensed under the terms of the GNU GPL, version 2.
  */
 
+#ifndef _ARM_IO_H_
+#define _ARM_IO_H_
+
 extern void io_init(void);
+
+#endif
lib/powerpc/io.h +0 -0
index 1f5a7bd6d745..d4f21ba15a54 100644

lib/powerpc/io.h line 13

Quoted 10 lines
lib/powerpc/io.h +5 -0
@@ -4,5 +4,10 @@
  * This work is licensed under the terms of the GNU GPL, version 2.
  */
 
+#ifndef _POWERPC_IO_H_
+#define _POWERPC_IO_H_
+
 extern void io_init(void);
 extern void putchar(int c);
+
+#endif
maintainer Applied
#5 lore raw
In reply to Cornelia Huck
Quoted 12 lines · Cornelia Huck

Laurent had notices some further issues in my header guards series, so I
- fixed some header guards I missed initially
- added header guards to some headers that actually define something (and don't just include another header)

I did not actually remove any header guards that might be unneeded.

Cornelia Huck (2):
header guards: clean up some stragglers
add header guards for non-trivial headers

Quoted 10 lines
  configure             | 4 ++--
  lib/argv.h            | 5 +++++
  lib/arm/asm/mmu-api.h | 4 ++--
  lib/arm/asm/mmu.h     | 6 +++---
  lib/arm/io.h          | 5 +++++
  lib/arm64/asm/mmu.h   | 6 +++---
  lib/pci.h             | 6 +++---
  lib/powerpc/io.h      | 5 +++++
  8 files changed, 28 insertions(+), 13 deletions(-)

Queued, thanks.

Paolo