On 8/19/19 1:55 PM, Max Reitz wrote: > endof() is a useful macro, we can make use of it outside of virtio. > > Signed-off-by: Max Reitz <mre...@redhat.com> > --- > include/hw/virtio/virtio.h | 7 ------- > include/qemu/compiler.h | 7 +++++++ > hw/block/virtio-blk.c | 4 ++-- > hw/net/virtio-net.c | 10 +++++----- > 4 files changed, 14 insertions(+), 14 deletions(-) >
> +++ b/include/qemu/compiler.h > @@ -60,6 +60,13 @@ > > #define sizeof_field(type, field) sizeof(((type *)0)->field) > > +/* > + * Calculate the number of bytes up to and including the given 'field' of > + * 'container'. > + */ > +#define endof(container, field) \ > + (offsetof(container, field) + sizeof_field(container, field)) Bike-shedding: I might have done s/container/type/ as part of the motion, to match the above definition of sizeof_field (and in C, we tend to refer to 'type's, not 'container's). But doesn't affect correctness of the patch. Reviewed-by: Eric Blake <ebl...@redhat.com> -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature