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 <asomers@gmail.com> Approved by: Gordon Ross <gwr@nexenta.com> Reviewed by: Matthew Ahrens <mahrens@delphix.com> Reviewed by: Igor Kozhukhov <igor@dilos.org> Reviewed by: George Melikov <mail@gmelikov.ru> Ported-by: Brian Behlendorf <behlendorf1@llnl.gov> OpenZFS-issue: https://www.illumos.org/issues/8652 OpenZFS-commit: https://github.com/openzfs/openzfs/commit/c2de80dc74 Closes #7061
This commit is contained in:
parent
1574c73bd0
commit
31864e3d8c
|
@ -511,7 +511,7 @@ static int
|
||||||
add_prop_list(const char *propname, char *propval, nvlist_t **props,
|
add_prop_list(const char *propname, char *propval, nvlist_t **props,
|
||||||
boolean_t poolprop)
|
boolean_t poolprop)
|
||||||
{
|
{
|
||||||
zpool_prop_t prop = ZPROP_INVAL;
|
zpool_prop_t prop = ZPOOL_PROP_INVAL;
|
||||||
zfs_prop_t fprop;
|
zfs_prop_t fprop;
|
||||||
nvlist_t *proplist;
|
nvlist_t *proplist;
|
||||||
const char *normnm;
|
const char *normnm;
|
||||||
|
@ -529,7 +529,7 @@ add_prop_list(const char *propname, char *propval, nvlist_t **props,
|
||||||
if (poolprop) {
|
if (poolprop) {
|
||||||
const char *vname = zpool_prop_to_name(ZPOOL_PROP_VERSION);
|
const char *vname = zpool_prop_to_name(ZPOOL_PROP_VERSION);
|
||||||
|
|
||||||
if ((prop = zpool_name_to_prop(propname)) == ZPROP_INVAL &&
|
if ((prop = zpool_name_to_prop(propname)) == ZPOOL_PROP_INVAL &&
|
||||||
!zpool_prop_feature(propname)) {
|
!zpool_prop_feature(propname)) {
|
||||||
(void) fprintf(stderr, gettext("property '%s' is "
|
(void) fprintf(stderr, gettext("property '%s' is "
|
||||||
"not a valid pool property\n"), propname);
|
"not a valid pool property\n"), propname);
|
||||||
|
@ -540,7 +540,7 @@ add_prop_list(const char *propname, char *propval, nvlist_t **props,
|
||||||
* feature@ properties and version should not be specified
|
* feature@ properties and version should not be specified
|
||||||
* at the same time.
|
* at the same time.
|
||||||
*/
|
*/
|
||||||
if ((prop == ZPROP_INVAL && zpool_prop_feature(propname) &&
|
if ((prop == ZPOOL_PROP_INVAL && zpool_prop_feature(propname) &&
|
||||||
nvlist_exists(proplist, vname)) ||
|
nvlist_exists(proplist, vname)) ||
|
||||||
(prop == ZPOOL_PROP_VERSION &&
|
(prop == ZPOOL_PROP_VERSION &&
|
||||||
prop_list_contains_feature(proplist))) {
|
prop_list_contains_feature(proplist))) {
|
||||||
|
|
|
@ -88,7 +88,8 @@ typedef enum dmu_objset_type {
|
||||||
* the property table in module/zcommon/zfs_prop.c.
|
* the property table in module/zcommon/zfs_prop.c.
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
ZFS_PROP_BAD = -1,
|
ZPROP_CONT = -2,
|
||||||
|
ZPROP_INVAL = -1,
|
||||||
ZFS_PROP_TYPE = 0,
|
ZFS_PROP_TYPE = 0,
|
||||||
ZFS_PROP_CREATION,
|
ZFS_PROP_CREATION,
|
||||||
ZFS_PROP_USED,
|
ZFS_PROP_USED,
|
||||||
|
@ -203,6 +204,7 @@ extern const char *zfs_userquota_prop_prefixes[ZFS_NUM_USERQUOTA_PROPS];
|
||||||
* the property table in module/zcommon/zpool_prop.c.
|
* the property table in module/zcommon/zpool_prop.c.
|
||||||
*/
|
*/
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
ZPOOL_PROP_INVAL = -1,
|
||||||
ZPOOL_PROP_NAME,
|
ZPOOL_PROP_NAME,
|
||||||
ZPOOL_PROP_SIZE,
|
ZPOOL_PROP_SIZE,
|
||||||
ZPOOL_PROP_CAPACITY,
|
ZPOOL_PROP_CAPACITY,
|
||||||
|
@ -238,9 +240,6 @@ typedef enum {
|
||||||
/* Small enough to not hog a whole line of printout in zpool(1M). */
|
/* Small enough to not hog a whole line of printout in zpool(1M). */
|
||||||
#define ZPROP_MAX_COMMENT 32
|
#define ZPROP_MAX_COMMENT 32
|
||||||
|
|
||||||
#define ZPROP_CONT -2
|
|
||||||
#define ZPROP_INVAL -1
|
|
||||||
|
|
||||||
#define ZPROP_VALUE "value"
|
#define ZPROP_VALUE "value"
|
||||||
#define ZPROP_SOURCE "source"
|
#define ZPROP_SOURCE "source"
|
||||||
|
|
||||||
|
|
|
@ -460,7 +460,7 @@ zpool_valid_proplist(libzfs_handle_t *hdl, const char *poolname,
|
||||||
const char *propname = nvpair_name(elem);
|
const char *propname = nvpair_name(elem);
|
||||||
|
|
||||||
prop = zpool_name_to_prop(propname);
|
prop = zpool_name_to_prop(propname);
|
||||||
if (prop == ZPROP_INVAL && zpool_prop_feature(propname)) {
|
if (prop == ZPOOL_PROP_INVAL && zpool_prop_feature(propname)) {
|
||||||
int err;
|
int err;
|
||||||
char *fname = strchr(propname, '@') + 1;
|
char *fname = strchr(propname, '@') + 1;
|
||||||
|
|
||||||
|
@ -500,7 +500,7 @@ zpool_valid_proplist(libzfs_handle_t *hdl, const char *poolname,
|
||||||
/*
|
/*
|
||||||
* Make sure this property is valid and applies to this type.
|
* Make sure this property is valid and applies to this type.
|
||||||
*/
|
*/
|
||||||
if (prop == ZPROP_INVAL) {
|
if (prop == ZPOOL_PROP_INVAL) {
|
||||||
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
|
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
|
||||||
"invalid property '%s'"), propname);
|
"invalid property '%s'"), propname);
|
||||||
(void) zfs_error(hdl, EZFS_BADPROP, errbuf);
|
(void) zfs_error(hdl, EZFS_BADPROP, errbuf);
|
||||||
|
|
|
@ -353,7 +353,7 @@ spa_prop_get(spa_t *spa, nvlist_t **nvp)
|
||||||
zprop_source_t src = ZPROP_SRC_DEFAULT;
|
zprop_source_t src = ZPROP_SRC_DEFAULT;
|
||||||
zpool_prop_t prop;
|
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;
|
continue;
|
||||||
|
|
||||||
switch (za.za_integer_length) {
|
switch (za.za_integer_length) {
|
||||||
|
@ -440,8 +440,8 @@ spa_prop_validate(spa_t *spa, nvlist_t *props)
|
||||||
const char *propname = nvpair_name(elem);
|
const char *propname = nvpair_name(elem);
|
||||||
zpool_prop_t prop = zpool_name_to_prop(propname);
|
zpool_prop_t prop = zpool_name_to_prop(propname);
|
||||||
|
|
||||||
switch ((int)prop) {
|
switch (prop) {
|
||||||
case ZPROP_INVAL:
|
case ZPOOL_PROP_INVAL:
|
||||||
if (!zpool_prop_feature(propname)) {
|
if (!zpool_prop_feature(propname)) {
|
||||||
error = SET_ERROR(EINVAL);
|
error = SET_ERROR(EINVAL);
|
||||||
break;
|
break;
|
||||||
|
@ -698,7 +698,7 @@ spa_prop_set(spa_t *spa, nvlist_t *nvp)
|
||||||
prop == ZPOOL_PROP_READONLY)
|
prop == ZPOOL_PROP_READONLY)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (prop == ZPOOL_PROP_VERSION || prop == ZPROP_INVAL) {
|
if (prop == ZPOOL_PROP_VERSION || prop == ZPOOL_PROP_INVAL) {
|
||||||
uint64_t ver;
|
uint64_t ver;
|
||||||
|
|
||||||
if (prop == ZPOOL_PROP_VERSION) {
|
if (prop == ZPOOL_PROP_VERSION) {
|
||||||
|
@ -6541,9 +6541,8 @@ spa_sync_props(void *arg, dmu_tx_t *tx)
|
||||||
zprop_type_t proptype;
|
zprop_type_t proptype;
|
||||||
spa_feature_t fid;
|
spa_feature_t fid;
|
||||||
|
|
||||||
prop = zpool_name_to_prop(nvpair_name(elem));
|
switch (prop = zpool_name_to_prop(nvpair_name(elem))) {
|
||||||
switch ((int)prop) {
|
case ZPOOL_PROP_INVAL:
|
||||||
case ZPROP_INVAL:
|
|
||||||
/*
|
/*
|
||||||
* We checked this earlier in spa_prop_validate().
|
* We checked this earlier in spa_prop_validate().
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in New Issue