From 180e8be77c8bc19f6d4b078dfd30a94cac9b04e9 Mon Sep 17 00:00:00 2001 From: Alex Waterman Date: Fri, 7 Sep 2018 14:07:40 -0700 Subject: [PATCH] gpu: nvgpu: POSIX MISRA cleanups in bug.h The POSIX code does not need to be MISRA complient but any macro code in the POSIX stuff does get checked by nature of the scanner. Thus we get a lot of false positives that are annoying. This change fixes a couple of issues in the BUG() and WARN() macros: '__' prefixes, missing '{}' in if-conditions, and using a non-boolean in boolean context. Change-Id: I064b90c2088ef4ea5093ed456241a98f166008ac Signed-off-by: Alex Waterman Reviewed-on: https://git-master.nvidia.com/r/1816681 Reviewed-by: svc-misra-checker GVS: Gerrit_Virtual_Submit Reviewed-by: Philip Elcan Reviewed-by: Scott Long Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/include/nvgpu/posix/bug.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/nvgpu/include/nvgpu/posix/bug.h b/drivers/gpu/nvgpu/include/nvgpu/posix/bug.h index 04389a909..2d9fad1ef 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/posix/bug.h +++ b/drivers/gpu/nvgpu/include/nvgpu/posix/bug.h @@ -32,18 +32,19 @@ #define BUG() __bug("") #define BUG_ON(cond) \ do { \ - if (cond) \ + if (cond) { \ BUG(); \ + } \ } while (0) #define WARN(cond, msg, arg...) __warn(cond, msg, ##arg) #define WARN_ON(cond) __warn(cond, "") #define WARN_ONCE(cond, msg, arg...) \ - ({static int __warned__ = 0; \ - if (!__warned__) { \ + ({static bool warn_once_warned = false; \ + if (!warn_once_warned) { \ WARN(cond, msg, ##arg); \ - __warned__ = 1; \ + warn_once_warned = true; \ } \ cond; })