On 9/17/18 4:27 PM, Richard W.M. Jones wrote:
This refactoring also fixes a bug spotted by Eric Blake:
nbdkit --filter truncate pattern size=5G round-up=512
results in a 1G virtual disk. ---
+/* Round up i to next multiple of n (n must be a power of 2). + */ +#define ROUND_UP(i, n) ({ \ + assert (is_power_of_2 (n)); \ + ((i) + (n) - 1) & -((typeof (i))n); \
Missing () around n here,
+}) + +/* Round down i to next multiple of n (n must be a power of 2). + */ +#define ROUND_DOWN(i, n) ({ \ + assert (is_power_of_2 (n)); \ + (i) & -((typeof (i))(n)); \
but not here. I pushed the obvious fix. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org