Silence static analyzer warnings about spa_sync_props()

Both Coverity and Clang's static analyzer complain about reading an
uninitialized intval if the property is not passed as DATA_TYPE_UINT64
in the nvlist. This is impossible becuase spa_prop_validate() already
checked this, but they are unlikely to be the last static analyzers to
complain about this, so lets just refactor the code to suppress the
warnings.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #14043
This commit is contained in:
Richard Yao 2022-10-15 18:34:31 -04:00 committed by Brian Behlendorf
parent 4ecd96371b
commit 44f71818f8
1 changed files with 28 additions and 28 deletions

View File

@ -8867,9 +8867,6 @@ spa_sync_props(void *arg, dmu_tx_t *tx)
spa_history_log_internal(spa, "set", tx, spa_history_log_internal(spa, "set", tx,
"%s=%lld", nvpair_name(elem), "%s=%lld", nvpair_name(elem),
(longlong_t)intval); (longlong_t)intval);
} else {
ASSERT(0); /* not allowed */
}
switch (prop) { switch (prop) {
case ZPOOL_PROP_DELEGATION: case ZPOOL_PROP_DELEGATION:
@ -8898,6 +8895,9 @@ spa_sync_props(void *arg, dmu_tx_t *tx)
default: default:
break; break;
} }
} else {
ASSERT(0); /* not allowed */
}
} }
} }