Cleanup: Remove ineffective unsigned comparisons against 0

Coverity found a number of places where we either do MAX(unsigned, 0) or
do assertions that a unsigned variable is >= 0. These do nothing, so
let us drop them all.

It also found a spot where we do `if (unsigned >= 0 && ...)`. Let us
also drop the unsigned >= 0 check.

Reviewed-by: Neal Gompa <ngompa@datto.com>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Closes #13871
This commit is contained in:
Richard Yao
2022-09-26 20:02:38 -04:00
committed by GitHub
parent 52afc3443d
commit 8ef15f9322
8 changed files with 5 additions and 9 deletions
+1 -1
View File
@@ -7664,7 +7664,7 @@ arc_tuning_update(boolean_t verbose)
/* Valid range: 0 - <all physical memory> */
if ((zfs_arc_sys_free) && (zfs_arc_sys_free != arc_sys_free))
arc_sys_free = MIN(MAX(zfs_arc_sys_free, 0), allmem);
arc_sys_free = MIN(zfs_arc_sys_free, allmem);
WARN_IF_TUNING_IGNORED(zfs_arc_sys_free, arc_sys_free, verbose);
}
-2
View File
@@ -2128,8 +2128,6 @@ dsl_livelist_should_disable(dsl_dataset_t *ds)
used = dsl_dir_get_usedds(ds->ds_dir);
referenced = dsl_get_referenced(ds);
ASSERT3U(referenced, >=, 0);
ASSERT3U(used, >=, 0);
if (referenced == 0)
return (B_FALSE);
percent_shared = (100 * (referenced - used)) / referenced;
-1
View File
@@ -137,7 +137,6 @@ zfs_refcount_add_many(zfs_refcount_t *rc, uint64_t number, const void *holder)
ref->ref_holder = holder;
ref->ref_number = number;
mutex_enter(&rc->rc_mtx);
ASSERT3U(rc->rc_count, >=, 0);
list_insert_head(&rc->rc_list, ref);
rc->rc_count += number;
count = rc->rc_count;
+1 -1
View File
@@ -614,7 +614,7 @@ vdev_queue_aggregate(vdev_queue_t *vq, zio_t *zio)
limit = zfs_vdev_aggregation_limit_non_rotating;
else
limit = zfs_vdev_aggregation_limit;
limit = MAX(MIN(limit, maxblocksize), 0);
limit = MIN(limit, maxblocksize);
if (zio->io_flags & ZIO_FLAG_DONT_AGGREGATE || limit == 0)
return (NULL);