[CFR] printf format changes
Bruce Evans
brde at optusnet.com.au
Tue Nov 12 07:54:46 UTC 2013
On Mon, 11 Nov 2013, Sean Bruno wrote:
> Updated patch for libzfs. I've continued the (longlong_t) nonsense as
> it matches the vendor code, wrapped any lines that go past 80 and reset
> the cast and printf() for the time_t argument. This patch is being sent
> to illumos for review as issue 4309.
>
> http://people.freebsd.org/~sbruno/libzfs_update_casting.txt
>
> Index: cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c
> ===================================================================
> --- cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c (revision 257998)
> +++ cddl/contrib/opensolaris/lib/libzfs/common/libzfs_dataset.c (working copy)
> @@ -2134,7 +2134,8 @@
> 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;
>
Next note that the vendor mostly uses KNF. This uses gnu style for
the change, despite a 3-line example of KNF continuation indentation
being visible in the same part of the patch.
> @@ -2648,7 +2649,8 @@
> 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);
gnu style.
> @@ -2705,7 +2707,8 @@
> return (err);
>
> if (literal) {
> - (void) snprintf(propbuf, proplen, "%llu", propvalue);
> + (void) snprintf(propbuf, proplen, "%llu",
> + (u_longlong_t)propvalue);
> } else {
> zfs_nicenum(propvalue, propbuf, proplen);
> }
gnu style.
> Index: cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c
> ===================================================================
> --- cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c (revision 257998)
> +++ cddl/contrib/opensolaris/lib/libzfs/common/libzfs_pool.c (working copy)
> @@ -261,7 +261,8 @@
>
> 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:
gnu style.
> @@ -337,7 +338,8 @@
> }
> /* FALLTHROUGH */
> default:
> - (void) snprintf(buf, len, "%llu", intval);
> + (void) snprintf(buf, len, "%llu",
> + (u_longlong_t)intval);
> }
> break;
>
gnu style.
> @@ -3228,7 +3233,7 @@
>
> (void) snprintf(msg, sizeof (msg),
> dgettext(TEXT_DOMAIN, "cannot clear errors for %llx"),
> - guid);
> + (longlong_t)guid);
>
> (void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name));
> zc.zc_guid = guid;
Sign mismatch in type in the cast. It matches neither the variable nor
the format.
> @@ -3793,7 +3798,8 @@
>
> 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;
> }
>
Sign mismatch.
> @@ -3804,7 +3810,7 @@
> 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));
Sign mismatch.
> @@ -3825,7 +3831,8 @@
> 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);
> }
Sign mismatch.
> Index: cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c
> ===================================================================
> --- cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c (revision 257998)
> +++ cddl/contrib/opensolaris/lib/libzfs/common/libzfs_sendrecv.c (working copy)
> @@ -2083,7 +2083,8 @@
> needagain = B_TRUE;
> else
> progress = B_TRUE;
> - sprintf(guidname, "%lu", thisguid);
> + sprintf(guidname, "%llu",
> + (u_longlong_t)thisguid);
> nvlist_add_boolean(deleted, guidname);
> continue;
> }
gnu style.
> @@ -2140,7 +2141,7 @@
> needagain = B_TRUE;
> else
> progress = B_TRUE;
> - sprintf(guidname, "%lu", parent_fromsnap_guid);
> + sprintf(guidname, "%llu", (u_longlong_t)parent_fromsnap_guid);
> nvlist_add_boolean(deleted, guidname);
> continue;
> }
Line too long.
> @@ -2173,7 +2174,7 @@
> if (stream_parent_fromsnap_guid != 0 &&
> parent_fromsnap_guid != 0 &&
> stream_parent_fromsnap_guid != parent_fromsnap_guid) {
> - sprintf(guidname, "%lu", parent_fromsnap_guid);
> + sprintf(guidname, "%ju", (uintmax_t)parent_fromsnap_guid);
> if (nvlist_exists(deleted, guidname)) {
> progress = B_TRUE;
> needagain = B_TRUE;
Doesn't use ulonglong_t.
Line too long.
I think I found all the errors.
Bruce
More information about the freebsd-fs
mailing list