From ee048e14898b41afeec8710e40283e5b4d32ee2f Mon Sep 17 00:00:00 2001 From: Adrian Reber Date: Tue, 13 Oct 2020 06:17:32 +0000 Subject: [PATCH] lock: disable clang_analyzer for the LOCK_BUG_ON() macro The clang analyzer, scan-build, cannot correctly handle the LOCK_BUG_ON() macro. At multiple places there is the following warning: Error: CLANG_WARNING: criu/pie/restorer.c:1221:4: warning: Dereference of null pointer include/common/lock.h:14:35: note: expanded from macro 'LOCK_BUG_ON' *(volatile unsigned long *)NULL = 0xdead0000 + __LINE__ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~ This just disable the clang analyzer for the LOCK_BUG_ON() macro. Signed-off-by: Adrian Reber --- include/common/lock.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/common/lock.h b/include/common/lock.h index 4782b638f..6baece25f 100644 --- a/include/common/lock.h +++ b/include/common/lock.h @@ -9,10 +9,13 @@ #include "common/asm/atomic.h" #include "common/compiler.h" +/* scan-build complains about derefencing a NULL pointer here. */ +#ifndef __clang_analyzer__ #define LOCK_BUG_ON(condition) \ if ((condition)) \ *(volatile unsigned long *)NULL = 0xdead0000 + __LINE__ #define LOCK_BUG() LOCK_BUG_ON(1) +#endif /* __clang_analyzer__ */ #ifdef CR_NOGLIBC # include