Blame SOURCES/audit-3.0.7-gcc-flags.patch

f1133c
From 36beaefbb4ecb0a222ac68ec9f17f854a82f7235 Mon Sep 17 00:00:00 2001
f1133c
From: Steve Grubb <sgrubb@redhat.com>
f1133c
Date: Mon, 14 Feb 2022 15:30:09 -0500
f1133c
Subject: [PATCH] Adjust compile flags
f1133c
f1133c
---
f1133c
 audisp/plugins/remote/Makefile.am |  2 +-
f1133c
 auparse/Makefile.am               |  2 +-
f1133c
 configure.ac                      | 15 +++++++++++++++
f1133c
 src/Makefile.am                   |  2 +-
f1133c
 4 files changed, 18 insertions(+), 3 deletions(-)
f1133c
f1133c
diff --git a/audisp/plugins/remote/Makefile.am b/audisp/plugins/remote/Makefile.am
f1133c
index 217d477c5..1ac77ee8d 100644
f1133c
--- a/audisp/plugins/remote/Makefile.am
f1133c
+++ b/audisp/plugins/remote/Makefile.am
f1133c
@@ -36,7 +36,7 @@ TESTS = $(check_PROGRAMS)
f1133c
 
f1133c
 audisp_remote_DEPENDENCIES = ${top_builddir}/common/libaucommon.la
f1133c
 audisp_remote_SOURCES = audisp-remote.c remote-config.c queue.c
f1133c
-audisp_remote_CFLAGS = -fPIE -DPIE -g -D_REENTRANT -D_GNU_SOURCE -Wundef
f1133c
+audisp_remote_CFLAGS = -fPIE -DPIE -g -D_REENTRANT -D_GNU_SOURCE -Wundef ${WFLAGS}
f1133c
 audisp_remote_LDFLAGS = -pie -Wl,-z,relro -Wl,-z,now
f1133c
 audisp_remote_LDADD = $(CAPNG_LDADD) $(gss_libs) ${top_builddir}/common/libaucommon.la
f1133c
 
f1133c
diff --git a/auparse/Makefile.am b/auparse/Makefile.am
f1133c
index b34b6c042..1eb5352cf 100644
f1133c
--- a/auparse/Makefile.am
f1133c
+++ b/auparse/Makefile.am
f1133c
@@ -26,7 +26,7 @@ SUBDIRS = test
f1133c
 EXTRA_DIST = expression-design.txt
f1133c
 CLEANFILES = $(BUILT_SOURCES)
f1133c
 CONFIG_CLEAN_FILES = *.loT *.rej *.orig
f1133c
-AM_CFLAGS = -fPIC -DPIC -D_GNU_SOURCE -g ${DEBUG} -Wno-pointer-sign -Wno-enum-compare -Wno-switch
f1133c
+AM_CFLAGS = -fPIC -DPIC -D_GNU_SOURCE -g ${DEBUG} -Wno-pointer-sign -Wno-enum-compare -Wno-switch ${WFLAGS}
f1133c
 AM_CPPFLAGS = -I. -I${top_srcdir} -I${top_srcdir}/src -I${top_srcdir}/lib -I${top_srcdir}/common
f1133c
 LIBS =
f1133c
 
f1133c
diff --git a/configure.ac b/configure.ac
f1133c
index e40d41e14..e74fd7036 100644
f1133c
--- a/configure.ac
f1133c
+++ b/configure.ac
f1133c
@@ -341,6 +341,21 @@ else
f1133c
 fi
f1133c
 ],WARNS="$ALLWARNS")
f1133c
 
f1133c
+WFLAGS=""
f1133c
+AC_MSG_CHECKING(for -Wformat-truncation)
f1133c
+TMPCFLAGS="${CFLAGS}"
f1133c
+CFLAGS="${CFLAGS} -Wformat-truncation"
f1133c
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[WFLAGS="-Wno-format-truncation"
f1133c
+	AC_MSG_RESULT(yes)],
f1133c
+	[AC_MSG_RESULT(no)])
f1133c
+CFLAGS="${TMPCFLAGS}"
f1133c
+CFLAGS="${CFLAGS} -Wunused-but-set-variable"
f1133c
+AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[WFLAGS="${WFLAGS} -Wno-unused-but-set-variable"
f1133c
+	AC_MSG_RESULT(yes)],
f1133c
+	[AC_MSG_RESULT(no)])
f1133c
+CFLAGS="${TMPCFLAGS}"
f1133c
+AC_SUBST(WFLAGS)
f1133c
+
f1133c
 withval=""
f1133c
 AC_MSG_CHECKING(whether to include arm eabi processor support)
f1133c
 AC_ARG_WITH(arm,
f1133c
diff --git a/src/Makefile.am b/src/Makefile.am
f1133c
index 9c68b42db..2bebf8d50 100644
f1133c
--- a/src/Makefile.am
f1133c
+++ b/src/Makefile.am
f1133c
@@ -25,7 +25,7 @@ CONFIG_CLEAN_FILES = *.rej *.orig
f1133c
 SUBDIRS = test
f1133c
 AM_CPPFLAGS = -I${top_srcdir} -I${top_srcdir}/lib -I${top_srcdir}/src/libev -I${top_srcdir}/auparse -I${top_srcdir}/audisp -I${top_srcdir}/common
f1133c
 sbin_PROGRAMS = auditd auditctl aureport ausearch autrace
f1133c
-AM_CFLAGS = -D_GNU_SOURCE -Wno-pointer-sign
f1133c
+AM_CFLAGS = -D_GNU_SOURCE -Wno-pointer-sign ${WFLAGS}
f1133c
 noinst_HEADERS = auditd-config.h auditd-event.h auditd-listen.h ausearch-llist.h ausearch-options.h auditctl-llist.h aureport-options.h ausearch-parse.h aureport-scan.h ausearch-lookup.h ausearch-int.h auditd-dispatch.h ausearch-string.h ausearch-nvpair.h ausearch-common.h ausearch-avc.h ausearch-time.h ausearch-lol.h auditctl-listing.h ausearch-checkpt.h
f1133c
 
f1133c
 auditd_SOURCES = auditd.c auditd-event.c auditd-config.c auditd-reconfig.c auditd-sendmail.c auditd-dispatch.c