Skip to contentSkip to conversation

Fix inclusion guards

PATCH In review Andre Przywara 3 participants 17 messages May 15, 2023 – May 31, 2023

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

cover Fix inclusion guards

A patch by Sam [1] reminded me to check for misspelled inclusion guards. I wrote some crude tool, with a high false positive rate, and was able to find some other occurences where the "#ifndef" and "#define" parts were not matching.

Those patches fix those preprocessor symbols. One header wasn't actually used anymore, so just remove that whole file.

Cheers,
Andre

[1] https://lore.kernel.org/u-boot/[email protected]/

Andre Przywara (5):
imx: fix header inclusion guards
arm: uniphier: fix header inclusion guard
freescale: fix header inclusion guard
exynos: fix header inclusion guard
faraday: remove orphaned header file

 arch/arm/include/asm/arch-imx8m/sys_proto.h   |  2 +-
 arch/arm/include/asm/arch-imx8ulp/sys_proto.h |  2 +-
 arch/arm/include/asm/arch-imx9/sys_proto.h    |  2 +-
 arch/arm/mach-uniphier/dram/ddrphy-init.h     |  2 +-
 board/freescale/common/vsc3316_3308.h         |  2 +-
 drivers/pinctrl/exynos/pinctrl-exynos.h       |  2 +-
 include/faraday/ftahbc020s.h                  | 46 -------------------
 include/imx_sip.h                             |  2 +-
 8 files changed, 7 insertions(+), 53 deletions(-)
 delete mode 100644 include/faraday/ftahbc020s.h
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/5 imx: fix header inclusion guards

It seems like the header inclusion guards for some IMX related headers were misspelled or got out of sync.

Make the preprocessor symbols for the #ifndef and #define lines the same, so that the double inclusion protection works as expected.

---
 arch/arm/include/asm/arch-imx8m/sys_proto.h   | 2 +-
 arch/arm/include/asm/arch-imx8ulp/sys_proto.h | 2 +-
 arch/arm/include/asm/arch-imx9/sys_proto.h    | 2 +-
 include/imx_sip.h                             | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
arch/arm/include/asm/arch-imx8m/sys_proto.h +1 -1
index 55b46afaf78..4ed8e954e31 100644
@@ -4,7 +4,7 @@
  */
 
 #ifndef __ARCH_IMX8M_SYS_PROTO_H
-#define __ARCH_NMX8M_SYS_PROTO_H
+#define __ARCH_IMX8M_SYS_PROTO_H
 
 #include <asm/mach-imx/sys_proto.h>
 #include <asm/arch/imx-regs.h>
arch/arm/include/asm/arch-imx8ulp/sys_proto.h +1 -1
index 5bbae21e37c..95bf753a766 100644
@@ -4,7 +4,7 @@
  */
 
 #ifndef __ARCH_IMX8ULP_SYS_PROTO_H
-#define __ARCH_NMX8ULP_SYS_PROTO_H
+#define __ARCH_IMX8ULP_SYS_PROTO_H
 
 #include <asm/mach-imx/sys_proto.h>
 
arch/arm/include/asm/arch-imx9/sys_proto.h +1 -1
index ba97f92f5ae..2f7a1292758 100644
@@ -4,7 +4,7 @@
  */
 
 #ifndef __ARCH_IMX9_SYS_PROTO_H
-#define __ARCH_NMX9_SYS_PROTO_H
+#define __ARCH_IMX9_SYS_PROTO_H
 
 #include <asm/mach-imx/sys_proto.h>
 
include/imx_sip.h +1 -1
index 1b873f231be..ebbb3a16d7e 100644
@@ -4,7 +4,7 @@
  */
 
 #ifndef _IMX_SIP_H__
-#define _IMX_SIP_H_
+#define _IMX_SIP_H__
 
 #define IMX_SIP_GPC		0xC2000000
 #define IMX_SIP_GPC_PM_DOMAIN	0x03
Signature · 1 line
2.25.1
Reviewed-by on v1 1/5
#2 lore raw

Re: [PATCH 1/5] imx: fix header inclusion guards

Quoted 7 lines · Andre Przywara

It seems like the header inclusion guards for some IMX related headers were misspelled or got out of sync.

Make the preprocessor symbols for the #ifndef and #define lines the same, so that the double inclusion protection works as expected.

Signature · 1 line
Tom
#3 lore raw

PATCH 2/5 arm: uniphier: fix header inclusion guard

In reply to Andre Przywara

It seems like the header inclusion guard for some Uniphier DDR PHY header was misspelled.

Make the preprocessor symbol for the #ifndef and #define lines the same, so that the double inclusion protection works as expected.

---
 arch/arm/mach-uniphier/dram/ddrphy-init.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm/mach-uniphier/dram/ddrphy-init.h +1 -1
index 09981f6e06f..4431f5c0ba6 100644
@@ -4,7 +4,7 @@
  */
 
 #ifndef ARCH_DDRPHY_INIT_H
-#define ARCH_DDRPHY_INTT_H
+#define ARCH_DDRPHY_INIT_H
 
 #include <linux/compiler.h>
 #include <linux/types.h>
Signature · 1 line
2.25.1
Reviewed-by on v1 2/5
#4 lore raw

Re: [PATCH 2/5] arm: uniphier: fix header inclusion guard

Quoted 7 lines · Andre Przywara

It seems like the header inclusion guard for some Uniphier DDR PHY header was misspelled.

Make the preprocessor symbol for the #ifndef and #define lines the same, so that the double inclusion protection works as expected.

Signature · 1 line
Tom
#5 lore raw

PATCH 3/5 freescale: fix header inclusion guard

In reply to Andre Przywara

It seems like the header inclusion guard for some Freescale crosspoint switch header was misspelled.

Make the preprocessor symbol for the #ifndef and #define lines the same, so that the double inclusion protection works as expected.

---
 board/freescale/common/vsc3316_3308.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
board/freescale/common/vsc3316_3308.h +1 -1
index 49a684f9f49..8d343ba4d65 100644
@@ -4,7 +4,7 @@
  */
 
 #ifndef __VSC_CROSSBAR_H_
-#define __VSC_CROSSBAR_H	1_
+#define __VSC_CROSSBAR_H_
 
 #include <common.h>
 #include <i2c.h>
Signature · 1 line
2.25.1
reviewer
#6 lore raw

Re: [PATCH 3/5] freescale: fix header inclusion guard

H Andre,

Quoted 17 lines · Andre Przywara

It seems like the header inclusion guard for some Freescale crosspoint switch header was misspelled.

Make the preprocessor symbol for the #ifndef and #define lines the same, so that the double inclusion protection works as expected.

---
 board/freescale/common/vsc3316_3308.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
board/freescale/common/vsc3316_3308.h +0 -0
index 49a684f9f49..8d343ba4d65 100644

board/freescale/common/vsc3316_3308.h line 7

Quoted 5 lines
board/freescale/common/vsc3316_3308.h +1 -1
@@ -4,7 +4,7 @@
  */
 
 #ifndef __VSC_CROSSBAR_H_
-#define __VSC_CROSSBAR_H       1_
+#define __VSC_CROSSBAR_H_

The change is correct, but it does not match the Subject/commit log.

#7 lore raw

Re: [PATCH 3/5] freescale: fix header inclusion guard

On Mon, 15 May 2023 11:17:14 -0300
Fabio Estevam <[email protected]> wrote:

Hi Fabio,

Quoted 20 lines · Andre Przywara
Quoted 19 lines

It seems like the header inclusion guard for some Freescale crosspoint switch header was misspelled.

Make the preprocessor symbol for the #ifndef and #define lines the same, so that the double inclusion protection works as expected.

---
 board/freescale/common/vsc3316_3308.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
board/freescale/common/vsc3316_3308.h +0 -0
index 49a684f9f49..8d343ba4d65 100644
@@ -4,7 +4,7 @@
  */
 
Quoted 5 lines

board/freescale/common/vsc3316_3308.h line 7

Quoted 3 lines
board/freescale/common/vsc3316_3308.h +1 -1
 #ifndef __VSC_CROSSBAR_H_
-#define __VSC_CROSSBAR_H       1_
+#define __VSC_CROSSBAR_H_  

The change is correct, but it does not match the Subject/commit log.

What do you mean, exactly?
To put *some* context into the commit message, I tried to find out what this "vsc" device is about, and found "crosspoint switch" somewhere (doc/README.VSC3316-3308). Is that not what it is about? Or is not a Freescale device, but just used by Freescale SoCs? Some T208 hardware seems to be the only user, though.

Can you suggest a better description?

Cheers,
Andre

reviewer
#8 lore raw

Re: [PATCH 3/5] freescale: fix header inclusion guard

Hi Andre,

Quoted 6 lines

What do you mean, exactly?
To put *some* context into the commit message, I tried to find out what this "vsc" device is about, and found "crosspoint switch" somewhere (doc/README.VSC3316-3308). Is that not what it is about? Or is not a Freescale device, but just used by Freescale SoCs? Some T208 hardware seems to be the only user, though.

The VSC3316 is a switch manufactured by Microchip:
https://www.microsemi.com/product-directory/digital-crosspoint-switches/3998-vsc3316

Quoted 1 line

Can you suggest a better description?

What about:

Subject: freescale: vsc3316_3308: fix header inclusion guard

It seems like the header inclusion guard for the vsc3316_3308 switch header was misspelled.

Make the preprocessor symbol for the #ifndef and #define lines the same, so that the double inclusion protection works as expected.

Reviewed-by on v1 3/5
#9 lore raw

Re: [PATCH 3/5] freescale: fix header inclusion guard

In reply to Andre Przywara
Quoted 7 lines · Andre Przywara

It seems like the header inclusion guard for some Freescale crosspoint switch header was misspelled.

Make the preprocessor symbol for the #ifndef and #define lines the same, so that the double inclusion protection works as expected.

Signature · 1 line
Tom
#10 lore raw

PATCH 4/5 exynos: fix header inclusion guard

In reply to Andre Przywara

It seems like the header inclusion guard for the Exynos pinctrl header was misspelled.

Make the preprocessor symbol for the #ifndef and #define lines the same, so that the double inclusion protection works as expected.

---
 drivers/pinctrl/exynos/pinctrl-exynos.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pinctrl/exynos/pinctrl-exynos.h +1 -1
index a7788b76d90..cbc5174b48c 100644
@@ -6,7 +6,7 @@
  */
 
 #ifndef __PINCTRL_EXYNOS_H_
-#define __PINCTRL_EXYNOS__H_
+#define __PINCTRL_EXYNOS_H_
 
 #define PIN_CON		0x00	/* Offset of pin function register */
 #define PIN_DAT		0x04	/* Offset of pin data register */
Signature · 1 line
2.25.1
Reviewed-by on v1 4/5
#11 lore raw

Re: [PATCH 4/5] exynos: fix header inclusion guard

Quoted 7 lines · Andre Przywara

It seems like the header inclusion guard for the Exynos pinctrl header was misspelled.

Make the preprocessor symbol for the #ifndef and #define lines the same, so that the double inclusion protection works as expected.

Signature · 1 line
Tom
#12 lore raw

Re: [PATCH 4/5] exynos: fix header inclusion guard

In reply to Andre Przywara
Quoted 8 lines · Andre Przywara

It seems like the header inclusion guard for the Exynos pinctrl header was misspelled.

Make the preprocessor symbol for the #ifndef and #define lines the same, so that the double inclusion protection works as expected.

Applied to u-boot/next, thanks!

Signature · 1 line
Tom
#13 lore raw

PATCH 5/5 faraday: remove orphaned header file

In reply to Andre Przywara

Commit 11232139e399 ("nds32: Remove the architecture") removed the nds32 architecture, and with it the last user of the Faraday AHB controller header file.

Consequently remove that header file as well.

This was found because the inclusion guard was misspelled.

---
 include/faraday/ftahbc020s.h | 46 ------------------------------------
 1 file changed, 46 deletions(-)
 delete mode 100644 include/faraday/ftahbc020s.h
include/faraday/ftahbc020s.h deleted +0 -46
deleted file mode 100644
index e628156c151..00000000000
@@ -1,46 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0+ */
-/*
- * Copyright (C) 2011 Andes Technology Corporation
- * Macpaul Lin, Andes Technology Corporation <[email protected]>
- */
-
-/* FTAHBC020S - AHB Controller (Arbiter/Decoder) definitions */
-#ifndef __FTAHBC020S_H
-#define __FTAHBC202S_H
-
-/* Registers Offsets */
-
-/*
- * AHB Slave BSR, offset: n * 4, n=0~31
- */
-#ifndef __ASSEMBLY__
-struct ftahbc02s {
-	unsigned int	s_bsr[32];	/* 0x00-0x7c - Slave n Base/Size Reg */
-	unsigned int	pcr;		/* 0x80	- Priority Ctrl Reg */
-	unsigned int	tcrg;		/* 0x84	- Transfer Ctrl Reg */
-	unsigned int	cr;		/* 0x88	- Ctrl Reg */
-};
-#endif /* __ASSEMBLY__ */
-
-/*
- * FTAHBC020S_SLAVE_BSR - Slave n Base / Size Register
- */
-#define FTAHBC020S_SLAVE_BSR_BASE(x)	(((x) & 0xfff) << 20)
-#define FTAHBC020S_SLAVE_BSR_SIZE(x)	(((x) & 0xf) << 16)
-/* The value of b(16:19)SLAVE_BSR_SIZE: 1M-2048M, must be power of 2 */
-#define FTAHBC020S_BSR_SIZE(x)		(ffs(x) - 1)	/* size of Addr Space */
-
-/*
- * FTAHBC020S_PCR - Priority Control Register
- */
-#define FTAHBC020S_PCR_PLEVEL_(x)	(1 << (x))	/* x: 1-15 */
-
-/*
- * FTAHBC020S_CR - Interrupt Control Register
- */
-#define FTAHBC020S_CR_INTSTS	(1 << 24)
-#define FTAHBC020S_CR_RESP(x)	(((x) & 0x3) << 20)
-#define FTAHBC020S_CR_INTSMASK	(1 << 16)
-#define FTAHBC020S_CR_REMAP	(1 << 0)
-
-#endif	/* __FTAHBC020S_H */
Signature · 1 line
2.25.1
Reviewed-by on v1 5/5
#14 lore raw

Re: [PATCH 5/5] faraday: remove orphaned header file

Quoted 9 lines · Andre Przywara

Commit 11232139e399 ("nds32: Remove the architecture") removed the nds32 architecture, and with it the last user of the Faraday AHB controller header file.

Consequently remove that header file as well.

This was found because the inclusion guard was misspelled.

Fixes 11232139e399 ("nds32: Remove the architecture")
Signature · 1 line
Tom
#15 lore raw

Re: [PATCH 5/5] faraday: remove orphaned header file

In reply to Andre Przywara
Quoted 10 lines · Andre Przywara

Commit 11232139e399 ("nds32: Remove the architecture") removed the nds32 architecture, and with it the last user of the Faraday AHB controller header file.

Consequently remove that header file as well.

This was found because the inclusion guard was misspelled.

Applied to u-boot/next, thanks!

Signature · 1 line
Tom
#16 lore raw
In reply to Andre Przywara
Quoted 7 lines · Andre Przywara

A patch by Sam [1] reminded me to check for misspelled inclusion guards. I wrote some crude tool, with a high false positive rate, and was able to find some other occurences where the "#ifndef" and "#define" parts were not matching.

Those patches fix those preprocessor symbols. One header wasn't actually used anymore, so just remove that whole file.

This got me to do a related quick check and I see a handful of unused include files. I'll follow up with that.

Signature · 1 line
Tom