03e484
From 10f48326f30ae89bea01124bdbab4702a21f3655 Mon Sep 17 00:00:00 2001
03e484
From: Miroslav Rezanina <mrezanin@redhat.com>
03e484
Date: Thu, 3 Dec 2020 11:17:02 -0500
03e484
Subject: [PATCH] Suppress prototype warning for nss headers
03e484
MIME-Version: 1.0
03e484
Content-Type: text/plain; charset=UTF-8
03e484
Content-Transfer-Encoding: 8bit
03e484
03e484
RH-Author: Miroslav Rezanina <mrezanin@redhat.com>
03e484
Message-id: <20201203111702.215084-1-mrezanin@redhat.com>
03e484
Patchwork-id: 100201
03e484
O-Subject: [RHEL-7.9.z qemu-kvm PATCH] Suppress prototype warning for nss headers
03e484
Bugzilla: 1884997
03e484
RH-Acked-by: Thomas Huth <thuth@redhat.com>
03e484
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
03e484
RH-Acked-by: Jon Maloy <jmaloy@redhat.com>
03e484
03e484
From: Miroslav Rezanina <mrezanin@redhat.com>
03e484
03e484
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1884997
03e484
Brew: https://brewweb.engineering.redhat.com/brew/taskinfo?taskID=33460150
03e484
branch: rhel79/master
03e484
Upstream: n/a
03e484
03e484
Rebase of nss introduced following warning when using it for building qemu-kvm:
03e484
03e484
/usr/include/nss3/pk11pub.h:951:1: error: function declaration isn’t a prototype [-Werror=strict-prototypes]
03e484
int SECMOD_GetSystemFIPSEnabled();
03e484
03e484
This issue is tracked by https://bugzilla.redhat.com/show_bug.cgi?id=1885321. However,
03e484
this issue is not important enough to fix (as discussed in the bugzilla).
03e484
03e484
We have to hack qemu-kvm to live with this warning. To do it we add following hacks:
03e484
03e484
1) We disable using -Werror for nss test in configure. This allows configure to pass.
03e484
03e484
2) We disable -Werror=scrict-prototypes when including nss headers. This allows build to pass.
03e484
03e484
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
03e484
Signed-off-by: Jon Maloy <jmaloy.redhat.com>
03e484
---
03e484
 configure                  | 13 ++++++-------
03e484
 libcacard/vcard_emul_nss.c |  8 ++++++++
03e484
 2 files changed, 14 insertions(+), 7 deletions(-)
03e484
03e484
diff --git a/configure b/configure
03e484
index 34e3accfdd..77c2f0a438 100755
03e484
--- a/configure
03e484
+++ b/configure
03e484
@@ -3246,13 +3246,11 @@ EOF
03e484
     libcacard_libs="$($pkg_config --libs nss 2>/dev/null) $glib_libs"
03e484
     libcacard_cflags="$($pkg_config --cflags nss 2>/dev/null) $glib_cflags"
03e484
     test_cflags="$libcacard_cflags"
03e484
-    # The header files in nss < 3.13.3 have a bug which causes them to
03e484
-    # emit a warning. If we're going to compile QEMU with -Werror, then
03e484
-    # test that the headers don't have this bug. Otherwise we would pass
03e484
-    # the configure test but fail to compile QEMU later.
03e484
-    if test "$werror" = "yes"; then
03e484
-        test_cflags="-Werror $test_cflags"
03e484
-    fi
03e484
+    # nss > 3.53 generates warning when including it's headers. This breaks the
03e484
+    # build so we have to disable -Werror for build test.
03e484
+    # See https://bugzilla.redhat.com/show_bug.cgi?id=1885321
03e484
+    old_werror=$werror
03e484
+    werror=no
03e484
     if test -n "$libtool" &&
03e484
             $pkg_config --atleast-version=3.12.8 nss >/dev/null 2>&1 && \
03e484
       compile_prog "$test_cflags" "$libcacard_libs"; then
03e484
@@ -3266,6 +3264,7 @@ EOF
03e484
         fi
03e484
         smartcard_nss="no"
03e484
     fi
03e484
+    werror=$old_werror
03e484
 fi
03e484
 
03e484
 # check for libusb
03e484
diff --git a/libcacard/vcard_emul_nss.c b/libcacard/vcard_emul_nss.c
03e484
index 1a3e5683bc..f1aa51943b 100644
03e484
--- a/libcacard/vcard_emul_nss.c
03e484
+++ b/libcacard/vcard_emul_nss.c
03e484
@@ -17,8 +17,16 @@
03e484
 /* avoid including prototypes.h that redefines uint32 */
03e484
 #define NO_NSPR_10_SUPPORT
03e484
 
03e484
+/*
03e484
+ * nss > 3.53 genererates prototype warning when including headers so we can't
03e484
+ * treat this warning ass error to allow build.
03e484
+ * See https://bugzilla.redhat.com/show_bug.cgi?id=1885321
03e484
+ */
03e484
+#pragma GCC diagnostic push
03e484
+#pragma GCC diagnostic ignored "-Wstrict-prototypes"
03e484
 #include <nss.h>
03e484
 #include <pk11pub.h>
03e484
+#pragma GCC diagnostic pop
03e484
 #include <cert.h>
03e484
 #include <key.h>
03e484
 #include <secmod.h>
03e484
-- 
03e484
2.18.2
03e484