]> granicus.if.org Git - zfs/commitdiff
Fix enum compiler warning
authorBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 23 Feb 2011 20:50:05 +0000 (12:50 -0800)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 23 Feb 2011 20:52:51 +0000 (12:52 -0800)
Generally it's a good idea to use enums for switch statements,
but in this case it causes warning because the enum is really a
set of flags.  These flags are OR'ed together in some cases
resulting in values which are not part of the original enum.
This causes compiler warning such as this about invalid cases.

  error: case value ‘33’ not in enumerated type ‘zprop_source_t’

To handle this we simply case the enum to an int for the switch
statement.  This leaves all other enum type checking in place
and effectively disabled these warnings.

module/zfs/dsl_prop.c

index 0ba929a713e145c28738af1802c2710062c94511..c0e65d8bd703c277998cd5d98158870686be94bb 100644 (file)
@@ -355,7 +355,7 @@ dsl_prop_predict_sync(dsl_dir_t *dd, dsl_prop_setarg_t *psa)
                        source = ZPROP_SRC_LOCAL;
        }
 
-       switch (source) {
+       switch ((int)source) {
        case ZPROP_SRC_NONE:
                /* Revert to the received value, if any. */
                err = zap_lookup(mos, zapobj, recvdstr, 8, 1,
@@ -594,7 +594,7 @@ dsl_prop_set_sync(void *arg1, void *arg2, dmu_tx_t *tx)
        inheritstr = kmem_asprintf("%s%s", propname, ZPROP_INHERIT_SUFFIX);
        recvdstr = kmem_asprintf("%s%s", propname, ZPROP_RECVD_SUFFIX);
 
-       switch (source) {
+       switch ((int)source) {
        case ZPROP_SRC_NONE:
                /*
                 * revert to received value, if any (inherit -S)