gpu: nvgpu: fix EXPECT_BUG macro

The EXPECT_BUG macro is using setjmp/longjmp semantics but was
doing so in an inconsistent way that could cause issues if the
code was compiled with optimizations enabled (release builds).
Specifically, if setjmp is used in an "if" statement, a relational
or equality operator must be used with the right operand being an
integer constant expression. The unary ! operator cannot be used
in this case.

JIRA NVGPU-1246

Change-Id: Iebecff95aefd5b96a8f1f2f13bc178b370374563
Signed-off-by: Nicolas Benech <nbenech@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2029459
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Adeel Raza <araza@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Nicolas Benech
2019-02-27 13:28:59 -05:00
committed by mobile promotions
parent 350c8ebf11
commit d02c558aa4

View File

@@ -67,7 +67,7 @@ void bug_handler_cancel(void);
({ \
jmp_buf handler; \
bool bug_result = true; \
if (!setjmp(handler)) { \
if (setjmp(handler) != 0) { \
bug_handler_register(&handler); \
code_to_run; \
bug_handler_cancel(); \