Skip to content

Commit

Permalink
Fix gcc cast warnings
Browse files Browse the repository at this point in the history
Gcc -Wall warn: 'lacks a cast'
Gcc -Wall warn: 'comparison between pointer and integer'

Signed-off-by: Brian Behlendorf <[email protected]>
  • Loading branch information
behlendorf committed Aug 27, 2010
1 parent d6320dd commit b8864a2
Show file tree
Hide file tree
Showing 16 changed files with 90 additions and 77 deletions.
4 changes: 2 additions & 2 deletions cmd/zdb/zdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -874,8 +874,8 @@ dump_history(spa_t *spa)
(void) snprintf(internalstr,
sizeof (internalstr),
"[internal %s txg:%lld] %s",
zfs_history_event_names[ievent], txg,
intstr);
zfs_history_event_names[ievent],
(longlong_t)txg, intstr);
cmd = internalstr;
}
tsec = time;
Expand Down
16 changes: 8 additions & 8 deletions cmd/zfs/zfs_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1682,7 +1682,7 @@ upgrade_set_callback(zfs_handle_t *zhp, void *data)
if (version < cb->cb_version) {
char verstr[16];
(void) snprintf(verstr, sizeof (verstr),
"%llu", cb->cb_version);
"%llu", (u_longlong_t)cb->cb_version);
if (cb->cb_lastfs[0] && !same_pool(zhp, cb->cb_lastfs)) {
/*
* If they did "zfs upgrade -a", then we could
Expand Down Expand Up @@ -1720,7 +1720,7 @@ zfs_do_upgrade(int argc, char **argv)
boolean_t showversions = B_FALSE;
int ret;
upgrade_cbdata_t cb = { 0 };
char c;
signed char c;
int flags = ZFS_ITER_ARGS_CAN_BE_PATHS;

/* check options */
Expand Down Expand Up @@ -1789,11 +1789,11 @@ zfs_do_upgrade(int argc, char **argv)
ret = zfs_for_each(argc, argv, flags, ZFS_TYPE_FILESYSTEM,
NULL, NULL, 0, upgrade_set_callback, &cb);
(void) printf(gettext("%llu filesystems upgraded\n"),
cb.cb_numupgraded);
(u_longlong_t)cb.cb_numupgraded);
if (cb.cb_numsamegraded) {
(void) printf(gettext("%llu filesystems already at "
"this version\n"),
cb.cb_numsamegraded);
(u_longlong_t)cb.cb_numsamegraded);
}
if (cb.cb_numfailed != 0)
ret = 1;
Expand Down Expand Up @@ -1957,9 +1957,9 @@ print_header(zprop_list_t *pl)
if (pl->pl_next == NULL && !right_justify)
(void) printf("%s", header);
else if (right_justify)
(void) printf("%*s", pl->pl_width, header);
(void) printf("%*s", (int)pl->pl_width, header);
else
(void) printf("%-*s", pl->pl_width, header);
(void) printf("%-*s", (int)pl->pl_width, header);
}

(void) printf("\n");
Expand Down Expand Up @@ -2550,7 +2550,7 @@ zfs_do_set(int argc, char **argv)
usage(B_FALSE);
}

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

return (ret);
Expand All @@ -2567,7 +2567,7 @@ zfs_do_snapshot(int argc, char **argv)
{
boolean_t recursive = B_FALSE;
int ret;
char c;
signed char c;
nvlist_t *props;

if (nvlist_alloc(&props, NV_UNIQUE_NAME, 0) != 0)
Expand Down
10 changes: 5 additions & 5 deletions cmd/zpool/zpool_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2438,9 +2438,9 @@ print_header(zprop_list_t *pl)
if (pl->pl_next == NULL && !right_justify)
(void) printf("%s", header);
else if (right_justify)
(void) printf("%*s", pl->pl_width, header);
(void) printf("%*s", (int)pl->pl_width, header);
else
(void) printf("%-*s", pl->pl_width, header);
(void) printf("%-*s", (int)pl->pl_width, header);
}

(void) printf("\n");
Expand Down Expand Up @@ -3906,7 +3906,7 @@ upgrade_one(zpool_handle_t *zhp, void *data)
if (cur_version > cbp->cb_version) {
(void) printf(gettext("Pool '%s' is already formatted "
"using more current version '%llu'.\n"),
zpool_get_name(zhp), cur_version);
zpool_get_name(zhp), (u_longlong_t) cur_version);
return (0);
}
if (cur_version == cbp->cb_version) {
Expand Down Expand Up @@ -4147,8 +4147,8 @@ get_history_one(zpool_handle_t *zhp, void *data)
continue;
(void) snprintf(internalstr,
sizeof (internalstr),
"[internal %s txg:%lld] %s",
zfs_history_event_names[ievent], txg,
"[internal %s txg:%llu] %s",
zfs_history_event_names[ievent], (u_longlong_t)txg,
pathstr);
cmdstr = internalstr;
}
Expand Down
34 changes: 22 additions & 12 deletions cmd/ztest/ztest.c
Original file line number Diff line number Diff line change
Expand Up @@ -2022,7 +2022,7 @@ ztest_od_init(ztest_od_t *od, uint64_t id, char *tag, uint64_t index,
od->od_gen = 0;

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

/*
Expand Down Expand Up @@ -3042,11 +3042,16 @@ ztest_dsl_dataset_cleanup(char *osname, uint64_t id)
char snap3name[MAXNAMELEN];
int error;

(void) snprintf(snap1name, MAXNAMELEN, "%s@s1_%llu", osname, id);
(void) snprintf(clone1name, MAXNAMELEN, "%s/c1_%llu", osname, id);
(void) snprintf(snap2name, MAXNAMELEN, "%s@s2_%llu", clone1name, id);
(void) snprintf(clone2name, MAXNAMELEN, "%s/c2_%llu", osname, id);
(void) snprintf(snap3name, MAXNAMELEN, "%s@s3_%llu", clone1name, id);
(void) snprintf(snap1name, MAXNAMELEN, "%s@s1_%llu",
osname, (u_longlong_t)id);
(void) snprintf(clone1name, MAXNAMELEN, "%s/c1_%llu",
osname, (u_longlong_t)id);
(void) snprintf(snap2name, MAXNAMELEN, "%s@s2_%llu",
clone1name, (u_longlong_t)id);
(void) snprintf(clone2name, MAXNAMELEN, "%s/c2_%llu",
osname, (u_longlong_t)id);
(void) snprintf(snap3name, MAXNAMELEN, "%s@s3_%llu",
clone1name, (u_longlong_t)id);

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

ztest_dsl_dataset_cleanup(osname, id);

(void) snprintf(snap1name, MAXNAMELEN, "%s@s1_%llu", osname, id);
(void) snprintf(clone1name, MAXNAMELEN, "%s/c1_%llu", osname, id);
(void) snprintf(snap2name, MAXNAMELEN, "%s@s2_%llu", clone1name, id);
(void) snprintf(clone2name, MAXNAMELEN, "%s/c2_%llu", osname, id);
(void) snprintf(snap3name, MAXNAMELEN, "%s@s3_%llu", clone1name, id);
(void) snprintf(snap1name, MAXNAMELEN, "%s@s1_%llu",
osname, (u_longlong_t)id);
(void) snprintf(clone1name, MAXNAMELEN, "%s/c1_%llu",
osname, (u_longlong_t)id);
(void) snprintf(snap2name, MAXNAMELEN, "%s@s2_%llu",
clone1name, (u_longlong_t)id);
(void) snprintf(clone2name, MAXNAMELEN, "%s/c2_%llu",
osname, (u_longlong_t)id);
(void) snprintf(snap3name, MAXNAMELEN, "%s@s3_%llu",
clone1name, (u_longlong_t)id);

error = dmu_objset_snapshot(osname, strchr(snap1name, '@')+1,
NULL, NULL, B_FALSE, B_FALSE, -1);
Expand Down Expand Up @@ -3912,7 +3922,7 @@ ztest_fzap(ztest_ds_t *zd, uint64_t id)
int error;

(void) snprintf(name, sizeof (name), "fzap-%llu-%llu",
id, value);
(u_longlong_t)id, (u_longlong_t)value);

tx = dmu_tx_create(os);
dmu_tx_hold_zap(tx, object, B_TRUE, name);
Expand Down
6 changes: 3 additions & 3 deletions lib/libnvpair/libnvpair.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ NVLIST_PRTFUNC(int32, int32_t, int32_t, "%d")
NVLIST_PRTFUNC(uint32, uint32_t, uint32_t, "0x%x")
NVLIST_PRTFUNC(int64, int64_t, longlong_t, "%lld")
NVLIST_PRTFUNC(uint64, uint64_t, u_longlong_t, "0x%llx")
NVLIST_PRTFUNC(double, double, double, "0x%llf")
NVLIST_PRTFUNC(double, double, double, "0x%f")
NVLIST_PRTFUNC(string, char *, char *, "%s")
NVLIST_PRTFUNC(hrtime, hrtime_t, hrtime_t, "0x%llx")

Expand Down Expand Up @@ -1216,7 +1216,7 @@ nvpair_value_match_regex(nvpair_t *nvp, int ai,
boolean_t val, val_arg;

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

/* check indexed value of array for match */
sr = sscanf(value, "%"SCNi32, &val_arg);
sr = sscanf(value, "%"SCNi32, (int32_t *)&val_arg);
if ((sr == 1) &&
(nvpair_value_boolean_array(nvp,
&val_array, &a_len) == 0) &&
Expand Down
5 changes: 3 additions & 2 deletions lib/libzfs/libzfs_dataset.c
Original file line number Diff line number Diff line change
Expand Up @@ -1906,7 +1906,7 @@ zfs_prop_get(zfs_handle_t *zhp, zfs_prop_t prop, char *propbuf, size_t proplen,
localtime_r(&time, &t) == NULL ||
strftime(propbuf, proplen, "%a %b %e %k:%M %Y",
&t) == 0)
(void) snprintf(propbuf, proplen, "%llu", val);
(void) snprintf(propbuf, proplen, "%llu", (u_longlong_t) val);
}
break;

Expand Down Expand Up @@ -2391,7 +2391,8 @@ zfs_prop_get_userquota(zfs_handle_t *zhp, const char *propname,
return (err);

if (literal) {
(void) snprintf(propbuf, proplen, "%llu", propvalue);
(void) snprintf(propbuf, proplen, "%llu",
(u_longlong_t)propvalue);
} else if (propvalue == 0 &&
(type == ZFS_PROP_USERQUOTA || type == ZFS_PROP_GROUPQUOTA)) {
(void) strlcpy(propbuf, "none", proplen);
Expand Down
4 changes: 2 additions & 2 deletions lib/libzfs/libzfs_diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ get_stats_for_obj(differ_info_t *di, const char *dsname, uint64_t obj,
(void) snprintf(di->errbuf, sizeof (di->errbuf),
dgettext(TEXT_DOMAIN,
"Unable to determine path or stats for "
"object %lld in %s"), obj, dsname);
"object %lld in %s"), (longlong_t)obj, dsname);
return (-1);
}
}
Expand Down Expand Up @@ -406,7 +406,7 @@ write_free_diffs(FILE *fp, differ_info_t *di, dmu_diff_record_t *dr)
(void) snprintf(di->errbuf, sizeof (di->errbuf),
dgettext(TEXT_DOMAIN,
"next allocated object (> %lld) find failure"),
zc.zc_obj);
(longlong_t)zc.zc_obj);
di->zerr = errno;
break;
}
Expand Down
31 changes: 17 additions & 14 deletions lib/libzfs/libzfs_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ zpool_get_prop(zpool_handle_t *zhp, zpool_prop_t prop, char *buf, size_t len,

case ZPOOL_PROP_GUID:
intval = zpool_get_prop_int(zhp, prop, &src);
(void) snprintf(buf, len, "%llu", intval);
(void) snprintf(buf, len, "%llu", (u_longlong_t)intval);
break;

case ZPOOL_PROP_ALTROOT:
Expand Down Expand Up @@ -295,7 +295,7 @@ zpool_get_prop(zpool_handle_t *zhp, zpool_prop_t prop, char *buf, size_t len,
vs->vs_aux), len);
break;
default:
(void) snprintf(buf, len, "%llu", intval);
(void) snprintf(buf, len, "%llu", (u_longlong_t)intval);
}
break;

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

if (localtime_r((time_t *)&rewindto, &t) != NULL &&
strftime(timestr, 128, 0, &t) != 0) {
strftime(timestr, 128, "%c", &t) != 0) {
if (dryrun) {
(void) printf(dgettext(TEXT_DOMAIN,
"Would be able to return %s "
Expand All @@ -1253,13 +1253,14 @@ zpool_rewind_exclaim(libzfs_handle_t *hdl, const char *name, boolean_t dryrun,
(void) printf(dgettext(TEXT_DOMAIN,
"%s approximately %lld "),
dryrun ? "Would discard" : "Discarded",
(loss + 30) / 60);
((longlong_t)loss + 30) / 60);
(void) printf(dgettext(TEXT_DOMAIN,
"minutes of transactions.\n"));
} else if (loss > 0) {
(void) printf(dgettext(TEXT_DOMAIN,
"%s approximately %lld "),
dryrun ? "Would discard" : "Discarded", loss);
dryrun ? "Would discard" : "Discarded",
(longlong_t)loss);
(void) printf(dgettext(TEXT_DOMAIN,
"seconds of transactions.\n"));
}
Expand Down Expand Up @@ -1298,7 +1299,7 @@ zpool_explain_recover(libzfs_handle_t *hdl, const char *name, int reason,
"Recovery is possible, but will result in some data loss.\n"));

if (localtime_r((time_t *)&rewindto, &t) != NULL &&
strftime(timestr, 128, 0, &t) != 0) {
strftime(timestr, 128, "%c", &t) != 0) {
(void) printf(dgettext(TEXT_DOMAIN,
"\tReturning the pool to its state as of %s\n"
"\tshould correct the problem. "),
Expand All @@ -1312,11 +1313,13 @@ zpool_explain_recover(libzfs_handle_t *hdl, const char *name, int reason,
if (loss > 120) {
(void) printf(dgettext(TEXT_DOMAIN,
"Approximately %lld minutes of data\n"
"\tmust be discarded, irreversibly. "), (loss + 30) / 60);
"\tmust be discarded, irreversibly. "),
((longlong_t)loss + 30) / 60);
} else if (loss > 0) {
(void) printf(dgettext(TEXT_DOMAIN,
"Approximately %lld seconds of data\n"
"\tmust be discarded, irreversibly. "), loss);
"\tmust be discarded, irreversibly. "),
(longlong_t)loss);
}
if (edata != 0 && edata != UINT64_MAX) {
if (edata == 1) {
Expand Down Expand Up @@ -2260,7 +2263,7 @@ zpool_vdev_fault(zpool_handle_t *zhp, uint64_t guid, vdev_aux_t aux)
libzfs_handle_t *hdl = zhp->zpool_hdl;

(void) snprintf(msg, sizeof (msg),
dgettext(TEXT_DOMAIN, "cannot fault %llu"), guid);
dgettext(TEXT_DOMAIN, "cannot fault %llu"), (u_longlong_t)guid);

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

(void) snprintf(msg, sizeof (msg),
dgettext(TEXT_DOMAIN, "cannot degrade %llu"), guid);
dgettext(TEXT_DOMAIN, "cannot degrade %llu"), (u_longlong_t)guid);

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

(void) snprintf(msg, sizeof (msg),
dgettext(TEXT_DOMAIN, "cannot clear errors for %llx"),
guid);
(u_longlong_t)guid);

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

if (dsobj == 0) {
/* special case for the MOS */
(void) snprintf(pathname, len, "<metadata>:<0x%llx>", obj);
(void) snprintf(pathname, len, "<metadata>:<0x%llx>", (longlong_t)obj);
return;
}

Expand All @@ -3486,7 +3489,7 @@ zpool_obj_to_path(zpool_handle_t *zhp, uint64_t dsobj, uint64_t obj,
ZFS_IOC_DSOBJ_TO_DSNAME, &zc) != 0) {
/* just write out a path of two object numbers */
(void) snprintf(pathname, len, "<0x%llx>:<0x%llx>",
dsobj, obj);
(longlong_t)dsobj, (longlong_t)obj);
return;
}
(void) strlcpy(dsname, zc.zc_value, sizeof (dsname));
Expand All @@ -3507,7 +3510,7 @@ zpool_obj_to_path(zpool_handle_t *zhp, uint64_t dsobj, uint64_t obj,
dsname, zc.zc_value);
}
} else {
(void) snprintf(pathname, len, "%s:<0x%llx>", dsname, obj);
(void) snprintf(pathname, len, "%s:<0x%llx>", dsname, (longlong_t)obj);
}
free(mntpnt);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/libzfs/libzfs_sendrecv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1571,7 +1571,7 @@ recv_rename(libzfs_handle_t *hdl, const char *name, const char *tryname,

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

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

stream_wantsnewfs = (drrb->drr_fromguid == NULL ||
stream_wantsnewfs = (drrb->drr_fromguid == 0 ||
(drrb->drr_flags & DRR_FLAG_CLONE));

if (stream_wantsnewfs) {
Expand Down
Loading

0 comments on commit b8864a2

Please sign in to comment.