From mboxrd@z Thu Jan 1 00:00:00 1970 From: Simon Glass Date: Tue, 17 Jan 2017 22:50:32 -0700 Subject: [U-Boot] [PATCH 03/22] Update WARN_ON() to return a value In-Reply-To: <20170118055058.6358-1-sjg@chromium.org> References: <20170118055058.6358-1-sjg@chromium.org> Message-ID: <20170118055058.6358-4-sjg@chromium.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 --- include/linux/compat.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/include/linux/compat.h b/include/linux/compat.h index a43e4d66983..03f9bef0dae 100644 --- a/include/linux/compat.h +++ b/include/linux/compat.h @@ -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 -- 2.11.0.483.g087da7b7c-goog