From 3bfd95d5898b1318f9a5c36d1cc43cf23d004f64 Mon Sep 17 00:00:00 2001 From: cao Date: Thu, 10 Nov 2016 09:35:26 +0800 Subject: [PATCH] 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 Signed-off-by: cao.xuewen Closes #5379 --- include/zpios-ctl.h | 2 +- module/zfs/spa.c | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/include/zpios-ctl.h b/include/zpios-ctl.h index aee4f0a501..90efcb1b18 100644 --- a/include/zpios-ctl.h +++ b/include/zpios-ctl.h @@ -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--; } diff --git a/module/zfs/spa.c b/module/zfs/spa.c index ec6924a020..05e15a2e6d 100644 --- a/module/zfs/spa.c +++ b/module/zfs/spa.c @@ -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); /*