Fix coverity defects: CID 147540, 147542

CID 147540: unsigned_compare
- Cast nsec to a int32_t to properly detect the expected overflow.
CID 147542: unsigned_compare
- intval can never be less than ZIO_FAILURE_MODE_WAIT which is
  defined to be zero.  Remove this useless check.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: cao.xuewen <cao.xuewen@zte.com.cn>
Closes #5379
This commit is contained in:
cao 2016-11-10 09:35:26 +08:00 committed by Brian Behlendorf
parent 7e5ea7be7f
commit 3bfd95d589
2 changed files with 2 additions and 3 deletions

View File

@ -146,7 +146,7 @@ zpios_timespec_normalize(zpios_timespec_t *ts, uint32_t sec, uint32_t nsec)
nsec -= NSEC_PER_SEC;
sec++;
}
while (nsec < 0) {
while (((int32_t)nsec) < 0) {
nsec += NSEC_PER_SEC;
sec--;
}

View File

@ -555,8 +555,7 @@ spa_prop_validate(spa_t *spa, nvlist_t *props)
case ZPOOL_PROP_FAILUREMODE:
error = nvpair_value_uint64(elem, &intval);
if (!error && (intval < ZIO_FAILURE_MODE_WAIT ||
intval > ZIO_FAILURE_MODE_PANIC))
if (!error && intval > ZIO_FAILURE_MODE_PANIC)
error = SET_ERROR(EINVAL);
/*