diff mbox

[4/7] Removed format=2 warnings

Message ID 20180220185034.26301-5-steved@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Steve Dickson Feb. 20, 2018, 6:50 p.m. UTC
Added the -Werror=format=2 warning flag
and added couple pragma statments to ignore
the warning where it could not be avoided.

Signed-off-by: Steve Dickson <steved@redhat.com>
---
 configure.ac            | 1 +
 utils/mount/stropts.c   | 2 ++
 utils/nfsstat/nfsstat.c | 2 ++
 3 files changed, 5 insertions(+)
diff mbox

Patch

diff --git a/configure.ac b/configure.ac
index 4f9d8c4..11b994b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -551,6 +551,7 @@  my_am_cflags="\
  -Werror=missing-prototypes \
  -Werror=missing-declarations \
  -Werror=format-overflow=2 \
+ -Werror=format=2 \
 "
 
 AC_SUBST([AM_CFLAGS], ["$my_am_cflags"])
diff --git a/utils/mount/stropts.c b/utils/mount/stropts.c
index 1217823..777de39 100644
--- a/utils/mount/stropts.c
+++ b/utils/mount/stropts.c
@@ -761,9 +761,11 @@  static int nfs_do_mount_v4(struct nfsmount_info *mi,
 			fmt = "vers=%lu.%lu";
 			break;
 		}
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
 		snprintf(version_opt, sizeof(version_opt) - 1,
 			fmt, mi->version.major,
 			mi->version.minor);
+#pragma GCC diagnostic warning "-Wformat-nonliteral"
 
 		if (po_append(options, version_opt) == PO_FAILED) {
 			errno = EINVAL;
diff --git a/utils/nfsstat/nfsstat.c b/utils/nfsstat/nfsstat.c
index 43fe0a8..c779053 100644
--- a/utils/nfsstat/nfsstat.c
+++ b/utils/nfsstat/nfsstat.c
@@ -980,8 +980,10 @@  more_stats:
 			}
 			bufp = buf;
 			for (; curindex < numvals; curindex++) {
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
 				n = sscanf(bufp, fmt, &ip->valptr[curindex],
 						&numconsumed);
+#pragma GCC diagnostic warning "-Wformat-nonliteral"
 				if (n != 1)
 					break;
 				if (is_proc) {