Skip to content

Commit b8864a2

Browse files
committed
Fix gcc cast warnings
Gcc -Wall warn: 'lacks a cast' Gcc -Wall warn: 'comparison between pointer and integer' Signed-off-by: Brian Behlendorf <[email protected]>
1 parent d6320dd commit b8864a2

File tree

16 files changed

+90
-77
lines changed

16 files changed

+90
-77
lines changed

cmd/zdb/zdb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -874,8 +874,8 @@ dump_history(spa_t *spa)
874874
(void) snprintf(internalstr,
875875
sizeof (internalstr),
876876
"[internal %s txg:%lld] %s",
877-
zfs_history_event_names[ievent], txg,
878-
intstr);
877+
zfs_history_event_names[ievent],
878+
(longlong_t)txg, intstr);
879879
cmd = internalstr;
880880
}
881881
tsec = time;

cmd/zfs/zfs_main.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1682,7 +1682,7 @@ upgrade_set_callback(zfs_handle_t *zhp, void *data)
16821682
if (version < cb->cb_version) {
16831683
char verstr[16];
16841684
(void) snprintf(verstr, sizeof (verstr),
1685-
"%llu", cb->cb_version);
1685+
"%llu", (u_longlong_t)cb->cb_version);
16861686
if (cb->cb_lastfs[0] && !same_pool(zhp, cb->cb_lastfs)) {
16871687
/*
16881688
* If they did "zfs upgrade -a", then we could
@@ -1720,7 +1720,7 @@ zfs_do_upgrade(int argc, char **argv)
17201720
boolean_t showversions = B_FALSE;
17211721
int ret;
17221722
upgrade_cbdata_t cb = { 0 };
1723-
char c;
1723+
signed char c;
17241724
int flags = ZFS_ITER_ARGS_CAN_BE_PATHS;
17251725

17261726
/* check options */
@@ -1789,11 +1789,11 @@ zfs_do_upgrade(int argc, char **argv)
17891789
ret = zfs_for_each(argc, argv, flags, ZFS_TYPE_FILESYSTEM,
17901790
NULL, NULL, 0, upgrade_set_callback, &cb);
17911791
(void) printf(gettext("%llu filesystems upgraded\n"),
1792-
cb.cb_numupgraded);
1792+
(u_longlong_t)cb.cb_numupgraded);
17931793
if (cb.cb_numsamegraded) {
17941794
(void) printf(gettext("%llu filesystems already at "
17951795
"this version\n"),
1796-
cb.cb_numsamegraded);
1796+
(u_longlong_t)cb.cb_numsamegraded);
17971797
}
17981798
if (cb.cb_numfailed != 0)
17991799
ret = 1;
@@ -1957,9 +1957,9 @@ print_header(zprop_list_t *pl)
19571957
if (pl->pl_next == NULL && !right_justify)
19581958
(void) printf("%s", header);
19591959
else if (right_justify)
1960-
(void) printf("%*s", pl->pl_width, header);
1960+
(void) printf("%*s", (int)pl->pl_width, header);
19611961
else
1962-
(void) printf("%-*s", pl->pl_width, header);
1962+
(void) printf("%-*s", (int)pl->pl_width, header);
19631963
}
19641964

19651965
(void) printf("\n");
@@ -2550,7 +2550,7 @@ zfs_do_set(int argc, char **argv)
25502550
usage(B_FALSE);
25512551
}
25522552

2553-
ret = zfs_for_each(argc - 2, argv + 2, NULL,
2553+
ret = zfs_for_each(argc - 2, argv + 2, 0,
25542554
ZFS_TYPE_DATASET, NULL, NULL, 0, set_callback, &cb);
25552555

25562556
return (ret);
@@ -2567,7 +2567,7 @@ zfs_do_snapshot(int argc, char **argv)
25672567
{
25682568
boolean_t recursive = B_FALSE;
25692569
int ret;
2570-
char c;
2570+
signed char c;
25712571
nvlist_t *props;
25722572

25732573
if (nvlist_alloc(&props, NV_UNIQUE_NAME, 0) != 0)

cmd/zpool/zpool_main.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2438,9 +2438,9 @@ print_header(zprop_list_t *pl)
24382438
if (pl->pl_next == NULL && !right_justify)
24392439
(void) printf("%s", header);
24402440
else if (right_justify)
2441-
(void) printf("%*s", pl->pl_width, header);
2441+
(void) printf("%*s", (int)pl->pl_width, header);
24422442
else
2443-
(void) printf("%-*s", pl->pl_width, header);
2443+
(void) printf("%-*s", (int)pl->pl_width, header);
24442444
}
24452445

24462446
(void) printf("\n");
@@ -3906,7 +3906,7 @@ upgrade_one(zpool_handle_t *zhp, void *data)
39063906
if (cur_version > cbp->cb_version) {
39073907
(void) printf(gettext("Pool '%s' is already formatted "
39083908
"using more current version '%llu'.\n"),
3909-
zpool_get_name(zhp), cur_version);
3909+
zpool_get_name(zhp), (u_longlong_t) cur_version);
39103910
return (0);
39113911
}
39123912
if (cur_version == cbp->cb_version) {
@@ -4147,8 +4147,8 @@ get_history_one(zpool_handle_t *zhp, void *data)
41474147
continue;
41484148
(void) snprintf(internalstr,
41494149
sizeof (internalstr),
4150-
"[internal %s txg:%lld] %s",
4151-
zfs_history_event_names[ievent], txg,
4150+
"[internal %s txg:%llu] %s",
4151+
zfs_history_event_names[ievent], (u_longlong_t)txg,
41524152
pathstr);
41534153
cmdstr = internalstr;
41544154
}

cmd/ztest/ztest.c

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2022,7 +2022,7 @@ ztest_od_init(ztest_od_t *od, uint64_t id, char *tag, uint64_t index,
20222022
od->od_gen = 0;
20232023

20242024
(void) snprintf(od->od_name, sizeof (od->od_name), "%s(%lld)[%llu]",
2025-
tag, (int64_t)id, index);
2025+
tag, (longlong_t)id, (u_longlong_t)index);
20262026
}
20272027

20282028
/*
@@ -3042,11 +3042,16 @@ ztest_dsl_dataset_cleanup(char *osname, uint64_t id)
30423042
char snap3name[MAXNAMELEN];
30433043
int error;
30443044

3045-
(void) snprintf(snap1name, MAXNAMELEN, "%s@s1_%llu", osname, id);
3046-
(void) snprintf(clone1name, MAXNAMELEN, "%s/c1_%llu", osname, id);
3047-
(void) snprintf(snap2name, MAXNAMELEN, "%s@s2_%llu", clone1name, id);
3048-
(void) snprintf(clone2name, MAXNAMELEN, "%s/c2_%llu", osname, id);
3049-
(void) snprintf(snap3name, MAXNAMELEN, "%s@s3_%llu", clone1name, id);
3045+
(void) snprintf(snap1name, MAXNAMELEN, "%s@s1_%llu",
3046+
osname, (u_longlong_t)id);
3047+
(void) snprintf(clone1name, MAXNAMELEN, "%s/c1_%llu",
3048+
osname, (u_longlong_t)id);
3049+
(void) snprintf(snap2name, MAXNAMELEN, "%s@s2_%llu",
3050+
clone1name, (u_longlong_t)id);
3051+
(void) snprintf(clone2name, MAXNAMELEN, "%s/c2_%llu",
3052+
osname, (u_longlong_t)id);
3053+
(void) snprintf(snap3name, MAXNAMELEN, "%s@s3_%llu",
3054+
clone1name, (u_longlong_t)id);
30503055

30513056
error = dmu_objset_destroy(clone2name, B_FALSE);
30523057
if (error && error != ENOENT)
@@ -3086,11 +3091,16 @@ ztest_dsl_dataset_promote_busy(ztest_ds_t *zd, uint64_t id)
30863091

30873092
ztest_dsl_dataset_cleanup(osname, id);
30883093

3089-
(void) snprintf(snap1name, MAXNAMELEN, "%s@s1_%llu", osname, id);
3090-
(void) snprintf(clone1name, MAXNAMELEN, "%s/c1_%llu", osname, id);
3091-
(void) snprintf(snap2name, MAXNAMELEN, "%s@s2_%llu", clone1name, id);
3092-
(void) snprintf(clone2name, MAXNAMELEN, "%s/c2_%llu", osname, id);
3093-
(void) snprintf(snap3name, MAXNAMELEN, "%s@s3_%llu", clone1name, id);
3094+
(void) snprintf(snap1name, MAXNAMELEN, "%s@s1_%llu",
3095+
osname, (u_longlong_t)id);
3096+
(void) snprintf(clone1name, MAXNAMELEN, "%s/c1_%llu",
3097+
osname, (u_longlong_t)id);
3098+
(void) snprintf(snap2name, MAXNAMELEN, "%s@s2_%llu",
3099+
clone1name, (u_longlong_t)id);
3100+
(void) snprintf(clone2name, MAXNAMELEN, "%s/c2_%llu",
3101+
osname, (u_longlong_t)id);
3102+
(void) snprintf(snap3name, MAXNAMELEN, "%s@s3_%llu",
3103+
clone1name, (u_longlong_t)id);
30943104

30953105
error = dmu_objset_snapshot(osname, strchr(snap1name, '@')+1,
30963106
NULL, NULL, B_FALSE, B_FALSE, -1);
@@ -3912,7 +3922,7 @@ ztest_fzap(ztest_ds_t *zd, uint64_t id)
39123922
int error;
39133923

39143924
(void) snprintf(name, sizeof (name), "fzap-%llu-%llu",
3915-
id, value);
3925+
(u_longlong_t)id, (u_longlong_t)value);
39163926

39173927
tx = dmu_tx_create(os);
39183928
dmu_tx_hold_zap(tx, object, B_TRUE, name);

lib/libnvpair/libnvpair.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ NVLIST_PRTFUNC(int32, int32_t, int32_t, "%d")
210210
NVLIST_PRTFUNC(uint32, uint32_t, uint32_t, "0x%x")
211211
NVLIST_PRTFUNC(int64, int64_t, longlong_t, "%lld")
212212
NVLIST_PRTFUNC(uint64, uint64_t, u_longlong_t, "0x%llx")
213-
NVLIST_PRTFUNC(double, double, double, "0x%llf")
213+
NVLIST_PRTFUNC(double, double, double, "0x%f")
214214
NVLIST_PRTFUNC(string, char *, char *, "%s")
215215
NVLIST_PRTFUNC(hrtime, hrtime_t, hrtime_t, "0x%llx")
216216

@@ -1216,7 +1216,7 @@ nvpair_value_match_regex(nvpair_t *nvp, int ai,
12161216
boolean_t val, val_arg;
12171217

12181218
/* scanf boolean_t from value and check for match */
1219-
sr = sscanf(value, "%"SCNi32, &val_arg);
1219+
sr = sscanf(value, "%"SCNi32, (int32_t *)&val_arg);
12201220
if ((sr == 1) &&
12211221
(nvpair_value_boolean_value(nvp, &val) == 0) &&
12221222
(val == val_arg))
@@ -1227,7 +1227,7 @@ nvpair_value_match_regex(nvpair_t *nvp, int ai,
12271227
boolean_t *val_array, val_arg;
12281228

12291229
/* check indexed value of array for match */
1230-
sr = sscanf(value, "%"SCNi32, &val_arg);
1230+
sr = sscanf(value, "%"SCNi32, (int32_t *)&val_arg);
12311231
if ((sr == 1) &&
12321232
(nvpair_value_boolean_array(nvp,
12331233
&val_array, &a_len) == 0) &&

lib/libzfs/libzfs_dataset.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1906,7 +1906,7 @@ zfs_prop_get(zfs_handle_t *zhp, zfs_prop_t prop, char *propbuf, size_t proplen,
19061906
localtime_r(&time, &t) == NULL ||
19071907
strftime(propbuf, proplen, "%a %b %e %k:%M %Y",
19081908
&t) == 0)
1909-
(void) snprintf(propbuf, proplen, "%llu", val);
1909+
(void) snprintf(propbuf, proplen, "%llu", (u_longlong_t) val);
19101910
}
19111911
break;
19121912

@@ -2391,7 +2391,8 @@ zfs_prop_get_userquota(zfs_handle_t *zhp, const char *propname,
23912391
return (err);
23922392

23932393
if (literal) {
2394-
(void) snprintf(propbuf, proplen, "%llu", propvalue);
2394+
(void) snprintf(propbuf, proplen, "%llu",
2395+
(u_longlong_t)propvalue);
23952396
} else if (propvalue == 0 &&
23962397
(type == ZFS_PROP_USERQUOTA || type == ZFS_PROP_GROUPQUOTA)) {
23972398
(void) strlcpy(propbuf, "none", proplen);

lib/libzfs/libzfs_diff.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ get_stats_for_obj(differ_info_t *di, const char *dsname, uint64_t obj,
118118
(void) snprintf(di->errbuf, sizeof (di->errbuf),
119119
dgettext(TEXT_DOMAIN,
120120
"Unable to determine path or stats for "
121-
"object %lld in %s"), obj, dsname);
121+
"object %lld in %s"), (longlong_t)obj, dsname);
122122
return (-1);
123123
}
124124
}
@@ -406,7 +406,7 @@ write_free_diffs(FILE *fp, differ_info_t *di, dmu_diff_record_t *dr)
406406
(void) snprintf(di->errbuf, sizeof (di->errbuf),
407407
dgettext(TEXT_DOMAIN,
408408
"next allocated object (> %lld) find failure"),
409-
zc.zc_obj);
409+
(longlong_t)zc.zc_obj);
410410
di->zerr = errno;
411411
break;
412412
}

lib/libzfs/libzfs_pool.c

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ zpool_get_prop(zpool_handle_t *zhp, zpool_prop_t prop, char *buf, size_t len,
228228

229229
case ZPOOL_PROP_GUID:
230230
intval = zpool_get_prop_int(zhp, prop, &src);
231-
(void) snprintf(buf, len, "%llu", intval);
231+
(void) snprintf(buf, len, "%llu", (u_longlong_t)intval);
232232
break;
233233

234234
case ZPOOL_PROP_ALTROOT:
@@ -295,7 +295,7 @@ zpool_get_prop(zpool_handle_t *zhp, zpool_prop_t prop, char *buf, size_t len,
295295
vs->vs_aux), len);
296296
break;
297297
default:
298-
(void) snprintf(buf, len, "%llu", intval);
298+
(void) snprintf(buf, len, "%llu", (u_longlong_t)intval);
299299
}
300300
break;
301301

@@ -1238,7 +1238,7 @@ zpool_rewind_exclaim(libzfs_handle_t *hdl, const char *name, boolean_t dryrun,
12381238
(void) nvlist_lookup_int64(nv, ZPOOL_CONFIG_REWIND_TIME, &loss);
12391239

12401240
if (localtime_r((time_t *)&rewindto, &t) != NULL &&
1241-
strftime(timestr, 128, 0, &t) != 0) {
1241+
strftime(timestr, 128, "%c", &t) != 0) {
12421242
if (dryrun) {
12431243
(void) printf(dgettext(TEXT_DOMAIN,
12441244
"Would be able to return %s "
@@ -1253,13 +1253,14 @@ zpool_rewind_exclaim(libzfs_handle_t *hdl, const char *name, boolean_t dryrun,
12531253
(void) printf(dgettext(TEXT_DOMAIN,
12541254
"%s approximately %lld "),
12551255
dryrun ? "Would discard" : "Discarded",
1256-
(loss + 30) / 60);
1256+
((longlong_t)loss + 30) / 60);
12571257
(void) printf(dgettext(TEXT_DOMAIN,
12581258
"minutes of transactions.\n"));
12591259
} else if (loss > 0) {
12601260
(void) printf(dgettext(TEXT_DOMAIN,
12611261
"%s approximately %lld "),
1262-
dryrun ? "Would discard" : "Discarded", loss);
1262+
dryrun ? "Would discard" : "Discarded",
1263+
(longlong_t)loss);
12631264
(void) printf(dgettext(TEXT_DOMAIN,
12641265
"seconds of transactions.\n"));
12651266
}
@@ -1298,7 +1299,7 @@ zpool_explain_recover(libzfs_handle_t *hdl, const char *name, int reason,
12981299
"Recovery is possible, but will result in some data loss.\n"));
12991300

13001301
if (localtime_r((time_t *)&rewindto, &t) != NULL &&
1301-
strftime(timestr, 128, 0, &t) != 0) {
1302+
strftime(timestr, 128, "%c", &t) != 0) {
13021303
(void) printf(dgettext(TEXT_DOMAIN,
13031304
"\tReturning the pool to its state as of %s\n"
13041305
"\tshould correct the problem. "),
@@ -1312,11 +1313,13 @@ zpool_explain_recover(libzfs_handle_t *hdl, const char *name, int reason,
13121313
if (loss > 120) {
13131314
(void) printf(dgettext(TEXT_DOMAIN,
13141315
"Approximately %lld minutes of data\n"
1315-
"\tmust be discarded, irreversibly. "), (loss + 30) / 60);
1316+
"\tmust be discarded, irreversibly. "),
1317+
((longlong_t)loss + 30) / 60);
13161318
} else if (loss > 0) {
13171319
(void) printf(dgettext(TEXT_DOMAIN,
13181320
"Approximately %lld seconds of data\n"
1319-
"\tmust be discarded, irreversibly. "), loss);
1321+
"\tmust be discarded, irreversibly. "),
1322+
(longlong_t)loss);
13201323
}
13211324
if (edata != 0 && edata != UINT64_MAX) {
13221325
if (edata == 1) {
@@ -2260,7 +2263,7 @@ zpool_vdev_fault(zpool_handle_t *zhp, uint64_t guid, vdev_aux_t aux)
22602263
libzfs_handle_t *hdl = zhp->zpool_hdl;
22612264

22622265
(void) snprintf(msg, sizeof (msg),
2263-
dgettext(TEXT_DOMAIN, "cannot fault %llu"), guid);
2266+
dgettext(TEXT_DOMAIN, "cannot fault %llu"), (u_longlong_t)guid);
22642267

22652268
(void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name));
22662269
zc.zc_guid = guid;
@@ -2295,7 +2298,7 @@ zpool_vdev_degrade(zpool_handle_t *zhp, uint64_t guid, vdev_aux_t aux)
22952298
libzfs_handle_t *hdl = zhp->zpool_hdl;
22962299

22972300
(void) snprintf(msg, sizeof (msg),
2298-
dgettext(TEXT_DOMAIN, "cannot degrade %llu"), guid);
2301+
dgettext(TEXT_DOMAIN, "cannot degrade %llu"), (u_longlong_t)guid);
22992302

23002303
(void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name));
23012304
zc.zc_guid = guid;
@@ -2954,7 +2957,7 @@ zpool_vdev_clear(zpool_handle_t *zhp, uint64_t guid)
29542957

29552958
(void) snprintf(msg, sizeof (msg),
29562959
dgettext(TEXT_DOMAIN, "cannot clear errors for %llx"),
2957-
guid);
2960+
(u_longlong_t)guid);
29582961

29592962
(void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name));
29602963
zc.zc_guid = guid;
@@ -3475,7 +3478,7 @@ zpool_obj_to_path(zpool_handle_t *zhp, uint64_t dsobj, uint64_t obj,
34753478

34763479
if (dsobj == 0) {
34773480
/* special case for the MOS */
3478-
(void) snprintf(pathname, len, "<metadata>:<0x%llx>", obj);
3481+
(void) snprintf(pathname, len, "<metadata>:<0x%llx>", (longlong_t)obj);
34793482
return;
34803483
}
34813484

@@ -3486,7 +3489,7 @@ zpool_obj_to_path(zpool_handle_t *zhp, uint64_t dsobj, uint64_t obj,
34863489
ZFS_IOC_DSOBJ_TO_DSNAME, &zc) != 0) {
34873490
/* just write out a path of two object numbers */
34883491
(void) snprintf(pathname, len, "<0x%llx>:<0x%llx>",
3489-
dsobj, obj);
3492+
(longlong_t)dsobj, (longlong_t)obj);
34903493
return;
34913494
}
34923495
(void) strlcpy(dsname, zc.zc_value, sizeof (dsname));
@@ -3507,7 +3510,7 @@ zpool_obj_to_path(zpool_handle_t *zhp, uint64_t dsobj, uint64_t obj,
35073510
dsname, zc.zc_value);
35083511
}
35093512
} else {
3510-
(void) snprintf(pathname, len, "%s:<0x%llx>", dsname, obj);
3513+
(void) snprintf(pathname, len, "%s:<0x%llx>", dsname, (longlong_t)obj);
35113514
}
35123515
free(mntpnt);
35133516
}

lib/libzfs/libzfs_sendrecv.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1571,7 +1571,7 @@ recv_rename(libzfs_handle_t *hdl, const char *name, const char *tryname,
15711571

15721572
(void) strncpy(newname, name, baselen);
15731573
(void) snprintf(newname+baselen, ZFS_MAXNAMELEN-baselen,
1574-
"recv-%u-%u", getpid(), seq);
1574+
"recv-%ld-%u", (long) getpid(), seq);
15751575
(void) strlcpy(zc.zc_value, newname, sizeof (zc.zc_value));
15761576

15771577
if (flags.verbose) {
@@ -2490,7 +2490,7 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
24902490
(void) printf("found clone origin %s\n", zc.zc_string);
24912491
}
24922492

2493-
stream_wantsnewfs = (drrb->drr_fromguid == NULL ||
2493+
stream_wantsnewfs = (drrb->drr_fromguid == 0 ||
24942494
(drrb->drr_flags & DRR_FLAG_CLONE));
24952495

24962496
if (stream_wantsnewfs) {

0 commit comments

Comments
 (0)