[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH v2 01/16] include: Move endof() up from hw/virti
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] [PATCH v2 01/16] include: Move endof() up from hw/virtio/virtio.h |
Date: |
Mon, 19 Aug 2019 14:06:41 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0 |
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 <address@hidden>
> ---
> 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 <address@hidden>
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3226
Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature
- [Qemu-devel] [PATCH v2 00/16] qcow2: Let check -r all repair some snapshot bits, Max Reitz, 2019/08/19
- [Qemu-devel] [PATCH v2 01/16] include: Move endof() up from hw/virtio/virtio.h, Max Reitz, 2019/08/19
- Re: [Qemu-devel] [PATCH v2 01/16] include: Move endof() up from hw/virtio/virtio.h,
Eric Blake <=
- [Qemu-devel] [PATCH v2 02/16] qcow2: Use endof(), Max Reitz, 2019/08/19
- [Qemu-devel] [PATCH v2 03/16] qcow2: Add Error ** to qcow2_read_snapshots(), Max Reitz, 2019/08/19
- [Qemu-devel] [PATCH v2 04/16] qcow2: Keep unknown extra snapshot data, Max Reitz, 2019/08/19
- [Qemu-devel] [PATCH v2 05/16] qcow2: Make qcow2_write_snapshots() public, Max Reitz, 2019/08/19
- [Qemu-devel] [PATCH v2 06/16] qcow2: Put qcow2_upgrade() into its own function, Max Reitz, 2019/08/19