Project

General

Profile

Bug #4309 » libzfs_additional_casts_for_printf.txt

sean bruno, 2013-11-11 06:16 PM

 
1
Index: cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c
2
===================================================================
3
--- cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c	(revision 257998)
4
+++ cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c	(working copy)
5
@@ -2134,7 +2134,8 @@
6
 			    localtime_r(&time, &t) == NULL ||
7
 			    strftime(propbuf, proplen, "%a %b %e %k:%M %Y",
8
 			    &t) == 0)
9
-				(void) snprintf(propbuf, proplen, "%llu", val);
10
+				(void) snprintf(propbuf, proplen, "%llu",
11
+						(u_longlong_t)val);
12
 		}
13
 		break;
14
 
15
@@ -2648,7 +2649,8 @@
16
 		return (err);
17
 
18
 	if (literal) {
19
-		(void) snprintf(propbuf, proplen, "%llu", propvalue);
20
+		(void) snprintf(propbuf, proplen, "%llu",
21
+				(u_longlong_t)propvalue);
22
 	} else if (propvalue == 0 &&
23
 	    (type == ZFS_PROP_USERQUOTA || type == ZFS_PROP_GROUPQUOTA)) {
24
 		(void) strlcpy(propbuf, "none", proplen);
25
@@ -2705,7 +2707,8 @@
26
 		return (err);
27
 
28
 	if (literal) {
29
-		(void) snprintf(propbuf, proplen, "%llu", propvalue);
30
+		(void) snprintf(propbuf, proplen, "%llu",
31
+				(u_longlong_t)propvalue);
32
 	} else {
33
 		zfs_nicenum(propvalue, propbuf, proplen);
34
 	}
35
Index: cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c
36
===================================================================
37
--- cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c	(revision 257998)
38
+++ cddl/contrib/opensolaris/lib/libzfs/common/libzfs_diff.c	(working copy)
39
@@ -116,7 +116,7 @@
40
 		(void) snprintf(di->errbuf, sizeof (di->errbuf),
41
 		    dgettext(TEXT_DOMAIN,
42
 		    "Unable to determine path or stats for "
43
-		    "object %lld in %s"), obj, dsname);
44
+		    "object %lld in %s"), (longlong_t)obj, dsname);
45
 		return (-1);
46
 	}
47
 }
48
@@ -410,7 +410,7 @@
49
 			(void) snprintf(di->errbuf, sizeof (di->errbuf),
50
 			    dgettext(TEXT_DOMAIN,
51
 			    "next allocated object (> %lld) find failure"),
52
-			    zc.zc_obj);
53
+			    (longlong_t)(zc.zc_obj));
54
 			di->zerr = errno;
55
 			break;
56
 		}
57
Index: cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c
58
===================================================================
59
--- cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c	(revision 257998)
60
+++ cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c	(working copy)
61
@@ -261,7 +261,8 @@
62
 
63
 		case ZPOOL_PROP_GUID:
64
 			intval = zpool_get_prop_int(zhp, prop, &src);
65
-			(void) snprintf(buf, len, "%llu", intval);
66
+			(void) snprintf(buf, len, "%llu",
67
+					(u_longlong_t)intval);
68
 			break;
69
 
70
 		case ZPOOL_PROP_ALTROOT:
71
@@ -337,7 +338,8 @@
72
 			}
73
 			/* FALLTHROUGH */
74
 		default:
75
-			(void) snprintf(buf, len, "%llu", intval);
76
+			(void) snprintf(buf, len, "%llu",
77
+					(u_longlong_t)intval);
78
 		}
79
 		break;
80
 
81
@@ -1474,13 +1476,13 @@
82
 			(void) printf(dgettext(TEXT_DOMAIN,
83
 			    "%s approximately %lld "),
84
 			    dryrun ? "Would discard" : "Discarded",
85
-			    (loss + 30) / 60);
86
+			    (longlong_t)(loss + 30) / 60);
87
 			(void) printf(dgettext(TEXT_DOMAIN,
88
 			    "minutes of transactions.\n"));
89
 		} else if (loss > 0) {
90
 			(void) printf(dgettext(TEXT_DOMAIN,
91
 			    "%s approximately %lld "),
92
-			    dryrun ? "Would discard" : "Discarded", loss);
93
+			    dryrun ? "Would discard" : "Discarded", (longlong_t)loss);
94
 			(void) printf(dgettext(TEXT_DOMAIN,
95
 			    "seconds of transactions.\n"));
96
 		}
97
@@ -1534,11 +1536,13 @@
98
 	if (loss > 120) {
99
 		(void) printf(dgettext(TEXT_DOMAIN,
100
 		    "Approximately %lld minutes of data\n"
101
-		    "\tmust be discarded, irreversibly.  "), (loss + 30) / 60);
102
+		    "\tmust be discarded, irreversibly.  "),
103
+		    (longlong_t)(loss + 30) / 60);
104
 	} else if (loss > 0) {
105
 		(void) printf(dgettext(TEXT_DOMAIN,
106
 		    "Approximately %lld seconds of data\n"
107
-		    "\tmust be discarded, irreversibly.  "), loss);
108
+		    "\tmust be discarded, irreversibly.  "),
109
+		    (longlong_t)loss);
110
 	}
111
 	if (edata != 0 && edata != UINT64_MAX) {
112
 		if (edata == 1) {
113
@@ -2524,7 +2528,7 @@
114
 	libzfs_handle_t *hdl = zhp->zpool_hdl;
115
 
116
 	(void) snprintf(msg, sizeof (msg),
117
-	    dgettext(TEXT_DOMAIN, "cannot fault %llu"), guid);
118
+	    dgettext(TEXT_DOMAIN, "cannot fault %llu"), (u_longlong_t)guid);
119
 
120
 	(void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name));
121
 	zc.zc_guid = guid;
122
@@ -2559,7 +2563,7 @@
123
 	libzfs_handle_t *hdl = zhp->zpool_hdl;
124
 
125
 	(void) snprintf(msg, sizeof (msg),
126
-	    dgettext(TEXT_DOMAIN, "cannot degrade %llu"), guid);
127
+	    dgettext(TEXT_DOMAIN, "cannot degrade %llu"), (u_longlong_t)guid);
128
 
129
 	(void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name));
130
 	zc.zc_guid = guid;
131
@@ -3228,7 +3232,7 @@
132
 
133
 	(void) snprintf(msg, sizeof (msg),
134
 	    dgettext(TEXT_DOMAIN, "cannot clear errors for %llx"),
135
-	    guid);
136
+	    (longlong_t)guid);
137
 
138
 	(void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name));
139
 	zc.zc_guid = guid;
140
@@ -3793,7 +3797,8 @@
141
 
142
 	if (dsobj == 0) {
143
 		/* special case for the MOS */
144
-		(void) snprintf(pathname, len, "<metadata>:<0x%llx>", obj);
145
+		(void) snprintf(pathname, len, "<metadata>:<0x%llx>",
146
+				(longlong_t)obj);
147
 		return;
148
 	}
149
 
150
@@ -3804,7 +3809,7 @@
151
 	    ZFS_IOC_DSOBJ_TO_DSNAME, &zc) != 0) {
152
 		/* just write out a path of two object numbers */
153
 		(void) snprintf(pathname, len, "<0x%llx>:<0x%llx>",
154
-		    dsobj, obj);
155
+		    (longlong_t)dsobj, (longlong_t)obj);
156
 		return;
157
 	}
158
 	(void) strlcpy(dsname, zc.zc_value, sizeof (dsname));
159
@@ -3825,7 +3830,8 @@
160
 			    dsname, zc.zc_value);
161
 		}
162
 	} else {
163
-		(void) snprintf(pathname, len, "%s:<0x%llx>", dsname, obj);
164
+		(void) snprintf(pathname, len, "%s:<0x%llx>", dsname,
165
+				(longlong_t)obj);
166
 	}
167
 	free(mntpnt);
168
 }
169
Index: cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c
170
===================================================================
171
--- cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c	(revision 257998)
172
+++ cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c	(working copy)
173
@@ -2083,7 +2083,8 @@
174
 					needagain = B_TRUE;
175
 				else
176
 					progress = B_TRUE;
177
-				sprintf(guidname, "%lu", thisguid);
178
+				sprintf(guidname, "%llu",
179
+					(u_longlong_t)thisguid);
180
 				nvlist_add_boolean(deleted, guidname);
181
 				continue;
182
 			}
183
@@ -2140,7 +2141,7 @@
184
 				needagain = B_TRUE;
185
 			else
186
 				progress = B_TRUE;
187
-			sprintf(guidname, "%lu", parent_fromsnap_guid);
188
+			sprintf(guidname, "%llu", (u_longlong_t)parent_fromsnap_guid);
189
 			nvlist_add_boolean(deleted, guidname);
190
 			continue;
191
 		}
192
@@ -2173,7 +2174,7 @@
193
 		if (stream_parent_fromsnap_guid != 0 &&
194
                     parent_fromsnap_guid != 0 &&
195
                     stream_parent_fromsnap_guid != parent_fromsnap_guid) {
196
-			sprintf(guidname, "%lu", parent_fromsnap_guid);
197
+			sprintf(guidname, "%ju", (uintmax_t)parent_fromsnap_guid);
198
 			if (nvlist_exists(deleted, guidname)) {
199
 				progress = B_TRUE;
200
 				needagain = B_TRUE;
201
Index: cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c
202
===================================================================
203
--- cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c	(revision 257998)
204
+++ cddl/contrib/opensolaris/lib/libzfs/common/libzfs_util.c	(working copy)
205
@@ -586,13 +586,13 @@
206
 	u = " KMGTPE"[index];
207
 
208
 	if (index == 0) {
209
-		(void) snprintf(buf, buflen, "%llu", n);
210
+		(void) snprintf(buf, buflen, "%llu", (u_longlong_t)n);
211
 	} else if ((num & ((1ULL << 10 * index) - 1)) == 0) {
212
 		/*
213
 		 * If this is an even multiple of the base, always display
214
 		 * without any decimal precision.
215
 		 */
216
-		(void) snprintf(buf, buflen, "%llu%c", n, u);
217
+		(void) snprintf(buf, buflen, "%llu%c", (u_longlong_t)n, u);
218
 	} else {
219
 		/*
220
 		 * We want to choose a precision that reflects the best choice
(2-2/2)