libcpu: Remove false positive null ptr deref warning for GCC, -O3

Message ID 130a5041-bd78-4347-950b-65c605678ce6@gmail.com
State Committed
Headers
Series libcpu: Remove false positive null ptr deref warning for GCC, -O3 |

Commit Message

Phi Jan. 10, 2025, 1:26 p.m. UTC
  Hi All,

I try to send a patch via thunderbird, I don't know if the process is correct.
I tried from gmail but it was not good.

The patch is trivial and I use it to learn the patch submission process, along with the signed-off-by process

Cheers,
Phi
  

Comments

Aaron Merey Jan. 10, 2025, 11:19 p.m. UTC | #1
Hi Phi,

On Fri, Jan 10, 2025 at 8:26 AM Phi <phi.debian@gmail.com> wrote:
>
> I try to send a patch via thunderbird, I don't know if the process is correct.
> I tried from gmail but it was not good.
>
> The patch is trivial and I use it to learn the patch submission process, along with the signed-off-by process

Thanks for the patch, it fixes the warning for me.

I merged your patch with a small change to the commit message. I moved
the bugzilla reference and the changelog to just above the
Signed-off-by. I also replaced "See bugzilla Bug#32527" with the
sourceware URL of the bug.

It's recommended that you send patches to this list using 'git
send-email'. But in this case I was able to apply the patch you
attached without issue.

Aaron
  

Patch

From 3ac65cf6eec36a9a22af378e89bc4d5b148d8713 Mon Sep 17 00:00:00 2001
From: Philippe Benard <phi.debian@gmail.com>
Date: Thu, 9 Jan 2025 14:59:00 +0100
Subject: [PATCH] libcpu: Remove false positive null ptr deref warning for GCC
 -O3

See bugzilla Bug#32527

* libcpu/Makefile.am
i386_lex_CFLAGS += $(subst -O3,-Wno-null-dereference,$(findstring -O3,$(CFLAGS)))

i386_lex_CFLAGS is a make variable to tweak the i386_lex.c.o
specific compile flags. The are already some -W defined there, I'd
like to add one to avoid seeing false warning during build with -O3
compile flag.

GCC 14.2 (as well as 13.x) produce a false positive warning for the
i386 lexer, a bug is filled already against GCC for that, CLANG is
imune.

Signed-off-by: Philippe Benard <phi.debian@gmail.com>
---
 libcpu/Makefile.am | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libcpu/Makefile.am b/libcpu/Makefile.am
index 32835237..2e87021b 100644
--- a/libcpu/Makefile.am
+++ b/libcpu/Makefile.am
@@ -91,6 +91,8 @@  libeu = ../lib/libeu.a
 
 i386_lex_CFLAGS = -Wno-unused-label -Wno-unused-function -Wno-sign-compare \
 		  -Wno-implicit-fallthrough
+i386_lex_CFLAGS += $(subst -O3,-Wno-null-dereference,$(findstring -O3,$(CFLAGS)))
+
 i386_parse.o: i386_parse.c i386.mnemonics
 i386_lex.o: i386_parse.h
 i386_gendis_LDADD = $(libeu) -lm $(obstack_LIBS)
-- 
2.43.0