Skip to contentSkip to conversation

bug.h: introduce WARN_ONCE

PATCH New Ramon Fried 3 participants 3 messages May 28, 2018 – May 29, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bug.h: introduce WARN_ONCE

Add WARN_ONCE definition to allow single time notification of warnings to the user.

---
 include/linux/bug.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
include/linux/bug.h +18 -0
index f07bb716fc0..67b6057a22a 100644
@@ -20,6 +20,13 @@
 	unlikely(__ret_warn_on);					\
 })
 
+#define WARN(condition, format...) ({                   \
+	int __ret_warn_on = !!(condition);              \
+	if (unlikely(__ret_warn_on))                    \
+		__WARN_printf(format);                  \
+	unlikely(__ret_warn_on);                    \
+})
+
 #define WARN_ON_ONCE(condition)	({				\
 	static bool __warned;					\
 	int __ret_warn_once = !!(condition);			\
@@ -31,4 +38,15 @@
 	unlikely(__ret_warn_once);				\
 })
 
+#define WARN_ONCE(condition, format...) ({          \
+	static bool __warned;     \
+	int __ret_warn_once = !!(condition);            \
+								\
+	if (unlikely(__ret_warn_once && !__warned)) {       \
+		__warned = true;                \
+		WARN(1, format);                \
+	}                           \
+	unlikely(__ret_warn_once);              \
+})
+
 #endif	/* _LINUX_BUG_H */
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#1 lore raw

PATCH 1/1 bug.h: introduce WARN_ONCE

2018-05-28 18:44 GMT+09:00 Ramon Fried <[email protected]>:

Quoted 13 lines

Add WARN_ONCE definition to allow single time notification of warnings to the user.

---
 include/linux/bug.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
include/linux/bug.h +0 -0
index f07bb716fc0..67b6057a22a 100644

include/linux/bug.h line 26

Quoted 7 lines
include/linux/bug.h +4 -0
@@ -20,6 +20,13 @@
        unlikely(__ret_warn_on);                                        \
 })
 
+#define WARN(condition, format...) ({                   \
+       int __ret_warn_on = !!(condition);              \
+       if (unlikely(__ret_warn_on))                    \
+               __WARN_printf(format);                  \

Where is __WARN_printf() defined?

Quoted 30 lines
include/linux/bug.h +14 -1
+       unlikely(__ret_warn_on);                    \
+})
+
 #define WARN_ON_ONCE(condition)        ({                              \
        static bool __warned;                                   \
        int __ret_warn_once = !!(condition);                    \
@@ -31,4 +38,15 @@
        unlikely(__ret_warn_once);                              \
 })
 
+#define WARN_ONCE(condition, format...) ({          \
+       static bool __warned;     \
+       int __ret_warn_once = !!(condition);            \
+                                                               \
+       if (unlikely(__ret_warn_once && !__warned)) {       \
+               __warned = true;                \
+               WARN(1, format);                \
+       }                           \
+       unlikely(__ret_warn_once);              \
+})
+
 #endif /* _LINUX_BUG_H */
--

The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot

Signature · 2 lines
Best Regards
Masahiro Yamada
#2 lore raw

PATCH 1/1 bug.h: introduce WARN_ONCE

Quoted 17 lines · Masahiro Yamada

2018-05-28 18:44 GMT+09:00 Ramon Fried <[email protected]>:

Quoted 16 lines

Add WARN_ONCE definition to allow single time notification of warnings to the user.

---
 include/linux/bug.h | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
include/linux/bug.h +0 -0
index f07bb716fc0..67b6057a22a 100644
@@ -20,6 +20,13 @@
        unlikely(__ret_warn_on);                                        \
 })
 
Quoted 8 lines

include/linux/bug.h line 26

Quoted 4 lines
include/linux/bug.h +4 -0
+#define WARN(condition, format...) ({                   \
+       int __ret_warn_on = !!(condition);              \
+       if (unlikely(__ret_warn_on))                    \
+               __WARN_printf(format);                  \

Where is __WARN_printf() defined?

Ohhh. thanks for noticing. I pushed the wrong file. I'm pushing a fix shortly.

Quoted 43 lines
Quoted 29 lines
include/linux/bug.h +14 -1
+       unlikely(__ret_warn_on);                    \
+})
+
 #define WARN_ON_ONCE(condition)        ({                              \
        static bool __warned;                                   \
        int __ret_warn_once = !!(condition);                    \
@@ -31,4 +38,15 @@
        unlikely(__ret_warn_once);                              \
 })
 
+#define WARN_ONCE(condition, format...) ({          \
+       static bool __warned;     \
+       int __ret_warn_once = !!(condition);            \
+                                                               \
+       if (unlikely(__ret_warn_once && !__warned)) {       \
+               __warned = true;                \
+               WARN(1, format);                \
+       }                           \
+       unlikely(__ret_warn_once);              \
+})
+
 #endif /* _LINUX_BUG_H */
--

The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project

Quoted 4 lines

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot

--
Best Regards
Masahiro Yamada
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot