Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix clang warnings when compiling on FreeBSD #1

Closed
wants to merge 2 commits into from

2 participants

@yaneurabeya

These items were found when compiling zpool(8) on FreeBSD with clang.

They have not been compile-tested as I don't have a copy of OpenSolaris available at my disposal, but the changes are very mechanical/trivial.

yaneurabeya added some commits
@yaneurabeya yaneurabeya Fix clang compiler warning on FreeBSD
The parentheses around assignment of zhp are potentially ambiguous in
the conditional test when iterating over zpools.

This makes the return value tested explicit and adds needed parentheses
to fix a clang/newer gcc compiler warning.

Signed-off-by: Garrett Cooper <yanegomi@gmail.com>
70cf8a9
@yaneurabeya yaneurabeya Fix -Wformat clang compile time warnings
The current printf(3) format qualifiers are signed or not exactly
equivalent to the values provided as parameters in the printf(3) calls.

All printf(3) calls have been properly standardized on u_longlong_t to
match the surrounding code.

Signed-off-by: Garrett Cooper <yanegomi@gmail.com>
dbf3d8f
@richlowe
Owner

I know we're weird, but it'd help a bunch if you'd follow: http://wiki.illumos.org/display/illumos/How+To+Contribute

Though while I'm here, you're using the BSD-ish type in dbf3d8f where we generally wouldn't (u_longlong_t in place of uint64_t I imagine).

@richlowe richlowe closed this
@yaneurabeya

Ok. I couldn't [quickly] find a way where one could disable pull requests, but doing that and providing a pointer to the docs would be ideal compared to having to manually do this all the time.

With respect to the the type, I matched the surrounding code by choosing u_longlong_t; [Free]BSD prefers strict types as well (uint32_t, int64_t, etc).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 12, 2012
  1. @yaneurabeya

    Fix clang compiler warning on FreeBSD

    yaneurabeya authored
    The parentheses around assignment of zhp are potentially ambiguous in
    the conditional test when iterating over zpools.
    
    This makes the return value tested explicit and adds needed parentheses
    to fix a clang/newer gcc compiler warning.
    
    Signed-off-by: Garrett Cooper <yanegomi@gmail.com>
  2. @yaneurabeya

    Fix -Wformat clang compile time warnings

    yaneurabeya authored
    The current printf(3) format qualifiers are signed or not exactly
    equivalent to the values provided as parameters in the printf(3) calls.
    
    All printf(3) calls have been properly standardized on u_longlong_t to
    match the surrounding code.
    
    Signed-off-by: Garrett Cooper <yanegomi@gmail.com>
This page is out of date. Refresh to see the latest.
Showing with 16 additions and 13 deletions.
  1. +3 −3 usr/src/cmd/zpool/zpool_iter.c
  2. +13 −10 usr/src/cmd/zpool/zpool_main.c
View
6 usr/src/cmd/zpool/zpool_iter.c
@@ -131,11 +131,11 @@ pool_list_get(int argc, char **argv, zprop_list_t **proplist, int *err)
for (i = 0; i < argc; i++) {
zpool_handle_t *zhp;
- if (zhp = zpool_open_canfail(g_zfs, argv[i])) {
+ if ((zhp = zpool_open_canfail(g_zfs, argv[i])) == NULL)
+ *err = B_TRUE;
+ else {
if (add_pool(zhp, zlp) != 0)
*err = B_TRUE;
- } else {
- *err = B_TRUE;
}
}
}
View
23 usr/src/cmd/zpool/zpool_main.c
@@ -4322,11 +4322,12 @@ upgrade_version(zpool_handle_t *zhp, uint64_t version)
if (version >= SPA_VERSION_FEATURES) {
(void) printf(gettext("Successfully upgraded "
"'%s' from version %llu to feature flags.\n"),
- zpool_get_name(zhp), oldversion);
+ zpool_get_name(zhp), (u_longlong_t)oldversion);
} else {
(void) printf(gettext("Successfully upgraded "
"'%s' from version %llu to version %llu.\n"),
- zpool_get_name(zhp), oldversion, version);
+ zpool_get_name(zhp), (u_longlong_t)oldversion,
+ (u_longlong_t)version);
}
return (0);
@@ -4525,14 +4526,14 @@ 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\n"),
- zpool_get_name(zhp), cur_version);
+ zpool_get_name(zhp), (u_longlong_t)cur_version);
return (0);
}
if (cbp->cb_version != SPA_VERSION && cur_version == cbp->cb_version) {
(void) printf(gettext("Pool '%s' is already formatted "
"using version %llu.\n\n"), zpool_get_name(zhp),
- cbp->cb_version);
+ (u_longlong_t)cbp->cb_version);
return (0);
}
@@ -4718,7 +4719,7 @@ zpool_do_upgrade(int argc, char **argv)
} else {
(void) printf(gettext("All pools are already "
"formatted with version %llu or higher.\n"),
- cb.cb_version);
+ (u_longlong_t)cb.cb_version);
}
}
} else if (argc == 0) {
@@ -4807,21 +4808,23 @@ get_history_one(zpool_handle_t *zhp, void *data)
dump_nvlist(rec, 4);
continue;
}
- (void) printf("%s [internal %s txg:%lld] %s", tbuf,
+ (void) printf("%s [internal %s txg:%llu] %s", tbuf,
zfs_history_event_names[ievent],
- fnvlist_lookup_uint64(rec, ZPOOL_HIST_TXG),
+ (u_longlong_t)fnvlist_lookup_uint64(rec,
+ ZPOOL_HIST_TXG),
fnvlist_lookup_string(rec, ZPOOL_HIST_INT_STR));
} else if (nvlist_exists(rec, ZPOOL_HIST_INT_NAME)) {
if (!cb->internal)
continue;
- (void) printf("%s [txg:%lld] %s", tbuf,
- fnvlist_lookup_uint64(rec, ZPOOL_HIST_TXG),
+ (void) printf("%s [txg:%llu] %s", tbuf,
+ (u_longlong_t)fnvlist_lookup_uint64(rec,
+ ZPOOL_HIST_TXG),
fnvlist_lookup_string(rec, ZPOOL_HIST_INT_NAME));
if (nvlist_exists(rec, ZPOOL_HIST_DSNAME)) {
(void) printf(" %s (%llu)",
fnvlist_lookup_string(rec,
ZPOOL_HIST_DSNAME),
- fnvlist_lookup_uint64(rec,
+ (u_longlong_t)fnvlist_lookup_uint64(rec,
ZPOOL_HIST_DSID));
}
(void) printf(" %s", fnvlist_lookup_string(rec,
Something went wrong with that request. Please try again.