[Libguestfs] [PATCH nbdkit] server: Remove tricksy initialization of struct b_conn_handle.

Eric Blake eblake at redhat.com
Thu Sep 19 13:17:16 UTC 2019


On 9/19/19 7:56 AM, Richard W.M. Jones wrote:
> b_conn_handle fields exportsize and can_* have a special meaning when
> they are -1.  It means that the value of the field has not been
> computed and cached yet.
> 
> The struct was being initialized using memset (_, -1, _) which does
> indeed have the effect of setting all the fields to -1, although it's
> somewhat non-obvious to say the least.
> 
> This commit replaces it with ordinary field initialization, also
> setting h->handle to NULL.  By keeping the initialization function
> next to the struct definition, hopefully they will be updated in
> tandem in future.
> 
> GCC 9.2.1 actually optimizes this back into the memset equivalent
> using inline AVX instructions, so good job there!
> 
> Simple refactoring, should have no effect on how the code works.
> 
> See commit d60d0f4248610fc1d116dc9f249526d20913c9a3.

ACK. And affects 3 and 4 of my pending spec cleanup patches, but yours
should go in first (I'll rebase mine, because I'm working on refactoring
those for less code duplication anyway).

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libguestfs/attachments/20190919/c9e4b116/attachment.sig>


More information about the Libguestfs mailing list