Re: [PATCH] btrfs: cleanup for open-coded alignment

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> Sometimes these open-coded alignment is not so easy to understand for
> newbie like me.

Thanks, this is a nice change.

You might have mentioned in the commit message that some of the changes
aren't *strictly* equivalent but that they're still safe.

> -		iosize = (iosize + blocksize - 1) & ~((u64)blocksize - 1);
> +		iosize = ALIGN(iosize, blocksize);

This is equivalent to

> +		iosize = (iosize + blocksize - 1) & ~((size_t)blocksize - 1);

Which is fine.  That u64 was overkill.  The manual casts only need to
make sure that the mask is as wide as the input value to avoid losing
bits and the macro now guarantees that.

> -	num_bytes = (end - start + blocksize) & ~(blocksize - 1);
> +	num_bytes = ALIGN(end - start + 1, blocksize);

Nice catch.

Reviewed-by: Zach Brown <zab@xxxxxxxxxx>

- z
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux