Commit 713e9e951a for qemu.org
commit 713e9e951aca89e1e77d16bdad1b109b3d82fd60
Author: Jamin Lin <jamin_lin@aspeedtech.com>
Date: Tue Mar 3 01:33:24 2026 +0000
hw/i3c/dw-i3c: Use ROUND_UP() for RX buffer allocation alignment
The RX temporary buffer allocation manually aligned the size using:
num + (4 - (num & 0x03))
Replace this with ROUND_UP(num, 4) for better readability and
consistency with common QEMU coding style.
No functional change.
Signed-off-by: Jamin Lin <jamin_lin@aspeedtech.com>
Reviewed-by: Jithu Joseph <jithu.joseph@oss.qualcomm.com>
Link: https://lore.kernel.org/qemu-devel/20260303013322.1297499-2-jamin_lin@aspeedtech.com
Signed-off-by: Cédric Le Goater <clg@redhat.com>
diff --git a/hw/i3c/dw-i3c.c b/hw/i3c/dw-i3c.c
index d742458129..3d8b95a14c 100644
--- a/hw/i3c/dw-i3c.c
+++ b/hw/i3c/dw-i3c.c
@@ -1282,7 +1282,7 @@ static uint16_t dw_i3c_rx(DWI3C *s, uint16_t num, bool is_i2c)
* Allocate a temporary buffer to read data from the target.
* Zero it and word-align it as well in case we're reading unaligned data.
*/
- g_autofree uint8_t *data = g_new0(uint8_t, num + (4 - (num & 0x03)));
+ g_autofree uint8_t *data = g_new0(uint8_t, ROUND_UP(num, 4));
uint32_t *data32 = (uint32_t *)data;
/*
* 32-bits since the I3C API wants a 32-bit number, even though the