[PATCH] bitmap: improve header protection

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The check to bail out if 'find.h' is included instead of 'bitmap.h' is
weak. It fails if 'bitmap.h' is included before 'find.h'. So, introduce
a specific define just for this check. Put the error string in quotes
while here. To avoid build regressions, all faulty includes have been
fixed before.

Signed-off-by: Wolfram Sang <wsa+renesas@xxxxxxxxxxxxxxxxxxxx>
---

Here is my promised patch from the discusson at [1]. Buildbot is happy
with it.

[1] https://lore.kernel.org/r/Z2Goxx27WL-G-13y@xxxxxxxxxx

 include/linux/bitmap.h | 2 ++
 include/linux/find.h   | 8 ++++----
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/include/linux/bitmap.h b/include/linux/bitmap.h
index 2026953e2c4e..8a1e88080d46 100644
--- a/include/linux/bitmap.h
+++ b/include/linux/bitmap.h
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0 */
 #ifndef __LINUX_BITMAP_H
 #define __LINUX_BITMAP_H
+#define __LINUX_INSIDE_BITMAP_H
 
 #ifndef __ASSEMBLY__
 
@@ -831,4 +832,5 @@ void bitmap_write(unsigned long *map, unsigned long value,
 
 #endif /* __ASSEMBLY__ */
 
+#undef __LINUX_INSIDE_BITMAP_H
 #endif /* __LINUX_BITMAP_H */
diff --git a/include/linux/find.h b/include/linux/find.h
index 68685714bc18..44812c4fb5ec 100644
--- a/include/linux/find.h
+++ b/include/linux/find.h
@@ -1,11 +1,11 @@
 /* SPDX-License-Identifier: GPL-2.0 */
+#ifndef __LINUX_INSIDE_BITMAP_H
+#error "only <linux/bitmap.h> can be included directly"
+#endif
+
 #ifndef __LINUX_FIND_H_
 #define __LINUX_FIND_H_
 
-#ifndef __LINUX_BITMAP_H
-#error only <linux/bitmap.h> can be included directly
-#endif
-
 #include <linux/bitops.h>
 
 unsigned long _find_next_bit(const unsigned long *addr1, unsigned long nbits,
-- 
2.45.2





[Index of Archives]     [Linux Samsung SOC]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux