From a37daf15bb02ee02e60a953e6807a59f03a896d3 Mon Sep 17 00:00:00 2001 From: "Kelvin M. Klann" Date: Wed, 31 May 2023 05:09:04 -0300 Subject: [PATCH 1/2] build: organize warning flags in CFLAGS --- src/prog.mk | 6 ++++-- src/so.mk | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/prog.mk b/src/prog.mk index b2ccf6147ed..53724465641 100644 --- a/src/prog.mk +++ b/src/prog.mk @@ -10,8 +10,10 @@ SRCS := $(sort $(wildcard *.c)) $(MOD_SRCS) OBJS := $(SRCS:.c=.o) $(MOD_OBJS) PROG_CFLAGS = \ - -ggdb $(HAVE_FATAL_WARNINGS) -O2 -DVERSION='"$(VERSION)"' \ - -fstack-protector-all -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security \ + -ggdb -O2 -DVERSION='"$(VERSION)"' \ + $(HAVE_FATAL_WARNINGS) \ + -Wformat -Wformat-security \ + -fstack-protector-all -D_FORTIFY_SOURCE=2 \ -fPIE \ -DPREFIX='"$(prefix)"' -DSYSCONFDIR='"$(sysconfdir)/firejail"' \ -DLIBDIR='"$(libdir)"' -DBINDIR='"$(bindir)"' \ diff --git a/src/so.mk b/src/so.mk index 28bd229e5c7..8787c71b824 100644 --- a/src/so.mk +++ b/src/so.mk @@ -10,8 +10,10 @@ SRCS := $(sort $(wildcard *.c)) $(MOD_SRCS) OBJS := $(SRCS:.c=.o) $(MOD_OBJS) SO_CFLAGS = \ - -ggdb $(HAVE_FATAL_WARNINGS) -O2 -DVERSION='"$(VERSION)"' \ - -fstack-protector-all -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security \ + -ggdb -O2 -DVERSION='"$(VERSION)"' \ + $(HAVE_FATAL_WARNINGS) \ + -Wformat -Wformat-security \ + -fstack-protector-all -D_FORTIFY_SOURCE=2 \ -fPIC SO_LDFLAGS = -pie -fPIE -Wl,-z,relro -Wl,-z,now From 94090654695bce5d00ef5a833fbd21f0d3ef195b Mon Sep 17 00:00:00 2001 From: "Kelvin M. Klann" Date: Wed, 31 May 2023 05:12:14 -0300 Subject: [PATCH 2/2] build: enable compiler warnings by default Enable -Wall by default and add -Wextra. --- configure | 4 ++-- configure.ac | 4 ++-- src/prog.mk | 2 +- src/so.mk | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/configure b/configure index dd210cd6756..ceb09bd3108 100755 --- a/configure +++ b/configure @@ -1391,7 +1391,7 @@ Optional Features: --disable-x11 disable X11 sandboxing support --disable-file-transfer disable file transfer --disable-suid install as a non-SUID executable - --enable-fatal-warnings -W -Wall -Werror + --enable-fatal-warnings -W -Werror --enable-busybox-workaround enable busybox workaround --enable-gcov Gcov instrumentation @@ -3601,7 +3601,7 @@ fi if test "x$enable_fatal_warnings" = "xyes"; then : - HAVE_FATAL_WARNINGS="-W -Wall -Werror" + HAVE_FATAL_WARNINGS="-W -Werror" fi diff --git a/configure.ac b/configure.ac index 357d1da452f..30b0318011b 100644 --- a/configure.ac +++ b/configure.ac @@ -215,9 +215,9 @@ AS_IF([test "x$enable_suid" != "xno"], [ HAVE_FATAL_WARNINGS="" AC_SUBST([HAVE_FATAL_WARNINGS]) AC_ARG_ENABLE([fatal_warnings], - [AS_HELP_STRING([--enable-fatal-warnings], [-W -Wall -Werror])]) + [AS_HELP_STRING([--enable-fatal-warnings], [-W -Werror])]) AS_IF([test "x$enable_fatal_warnings" = "xyes"], [ - HAVE_FATAL_WARNINGS="-W -Wall -Werror" + HAVE_FATAL_WARNINGS="-W -Werror" ]) BUSYBOX_WORKAROUND="no" diff --git a/src/prog.mk b/src/prog.mk index 53724465641..e4473184f15 100644 --- a/src/prog.mk +++ b/src/prog.mk @@ -11,7 +11,7 @@ OBJS := $(SRCS:.c=.o) $(MOD_OBJS) PROG_CFLAGS = \ -ggdb -O2 -DVERSION='"$(VERSION)"' \ - $(HAVE_FATAL_WARNINGS) \ + -Wall -Wextra $(HAVE_FATAL_WARNINGS) \ -Wformat -Wformat-security \ -fstack-protector-all -D_FORTIFY_SOURCE=2 \ -fPIE \ diff --git a/src/so.mk b/src/so.mk index 8787c71b824..e464a7bffe4 100644 --- a/src/so.mk +++ b/src/so.mk @@ -11,7 +11,7 @@ OBJS := $(SRCS:.c=.o) $(MOD_OBJS) SO_CFLAGS = \ -ggdb -O2 -DVERSION='"$(VERSION)"' \ - $(HAVE_FATAL_WARNINGS) \ + -Wall -Wextra $(HAVE_FATAL_WARNINGS) \ -Wformat -Wformat-security \ -fstack-protector-all -D_FORTIFY_SOURCE=2 \ -fPIC