mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-27 04:32:16 +03:00
Replace P2ALIGN with P2ALIGN_TYPED and delete P2ALIGN.
In P2ALIGN, the result would be incorrect when align is unsigned integer and x is larger than max value of the type of align. In that case, -(align) would be a positive integer, which means high bits would be zero and finally stay zero after '&' when align is converted to a larger integer type. Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Youzhong Yang <yyang@mathworks.com> Signed-off-by: Qiuhao Chen <chenqiuhao1997@gmail.com> Closes #15940
This commit is contained in:
@@ -191,7 +191,8 @@ extern unsigned char bcd_to_byte[256];
|
||||
* eg, P2ALIGN(0x1234, 0x100) == 0x1200 (0x12*align)
|
||||
* eg, P2ALIGN(0x5600, 0x100) == 0x5600 (0x56*align)
|
||||
*/
|
||||
#define P2ALIGN(x, align) ((x) & -(align))
|
||||
// Deprecated. Use P2ALIGN_TYPED instead.
|
||||
// #define P2ALIGN(x, align) ((x) & -(align))
|
||||
|
||||
/*
|
||||
* return x % (mod) align
|
||||
|
||||
Reference in New Issue
Block a user