On 01/30/2018 09:04 AM, Alberto Garcia wrote: > The align_offset() function is equivalent to the ROUND_UP() macro so > there's no need to use the former. The ROUND_UP() name is also a bit > more explicit. > > This patch uses ROUND_UP() instead of the slower QEMU_ALIGN_UP() > because align_offset() already requires that the second parameter is a > power of two.
(Presumably, for the cases where the second argument is a compile-time constant, the compiler emits the same code for either macro - but I agree that QEMU_ALIGN_UP can be slower where the compiler can't see it is a power of 2) > > Signed-off-by: Alberto Garcia <be...@igalia.com> > --- > +++ b/block/qcow2-bitmap.c > @@ -413,7 +413,7 @@ static inline void > bitmap_dir_entry_to_be(Qcow2BitmapDirEntry *entry) > > static inline int calc_dir_entry_size(size_t name_size, size_t > extra_data_size) > { > - return align_offset(sizeof(Qcow2BitmapDirEntry) + > + return ROUND_UP(sizeof(Qcow2BitmapDirEntry) + > name_size + extra_data_size, 8); Indentation alignment is now off. > +++ b/block/qcow2.c > @@ -3681,7 +3681,7 @@ static BlockMeasureInfo *qcow2_measure(QemuOpts *opts, > BlockDriverState *in_bs, > has_backing_file = !!optstr; > g_free(optstr); > > - virtual_size = align_offset(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, > 0), > + virtual_size = ROUND_UP(qemu_opt_get_size_del(opts, BLOCK_OPT_SIZE, 0), > cluster_size); and again. With the whitespace fixed, Reviewed-by: Eric Blake <ebl...@redhat.com> -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature