diff options
author | Brian Behlendorf <[email protected]> | 2018-01-19 09:22:37 -0800 |
---|---|---|
committer | GitHub <[email protected]> | 2018-01-19 09:22:37 -0800 |
commit | 31864e3d8c9fc762d4c30324d9a061f4ed009446 (patch) | |
tree | aa46e0178efcbd829a3d83a4a9531d4495d45b5a /module | |
parent | 1574c73bd0680cf3141e26627191120daba3fe8d (diff) |
OpenZFS 8652 - Tautological comparisons with ZPROP_INVAL
usr/src/uts/common/sys/fs/zfs.h
Change ZPROP_INVAL and ZPROP_CONT from macros to enum values. Clang
and GCC both prefer to use unsigned ints to store enums. That was
causing tautological comparison warnings (and likely eliminating
error handling code at compile time) whenever a zfs_prop_t or
zpool_prop_t was compared to ZPROP_INVAL or ZPROP_CONT. Making the
error flags be explicity enum values forces the enum types to be
signed.
ZPROP_INVAL was also compared against two different enum types. I
had to change its name to ZPOOL_PROP_INVAL whenever its compared to
a zpool_prop_t. There are still some places where ZPROP_INVAL or
ZPROP_CONT is compared to a plain int, in code that doesn't know
whether the int is storing a zfs_prop_t or a zpool_prop_t.
usr/src/uts/common/fs/zfs/spa.c
s/ZPROP_INVAL/ZPOOL_PROP_INVAL/
Authored by: Alan Somers <[email protected]>
Approved by: Gordon Ross <[email protected]>
Reviewed by: Matthew Ahrens <[email protected]>
Reviewed by: Igor Kozhukhov <[email protected]>
Reviewed by: George Melikov <[email protected]>
Ported-by: Brian Behlendorf <[email protected]>
OpenZFS-issue: https://www.illumos.org/issues/8652
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/c2de80dc74
Closes #7061
Diffstat (limited to 'module')
-rw-r--r-- | module/zfs/spa.c | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/module/zfs/spa.c b/module/zfs/spa.c index 75b928620..dac042464 100644 --- a/module/zfs/spa.c +++ b/module/zfs/spa.c @@ -353,7 +353,7 @@ spa_prop_get(spa_t *spa, nvlist_t **nvp) zprop_source_t src = ZPROP_SRC_DEFAULT; zpool_prop_t prop; - if ((prop = zpool_name_to_prop(za.za_name)) == ZPROP_INVAL) + if ((prop = zpool_name_to_prop(za.za_name)) == ZPOOL_PROP_INVAL) continue; switch (za.za_integer_length) { @@ -440,8 +440,8 @@ spa_prop_validate(spa_t *spa, nvlist_t *props) const char *propname = nvpair_name(elem); zpool_prop_t prop = zpool_name_to_prop(propname); - switch ((int)prop) { - case ZPROP_INVAL: + switch (prop) { + case ZPOOL_PROP_INVAL: if (!zpool_prop_feature(propname)) { error = SET_ERROR(EINVAL); break; @@ -698,7 +698,7 @@ spa_prop_set(spa_t *spa, nvlist_t *nvp) prop == ZPOOL_PROP_READONLY) continue; - if (prop == ZPOOL_PROP_VERSION || prop == ZPROP_INVAL) { + if (prop == ZPOOL_PROP_VERSION || prop == ZPOOL_PROP_INVAL) { uint64_t ver; if (prop == ZPOOL_PROP_VERSION) { @@ -6541,9 +6541,8 @@ spa_sync_props(void *arg, dmu_tx_t *tx) zprop_type_t proptype; spa_feature_t fid; - prop = zpool_name_to_prop(nvpair_name(elem)); - switch ((int)prop) { - case ZPROP_INVAL: + switch (prop = zpool_name_to_prop(nvpair_name(elem))) { + case ZPOOL_PROP_INVAL: /* * We checked this earlier in spa_prop_validate(). */ |