Skip to content

Commit 7657fd9

Browse files
ryaoandrewc12
authored andcommitted
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 <[email protected]> Signed-off-by: Richard Yao <[email protected]> Closes openzfs#14043
1 parent 7270f31 commit 7657fd9

File tree

1 file changed

+28
-28
lines changed

1 file changed

+28
-28
lines changed

module/zfs/spa.c

Lines changed: 28 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8869,36 +8869,36 @@ spa_sync_props(void *arg, dmu_tx_t *tx)
88698869
spa_history_log_internal(spa, "set", tx,
88708870
"%s=%lld", nvpair_name(elem),
88718871
(longlong_t)intval);
8872-
} else {
8873-
ASSERT(0); /* not allowed */
8874-
}
88758872

8876-
switch (prop) {
8877-
case ZPOOL_PROP_DELEGATION:
8878-
spa->spa_delegation = intval;
8879-
break;
8880-
case ZPOOL_PROP_BOOTFS:
8881-
spa->spa_bootfs = intval;
8882-
break;
8883-
case ZPOOL_PROP_FAILUREMODE:
8884-
spa->spa_failmode = intval;
8885-
break;
8886-
case ZPOOL_PROP_AUTOTRIM:
8887-
spa->spa_autotrim = intval;
8888-
spa_async_request(spa,
8889-
SPA_ASYNC_AUTOTRIM_RESTART);
8890-
break;
8891-
case ZPOOL_PROP_AUTOEXPAND:
8892-
spa->spa_autoexpand = intval;
8893-
if (tx->tx_txg != TXG_INITIAL)
8873+
switch (prop) {
8874+
case ZPOOL_PROP_DELEGATION:
8875+
spa->spa_delegation = intval;
8876+
break;
8877+
case ZPOOL_PROP_BOOTFS:
8878+
spa->spa_bootfs = intval;
8879+
break;
8880+
case ZPOOL_PROP_FAILUREMODE:
8881+
spa->spa_failmode = intval;
8882+
break;
8883+
case ZPOOL_PROP_AUTOTRIM:
8884+
spa->spa_autotrim = intval;
88948885
spa_async_request(spa,
8895-
SPA_ASYNC_AUTOEXPAND);
8896-
break;
8897-
case ZPOOL_PROP_MULTIHOST:
8898-
spa->spa_multihost = intval;
8899-
break;
8900-
default:
8901-
break;
8886+
SPA_ASYNC_AUTOTRIM_RESTART);
8887+
break;
8888+
case ZPOOL_PROP_AUTOEXPAND:
8889+
spa->spa_autoexpand = intval;
8890+
if (tx->tx_txg != TXG_INITIAL)
8891+
spa_async_request(spa,
8892+
SPA_ASYNC_AUTOEXPAND);
8893+
break;
8894+
case ZPOOL_PROP_MULTIHOST:
8895+
spa->spa_multihost = intval;
8896+
break;
8897+
default:
8898+
break;
8899+
}
8900+
} else {
8901+
ASSERT(0); /* not allowed */
89028902
}
89038903
}
89048904

0 commit comments

Comments
 (0)