qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCHv3 20/20] block/raw: copy BlockLimits on raw_open


From: Eric Blake
Subject: Re: [Qemu-devel] [PATCHv3 20/20] block/raw: copy BlockLimits on raw_open
Date: Wed, 02 Oct 2013 11:11:05 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130923 Thunderbird/17.0.9

On 09/24/2013 07:35 AM, Peter Lieven wrote:
> Signed-off-by: Peter Lieven <address@hidden>
> ---
>  block/raw_bsd.c |    1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/block/raw_bsd.c b/block/raw_bsd.c
> index 8dc7bba..7af26ad 100644
> --- a/block/raw_bsd.c
> +++ b/block/raw_bsd.c
> @@ -159,6 +159,7 @@ static int raw_open(BlockDriverState *bs, QDict *options, 
> int flags,
>                      Error **errp)
>  {
>      bs->sg = bs->file->sg;
> +    memcpy(&bs->bl, &bs->file->bl, sizeof(struct BlockLimits));

Personally, I think that sizeof(var) is more robust, because if the
declaration of var is ever changed, you don't have to remember to also
touch up the memcpy.  As in:

memcpy(&bs->bl, &bs->file->bl, sizeof(bs->bl));

But there's plenty of examples of sizeof(type) in the codebase even when
a var is handy, so you are not alone, and that's not a reason for me to
request a respin.

On the other hand, why use memcpy() at all?

bs->bl = bs->file->bl;

should do the same trick, with less typing.

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]