[LTP] [PATCH 2/2] tools/sparse: Allow null pointer subtraction

Richard Palethorpe rpalethorpe@suse.com
Tue Apr 12 13:06:31 CEST 2022


Used for the offsetof trick. Technically it is undefined behavior. A
patch to Sparse is waiting upstream:

https://lore.kernel.org/linux-sparse/20220321112119.23308-1-rpalethorpe@suse.com/T/#u

In the meantime we can disable the warning to make it compile.

Signed-off-by: Richard Palethorpe <rpalethorpe@suse.com>
---
 tools/sparse/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/sparse/Makefile b/tools/sparse/Makefile
index 4247dd86e..d35c9cabf 100644
--- a/tools/sparse/Makefile
+++ b/tools/sparse/Makefile
@@ -20,7 +20,7 @@ $(SPARSE_SRC)/libsparse.a: $(SPARSE_SRC)/Makefile
 
 HOST_MAKE_TARGETS	:= sparse-ltp
 MAKE_DEPS		+= $(SPARSE_SRC)/libsparse.a
-HOST_CFLAGS		+= -I$(SPARSE_SRC) -Werror
+HOST_CFLAGS		+= -I$(SPARSE_SRC) -Werror -Wno-null-pointer-subtraction
 HOST_LDLIBS		+= $(SPARSE_SRC)/libsparse.a
 
 
-- 
2.35.1



More information about the ltp mailing list