summaryrefslogtreecommitdiffstats
path: root/meta/recipes-connectivity/nfs-utils/nfs-utils/clang-warnings.patch
blob: ff697477b08806464508183b76e53631a3814ccf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
From 7d04566b7b8e57114533360cc4b933a74ed6b314 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Tue, 31 Dec 2019 08:15:34 -0800
Subject: [PATCH] Detect warning options during configure

Certain options maybe compiler specific therefore its better
to detect them before use.

nfs_error copies the format string and appends newline to it
but compiler can forget that it was format string since its not
same fmt string that was passed. Ignore the warning

Wdiscarded-qualifiers is gcc specific and this is no longer needed

Upstream-Status: Pending
Signed-off-by: Khem Raj <raj.khem@gmail.com>

---
 support/nfs/xcommon.c          | 6 ++++++
 support/nfs/xlog.c             | 6 ++++++
 support/nfsidmap/libnfsidmap.c | 3 +++
 utils/exportfs/exportfs.c      | 3 +++
 4 files changed, 18 insertions(+)

diff --git a/support/nfs/xcommon.c b/support/nfs/xcommon.c
index 3989f0bc..ff438c18 100644
--- a/support/nfs/xcommon.c
+++ b/support/nfs/xcommon.c
@@ -98,7 +98,10 @@ nfs_error (const char *fmt, ...) {
 
      fmt2 = xstrconcat2 (fmt, "\n");
      va_start (args, fmt);
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
      vfprintf (stderr, fmt2, args);
+#pragma GCC diagnostic pop
      va_end (args);
      free (fmt2);
 }
@@ -132,7 +135,10 @@ die(int err, const char *fmt, ...) {
 	va_list args;
 
 	va_start(args, fmt);
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
 	vfprintf(stderr, fmt, args);
+#pragma GCC diagnostic pop
 	fprintf(stderr, "\n");
 	va_end(args);
 
diff --git a/support/nfs/xlog.c b/support/nfs/xlog.c
index fa125cef..dc4c9ea1 100644
--- a/support/nfs/xlog.c
+++ b/support/nfs/xlog.c
@@ -178,11 +178,16 @@ xlog_backend(int kind, const char *fmt, va_list args)
 		fprintf(stderr, "%s: ", log_name);
 #endif
 		va_copy(args2, args);
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
 		vfprintf(stderr, fmt, args2);
+#pragma GCC diagnostic pop
 		fprintf(stderr, "\n");
 		va_end(args2);
 	}
 
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
 	if (log_syslog) {
 		switch (kind) {
 		case L_FATAL:
@@ -203,6 +208,7 @@ xlog_backend(int kind, const char *fmt, va_list args)
 			break;
 		}
 	}
+#pragma GCC diagnostic pop
 
 	if (kind == L_FATAL)
 		exit(1);
diff --git a/support/nfsidmap/libnfsidmap.c b/support/nfsidmap/libnfsidmap.c
index 0a912e52..95eb64d2 100644
--- a/support/nfsidmap/libnfsidmap.c
+++ b/support/nfsidmap/libnfsidmap.c
@@ -99,7 +99,10 @@ static void default_logger(const char *fmt, ...)
 	va_list vp;
 
 	va_start(vp, fmt);
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
 	vsyslog(LOG_WARNING, fmt, vp);
+#pragma GCC diagnostic pop
 	va_end(vp);
 }
 
diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c
index b03a047b..eac1ff2a 100644
--- a/utils/exportfs/exportfs.c
+++ b/utils/exportfs/exportfs.c
@@ -646,7 +646,10 @@ dumpopt(char c, char *fmt, ...)
 
 	va_start(ap, fmt);
 	printf("%c", c);
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wformat-nonliteral"
 	vprintf(fmt, ap);
+#pragma GCC diagnostic pop
 	va_end(ap);
 	return ',';
 }