]> git.sur5r.net Git - u-boot/commitdiff
Update WARN_ON() to return a value
authorSimon Glass <sjg@chromium.org>
Fri, 19 May 2017 02:08:52 +0000 (20:08 -0600)
committerSimon Glass <sjg@chromium.org>
Thu, 1 Jun 2017 13:03:06 +0000 (07:03 -0600)
In linux v4.9 this returns a value. This saves checking the warning
condition twice in some code.

Update the U-Boot version to do this also.

Signed-off-by: Simon Glass <sjg@chromium.org>
include/linux/compat.h

index a43e4d66983dd9a996eb1a21fd44ce5df6357cea..03f9bef0dae8a2c44f91fbed9af7dba122a7628d 100644 (file)
@@ -106,8 +106,12 @@ static inline void kmem_cache_destroy(struct kmem_cache *cachep)
 #define BUG_ON(condition) do { if (condition) BUG(); } while(0)
 #endif /* BUG */
 
-#define WARN_ON(x) if (x) {printf("WARNING in %s line %d\n" \
-                                 , __FILE__, __LINE__); }
+#define WARN_ON(condition) ({                                          \
+       int __ret_warn_on = !!(condition);                              \
+       if (unlikely(__ret_warn_on))                                    \
+               printf("WARNING in %s line %d\n", __FILE__, __LINE__);; \
+       unlikely(__ret_warn_on);                                        \
+})
 
 #define PAGE_SIZE      4096