From 150905fff2674cc3dcbff6b62b679e7f1c38b0eb Mon Sep 17 00:00:00 2001 From: Alex Waterman Date: Thu, 20 Dec 2018 10:40:53 -0800 Subject: [PATCH] gpu: nvgpu: Combine else paths in nvgpu_assert() The else path in the nvgpu_assert() call definition handles the non-Linux kernel platforms. These platforms are generally safety conscious and as a result care about MISRA scans and unit testing. The static inline hides the BUG_ON() call from the unit test branch analyzer and the MISRA analyzer. Note: the MISRA issue still exists; however, it's just not seen when analyzing patches that only use the nvgpu_assert() call. This patch combines the __POSIX__ path with the general else path to ensure that all non-Linux platforms use the aforementioned static inline. JIRA NVGPU-1246 Change-Id: I3f267224acd0b27429302118872c40ca6d7b9137 Signed-off-by: Alex Waterman Reviewed-on: https://git-master.nvidia.com/r/1977276 Reviewed-by: Adeel Raza Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Terje Bergstrom GVS: Gerrit_Virtual_Submit Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/include/nvgpu/bug.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/nvgpu/include/nvgpu/bug.h b/drivers/gpu/nvgpu/include/nvgpu/bug.h index c458af58a..74c971fc8 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/bug.h +++ b/drivers/gpu/nvgpu/include/nvgpu/bug.h @@ -45,18 +45,21 @@ */ #if defined(__KERNEL__) #define nvgpu_assert(cond) WARN_ON(!(cond)) -#elif defined(__NVGPU_POSIX__) +#else /* - * A static inline for POSIX so that we can hide the branch in BUG_ON() from the - * branch analysis for users of this function. When this assert fails the - * function will not return. + * A static inline for POSIX/QNX/etc so that we can hide the branch in BUG_ON() + * from the branch analyzer. This prevents unit testing branch analysis from + * marking this as an untested branch everywhere the nvgpu_assert() macro is + * used. Similarly for MISRA this hides the messy BUG_ON() macro from users of + * this function. This means the MISRA scanner will only trigger 1 issue for + * this instead of 1 for every place it's used. + * + * When this assert fails the function will not return. */ static inline void nvgpu_assert(bool cond) { BUG_ON(!cond); } -#else -#define nvgpu_assert(cond) BUG_ON(!(cond)) #endif #endif /* NVGPU_BUG_H */