Cleanup the rman_make_alignment_flags function to be much clearer and shorter

than the prior version.
This commit is contained in:
Warner Losh 2000-10-22 04:48:11 +00:00
parent fe8d027cd8
commit bbfe025461
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=67425

View file

@ -598,18 +598,16 @@ uint32_t
rman_make_alignment_flags(uint32_t size)
{
int i;
int count;
for (i = 0, count = 0; i < 32 && size > 0x01; i++) {
count += size & 1;
size >>= 1;
}
if (count > 0)
i ++;
if (i > 31)
i = 0;
/*
* Find the hightest bit set, and add one if more than one bit
* set. We're effectively computing the ceil(log2(size)) here.
*/
for (i = 32; i > 0; i--)
if ((1 << i) & size)
break;
if (~(1 << i) & size)
i++;
return(RF_ALIGNMENT_LOG2(i));
}
}