Cleanup ->dd_space_towrite should be unsigned
This is only ever used with unsigned data, so the type itself should be unsigned. Also, PVS Studio's 2016 FreeBSD kernel report correctly identified the following assertion as always being true, so we can drop it: ASSERT3U(dd->dd_space_towrite[i & TXG_MASK], >=, 0); The reason it was always true is because it would do casts to give us unsigned comparisons. This could have been fixed by switching to `ASSERT3S()`, but upon inspection, it turned out that this variable never should have been allowed to be signed in the first place. Reviewed-by: Ryan Moeller <ryan@iXsystems.com> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Richard Yao <richard.yao@alumni.stonybrook.edu> Closes #14408
This commit is contained in:
parent
ebabb93e6c
commit
856cefcd1c
|
@ -116,7 +116,7 @@ struct dsl_dir {
|
||||||
/* gross estimate of space used by in-flight tx's */
|
/* gross estimate of space used by in-flight tx's */
|
||||||
uint64_t dd_tempreserved[TXG_SIZE];
|
uint64_t dd_tempreserved[TXG_SIZE];
|
||||||
/* amount of space we expect to write; == amount of dirty data */
|
/* amount of space we expect to write; == amount of dirty data */
|
||||||
int64_t dd_space_towrite[TXG_SIZE];
|
uint64_t dd_space_towrite[TXG_SIZE];
|
||||||
|
|
||||||
dsl_deadlist_t dd_livelist;
|
dsl_deadlist_t dd_livelist;
|
||||||
bplist_t dd_pending_frees;
|
bplist_t dd_pending_frees;
|
||||||
|
|
|
@ -1186,10 +1186,9 @@ dsl_dir_space_towrite(dsl_dir_t *dd)
|
||||||
|
|
||||||
ASSERT(MUTEX_HELD(&dd->dd_lock));
|
ASSERT(MUTEX_HELD(&dd->dd_lock));
|
||||||
|
|
||||||
for (int i = 0; i < TXG_SIZE; i++) {
|
for (int i = 0; i < TXG_SIZE; i++)
|
||||||
space += dd->dd_space_towrite[i & TXG_MASK];
|
space += dd->dd_space_towrite[i & TXG_MASK];
|
||||||
ASSERT3U(dd->dd_space_towrite[i & TXG_MASK], >=, 0);
|
|
||||||
}
|
|
||||||
return (space);
|
return (space);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue