aboutsummaryrefslogtreecommitdiffstats
path: root/meta/recipes-connectivity/nfs-utils/nfs-utils/clang-format-string.patch
blob: 1d693e4142a7cccb86b4dd0d2f95c67eea174099 (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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
Clang comes up with more printf format warnings
Correcting “format string is not a string literal” warning
requires us to declare that parameter is a printf style 
format using the attribute flag

Upstream-Status: Pending

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

Index: nfs-utils-2.3.3/support/include/xcommon.h
===================================================================
--- nfs-utils-2.3.3.orig/support/include/xcommon.h
+++ nfs-utils-2.3.3/support/include/xcommon.h
@@ -27,7 +27,7 @@
 
 /* Functions in sundries.c that are used in mount.c and umount.c  */ 
 char *canonicalize (const char *path);
-void nfs_error (const char *fmt, ...);
+void nfs_error (const char *fmt, ...) __attribute__((__format__ (__printf__, 1, 2)));
 void *xmalloc (size_t size);
 void *xrealloc(void *p, size_t size);
 void xfree(void *);
@@ -36,9 +36,9 @@ char *xstrndup (const char *s, int n);
 char *xstrconcat2 (const char *, const char *);
 char *xstrconcat3 (const char *, const char *, const char *);
 char *xstrconcat4 (const char *, const char *, const char *, const char *);
-void die (int errcode, const char *fmt, ...);
+void die (int errcode, const char *fmt, ...) __attribute__((__format__ (__printf__, 2, 3)));
 
-extern void die(int err, const char *fmt, ...);
+extern void die(int err, const char *fmt, ...) __attribute__((__format__ (__printf__, 2, 3)));
 extern void (*at_die)(void);
 
 /* exit status - bits below are ORed */
Index: nfs-utils-2.3.3/support/include/xlog.h
===================================================================
--- nfs-utils-2.3.3.orig/support/include/xlog.h
+++ nfs-utils-2.3.3/support/include/xlog.h
@@ -43,10 +43,10 @@ void			xlog_config(int fac, int on);
 void			xlog_sconfig(char *, int on);
 void			xlog_from_conffile(char *);
 int			xlog_enabled(int fac);
-void			xlog(int fac, const char *fmt, ...);
-void			xlog_warn(const char *fmt, ...);
-void			xlog_err(const char *fmt, ...);
-void			xlog_errno(int err, const char *fmt, ...);
-void			xlog_backend(int fac, const char *fmt, va_list args);
+void			xlog(int fac, const char *fmt, ...) __attribute__((__format__ (__printf__, 2, 3)));
+void			xlog_warn(const char *fmt, ...) __attribute__((__format__ (__printf__, 1, 2)));
+void			xlog_err(const char *fmt, ...) __attribute__((__format__ (__printf__, 1, 2)));
+void			xlog_errno(int err, const char *fmt, ...) __attribute__((__format__ (__printf__, 2, 3)));
+void			xlog_backend(int fac, const char *fmt, va_list args) __attribute__((__format__ (__printf__, 2, 0)));
 
 #endif /* XLOG_H */
Index: nfs-utils-2.3.3/support/nfs/xcommon.c
===================================================================
--- nfs-utils-2.3.3.orig/support/nfs/xcommon.c
+++ nfs-utils-2.3.3/support/nfs/xcommon.c
@@ -93,7 +93,10 @@ nfs_error (const char *fmt, ...) {
 
      fmt2 = xstrconcat2 (fmt, "\n");
      va_start (args, fmt);
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wformat-nonliteral"
      vfprintf (stderr, fmt2, args);
+#pragma clang diagnostic pop
      va_end (args);
      free (fmt2);
 }
Index: nfs-utils-2.3.3/utils/exportfs/exportfs.c
===================================================================
--- nfs-utils-2.3.3.orig/utils/exportfs/exportfs.c
+++ nfs-utils-2.3.3/utils/exportfs/exportfs.c
@@ -644,6 +644,7 @@ out:
 	return result;
 }
 
+__attribute__((__format__ (__printf__, 2, 3)))
 static char
 dumpopt(char c, char *fmt, ...)
 {
Index: nfs-utils-2.3.3/utils/statd/statd.c
===================================================================
--- nfs-utils-2.3.3.orig/utils/statd/statd.c
+++ nfs-utils-2.3.3/utils/statd/statd.c
@@ -136,7 +136,7 @@ static void log_modes(void)
 	strcat(buf, "TI-RPC ");
 #endif
 
-	xlog_warn(buf);
+	xlog_warn("%s", buf);
 }
 
 /*
Index: nfs-utils-2.3.3/support/nfs/svc_create.c
===================================================================
--- nfs-utils-2.3.3.orig/support/nfs/svc_create.c
+++ nfs-utils-2.3.3/support/nfs/svc_create.c
@@ -184,7 +184,7 @@ svc_create_sock(const struct sockaddr *s
 		type = SOCK_STREAM;
 		break;
 	default:
-		xlog(D_GENERAL, "%s: Unrecognized bind address semantics: %u",
+		xlog(D_GENERAL, "%s: Unrecognized bind address semantics: %lu",
 			__func__, nconf->nc_semantics);
 		return -1;
 	}
Index: nfs-utils-2.3.3/support/nsm/rpc.c
===================================================================
--- nfs-utils-2.3.3.orig/support/nsm/rpc.c
+++ nfs-utils-2.3.3/support/nsm/rpc.c
@@ -182,7 +182,7 @@ nsm_xmit_getport(const int sock, const s
 	uint32_t xid;
 	XDR xdr;
 
-	xlog(D_CALL, "Sending PMAP_GETPORT for %u, %u, udp", program, version);
+	xlog(D_CALL, "Sending PMAP_GETPORT for %lu, %lu, udp", program, version);
 
 	nsm_init_xdrmem(msgbuf, NSM_MAXMSGSIZE, &xdr);
 	xid = nsm_init_rpc_header(PMAPPROG, PMAPVERS,
Index: nfs-utils-2.3.3/utils/mountd/cache.c
===================================================================
--- nfs-utils-2.3.3.orig/utils/mountd/cache.c
+++ nfs-utils-2.3.3/utils/mountd/cache.c
@@ -968,8 +968,7 @@ lookup_export(char *dom, char *path, str
 			} else if (found_type == i && found->m_warned == 0) {
 				xlog(L_WARNING, "%s exported to both %s and %s, "
 				     "arbitrarily choosing options from first",
-				     path, found->m_client->m_hostname, exp->m_client->m_hostname,
-				     dom);
+				     path, found->m_client->m_hostname, exp->m_client->m_hostname);
 				found->m_warned = 1;
 			}
 		}
Index: nfs-utils-2.3.3/utils/mountd/mountd.c
===================================================================
--- nfs-utils-2.3.3.orig/utils/mountd/mountd.c
+++ nfs-utils-2.3.3/utils/mountd/mountd.c
@@ -213,7 +213,7 @@ static void
 sig_hup (int sig)
 {
 	/* don't exit on SIGHUP */
-	xlog (L_NOTICE, "Received SIGHUP... Ignoring.\n", sig);
+	xlog (L_NOTICE, "Received SIGHUP(%d)... Ignoring.\n", sig);
 	return;
 }
 
Index: nfs-utils-2.3.3/utils/statd/rmtcall.c
===================================================================
--- nfs-utils-2.3.3.orig/utils/statd/rmtcall.c
+++ nfs-utils-2.3.3/utils/statd/rmtcall.c
@@ -247,7 +247,7 @@ process_reply(FD_SET_TYPE *rfds)
 		xlog_warn("%s: service %d not registered on localhost",
 			__func__, NL_MY_PROG(lp));
 	} else {
-		xlog(D_GENERAL, "%s: Callback to %s (for %d) succeeded",
+		xlog(D_GENERAL, "%s: Callback to %s (for %s) succeeded",
 			__func__, NL_MY_NAME(lp), NL_MON_NAME(lp));
 	}
 	nlist_free(&notify, lp);
Index: nfs-utils-2.3.3/utils/statd/svc_run.c
===================================================================
--- nfs-utils-2.3.3.orig/utils/statd/svc_run.c
+++ nfs-utils-2.3.3/utils/statd/svc_run.c
@@ -53,6 +53,7 @@
 
 #include <errno.h>
 #include <time.h>
+#include <inttypes.h>
 #include "statd.h"
 #include "notlist.h"
 
@@ -104,8 +105,8 @@ my_svc_run(int sockfd)
 
 			tv.tv_sec  = NL_WHEN(notify) - now;
 			tv.tv_usec = 0;
-			xlog(D_GENERAL, "Waiting for reply... (timeo %d)",
-							tv.tv_sec);
+			xlog(D_GENERAL, "Waiting for reply... (timeo %jd)",
+							(intmax_t)tv.tv_sec);
 			selret = select(FD_SETSIZE, &readfds,
 				(void *) 0, (void *) 0, &tv);
 		} else {