diff mbox series

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

Message ID 20220412110631.13865-2-rpalethorpe@suse.com
State Accepted
Headers show
Series [1/2] tools/sparse: Update to v0.6.4 | expand

Commit Message

Richard Palethorpe April 12, 2022, 11:06 a.m. UTC
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(-)

Comments

Petr Vorel April 14, 2022, 3:35 p.m. UTC | #1
Hi Richie,

Reviewed-by: Petr Vorel <pvorel@suse.cz>

Fortunately we can workaround the issue with compiler flag.
Hopefully we never need to fork remote repo due need to add a patch to source
code.

Kind regards,
Petr
diff mbox series

Patch

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