From: Brian Behlendorf Date: Thu, 4 Dec 2008 22:41:11 +0000 (-0800) Subject: Refresh gcc-cast branch X-Git-Tag: zfs-0.4.1~459^2^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8de21aeeef837a04efb827117c84382a3d6f8f04;p=zfs Refresh gcc-cast branch --- diff --git a/.topdeps b/.topdeps new file mode 100644 index 000000000..1f7391f92 --- /dev/null +++ b/.topdeps @@ -0,0 +1 @@ +master diff --git a/.topmsg b/.topmsg new file mode 100644 index 000000000..5dae05cd3 --- /dev/null +++ b/.topmsg @@ -0,0 +1,7 @@ +From: Brian Behlendorf +Subject: [PATCH] gcc cast + +Gcc -Wall warn: 'lacks a cast' +Gcc -Wall warn: 'comparison between pointer and integer' + +Signed-off-by: Brian Behlendorf diff --git a/zfs/lib/libspl/util.c b/zfs/lib/libspl/util.c index 781edb6e8..360bf7bee 100644 --- a/zfs/lib/libspl/util.c +++ b/zfs/lib/libspl/util.c @@ -109,7 +109,7 @@ show_vdev_stats(const char *desc, const char *ctype, nvlist_t *nv, int indent) (void) printf("%*s%s%*s%*s%*s %5s %5s %5s %5s %5s %5s %5s\n", indent, "", prefix, - indent + strlen(prefix) - 25 - (vs->vs_space ? 0 : 12), + (int)(indent+strlen(prefix)-25-(vs->vs_space ? 0 : 12)), desc, vs->vs_space ? 6 : 0, vs->vs_space ? used : "", vs->vs_space ? 6 : 0, vs->vs_space ? avail : "", diff --git a/zfs/lib/libzfs/libzfs_dataset.c b/zfs/lib/libzfs/libzfs_dataset.c index a8005ffc0..4aeb9bd09 100644 --- a/zfs/lib/libzfs/libzfs_dataset.c +++ b/zfs/lib/libzfs/libzfs_dataset.c @@ -1172,7 +1172,7 @@ zfs_build_perms(zfs_handle_t *zhp, char *whostr, char *perms, if (sets_nvp) nvlist_free(sets_nvp); (void) snprintf(errbuf, sizeof (errbuf), - dgettext(TEXT_DOMAIN, "Who string is NULL"), + dgettext(TEXT_DOMAIN, "Who string is NULL: %s"), whostr); return (zfs_error(zhp->zfs_hdl, EZFS_BADWHO, errbuf)); } @@ -2317,7 +2317,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; diff --git a/zfs/lib/libzfs/libzfs_pool.c b/zfs/lib/libzfs/libzfs_pool.c index dc5407bef..ae4b19adb 100644 --- a/zfs/lib/libzfs/libzfs_pool.c +++ b/zfs/lib/libzfs/libzfs_pool.c @@ -261,7 +261,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; @@ -1661,7 +1661,7 @@ zpool_vdev_fault(zpool_handle_t *zhp, uint64_t guid) 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; @@ -1695,7 +1695,7 @@ zpool_vdev_degrade(zpool_handle_t *zhp, uint64_t guid) 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; @@ -2068,7 +2068,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; @@ -2727,7 +2727,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, ":<0x%llx>", obj); + (void) snprintf(pathname, len, ":<0x%llx>", (longlong_t)obj); return; } @@ -2738,7 +2738,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)); @@ -2759,7 +2759,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); } diff --git a/zfs/lib/libzfs/libzfs_sendrecv.c b/zfs/lib/libzfs/libzfs_sendrecv.c index a3ed5cea8..a7acf3974 100644 --- a/zfs/lib/libzfs/libzfs_sendrecv.c +++ b/zfs/lib/libzfs/libzfs_sendrecv.c @@ -915,7 +915,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) { @@ -1665,7 +1665,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) { diff --git a/zfs/lib/libzfs/libzfs_util.c b/zfs/lib/libzfs/libzfs_util.c index 54de0f4b5..116521cb4 100644 --- a/zfs/lib/libzfs/libzfs_util.c +++ b/zfs/lib/libzfs/libzfs_util.c @@ -520,13 +520,13 @@ zfs_nicenum(uint64_t num, char *buf, size_t buflen) u = " KMGTPE"[index]; if (index == 0) { - (void) snprintf(buf, buflen, "%llu", n); + (void) snprintf(buf, buflen, "%llu", (u_longlong_t) n); } else if ((num & ((1ULL << 10 * index) - 1)) == 0) { /* * If this is an even multiple of the base, always display * without any decimal precision. */ - (void) snprintf(buf, buflen, "%llu%c", n, u); + (void) snprintf(buf, buflen, "%llu%c", (u_longlong_t) n, u); } else { /* * We want to choose a precision that reflects the best choice @@ -670,7 +670,7 @@ zcmd_alloc_dst_nvlist(libzfs_handle_t *hdl, zfs_cmd_t *zc, size_t len) len = 2048; zc->zc_nvlist_dst_size = len; if ((zc->zc_nvlist_dst = (uint64_t)(uintptr_t) - zfs_alloc(hdl, zc->zc_nvlist_dst_size)) == NULL) + zfs_alloc(hdl, zc->zc_nvlist_dst_size)) == 0) return (-1); return (0); @@ -686,8 +686,7 @@ zcmd_expand_dst_nvlist(libzfs_handle_t *hdl, zfs_cmd_t *zc) { free((void *)(uintptr_t)zc->zc_nvlist_dst); if ((zc->zc_nvlist_dst = (uint64_t)(uintptr_t) - zfs_alloc(hdl, zc->zc_nvlist_dst_size)) - == NULL) + zfs_alloc(hdl, zc->zc_nvlist_dst_size)) == 0) return (-1); return (0); diff --git a/zfs/lib/libzpool/zap.c b/zfs/lib/libzpool/zap.c index ca859ec35..2f604faf9 100644 --- a/zfs/lib/libzpool/zap.c +++ b/zfs/lib/libzpool/zap.c @@ -476,7 +476,7 @@ zap_open_leaf(uint64_t blkid, dmu_buf_t *db) ASSERT3U(ZAP_LEAF_HASH_NUMENTRIES(l), >, ZAP_LEAF_NUMCHUNKS(l) / 3); /* The chunks should begin at the end of the hash table */ - ASSERT3P(&ZAP_LEAF_CHUNK(l, 0), ==, + ASSERT3P(&ZAP_LEAF_CHUNK(l, 0), ==, (zap_leaf_chunk_t *) &l->l_phys->l_hash[ZAP_LEAF_HASH_NUMENTRIES(l)]); /* The chunks should end at the end of the block */ diff --git a/zfs/lib/libzpool/zfs_ioctl.c b/zfs/lib/libzpool/zfs_ioctl.c index b6ad57451..62e105b47 100644 --- a/zfs/lib/libzpool/zfs_ioctl.c +++ b/zfs/lib/libzpool/zfs_ioctl.c @@ -142,7 +142,7 @@ history_str_get(zfs_cmd_t *zc) { char *buf; - if (zc->zc_history == NULL) + if (zc->zc_history == 0) return (NULL); buf = kmem_alloc(HIS_MAX_RECORD_LEN, KM_SLEEP); @@ -1271,7 +1271,7 @@ zfs_ioc_objset_zplprops(zfs_cmd_t *zc) * which we aren't supposed to do with a DS_MODE_USER * hold, because it could be inconsistent. */ - if (zc->zc_nvlist_dst != NULL && + if (zc->zc_nvlist_dst != 0 && !zc->zc_objset_stats.dds_inconsistent && dmu_objset_type(os) == DMU_OST_ZFS) { nvlist_t *nv; @@ -1669,7 +1669,7 @@ zfs_ioc_pool_get_props(zfs_cmd_t *zc) error = spa_prop_get(spa, &nvp); - if (error == 0 && zc->zc_nvlist_dst != NULL) + if (error == 0 && zc->zc_nvlist_dst != 0) error = put_nvlist(zc, nvp); else error = EFAULT; @@ -2045,7 +2045,7 @@ zfs_ioc_create(zfs_cmd_t *zc) strchr(zc->zc_name, '%')) return (EINVAL); - if (zc->zc_nvlist_src != NULL && + if (zc->zc_nvlist_src != 0 && (error = get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size, &nvprops)) != 0) return (error); @@ -2441,7 +2441,7 @@ zfs_ioc_recv(zfs_cmd_t *zc) *tosnap = '\0'; tosnap++; - if (zc->zc_nvlist_src != NULL && + if (zc->zc_nvlist_src != 0 && (error = get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size, &props)) != 0) return (error); diff --git a/zfs/zcmd/zfs/zfs_main.c b/zfs/zcmd/zfs/zfs_main.c index f9480ceba..b46086c24 100644 --- a/zfs/zcmd/zfs/zfs_main.c +++ b/zfs/zcmd/zfs/zfs_main.c @@ -1453,7 +1453,7 @@ upgrade_set_callback(zfs_handle_t *zhp, void *data) /* can't upgrade */ (void) printf(gettext("%s: can not be upgraded; " "the pool version needs to first be upgraded\nto " - "version %d\n\n"), + "version %llu\n\n"), zfs_get_name(zhp), SPA_VERSION_FUID); cb->cb_numfailed++; return (0); @@ -1464,7 +1464,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 @@ -1570,11 +1570,11 @@ zfs_do_upgrade(int argc, char **argv) ret = zfs_for_each(argc, argv, flags, ZFS_TYPE_FILESYSTEM, NULL, NULL, 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; @@ -1659,9 +1659,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"); diff --git a/zfs/zcmd/zpool/zpool_main.c b/zfs/zcmd/zpool/zpool_main.c index 54bba8645..316fa291d 100644 --- a/zfs/zcmd/zpool/zpool_main.c +++ b/zfs/zcmd/zpool/zpool_main.c @@ -2061,9 +2061,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"); @@ -3368,7 +3368,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) { @@ -3631,8 +3631,8 @@ get_history_one(zpool_handle_t *zhp, void *data) continue; (void) snprintf(internalstr, sizeof (internalstr), - "[internal %s txg:%lld] %s", - hist_event_table[ievent], txg, + "[internal %s txg:%llu] %s", + hist_event_table[ievent], (u_longlong_t)txg, pathstr); cmdstr = internalstr; }