Page MenuHomeFreeBSD

Add parens to radix_to_skip for reader clarity
ClosedPublic

Authored by dougm on Aug 2 2017, 3:14 AM.
Tags
None
Referenced Files
Unknown Object (File)
Jan 21 2024, 6:03 PM
Unknown Object (File)
Jan 13 2024, 10:57 PM
Unknown Object (File)
Nov 30 2023, 8:46 AM
Unknown Object (File)
Nov 25 2023, 1:14 AM
Unknown Object (File)
Nov 23 2023, 12:54 AM
Unknown Object (File)
Nov 5 2023, 10:36 PM
Unknown Object (File)
Nov 4 2023, 7:45 PM
Unknown Object (File)
Oct 4 2023, 9:34 PM
Subscribers
None

Details

Summary

In case readers are misled by expressions that combine multiplication and division, add parentheses to make the precedence explicit. Add similar changes to accompanying comments.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Thanks! This helps the readability of the code a little and won't trigger people's "this might be a bug" reflex. I made a couple of minor suggested tweaks to the comments for your consideration.

And thanks for the larger work that preceded this.

sys/kern/subr_blist.c
155 ↗(On Diff #31457)

s/if/since/ because m must divide BLIST_BMAP_RADIX for this code to work.

158 ↗(On Diff #31457)

"so simple integer division by a constant can safely be used for the calculation" might better convey what's going on here.

165 ↗(On Diff #31457)

so this is radix / ( ( 64 / 16 ) * 63 )

which works because BLIST_BMAP_RADIX % BLIST_META_RADIX == 0. OK.

This revision is now accepted and ready to land.Aug 2 2017, 4:43 PM
dougm edited edge metadata.
This revision now requires review to proceed.Aug 2 2017, 5:33 PM
sys/kern/subr_blist.c
165 ↗(On Diff #31457)

Actually, it is radix/((64/16)*15), but it's still okay.

Add a CTASSERT for the divisibilty condition.

Excellent! Thanks! this looks perfect now.

This revision is now accepted and ready to land.Aug 2 2017, 6:36 PM
dougm edited edge metadata.

#define a null CTASSERT macro for the self-testing compile.

This revision now requires review to proceed.Aug 2 2017, 6:46 PM
This revision is now accepted and ready to land.Aug 2 2017, 8:13 PM
This revision was automatically updated to reflect the committed changes.