[libvirt] [PATCH 6/6] Implement VNC password change in QEMU

Eric Blake eblake at redhat.com
Mon Mar 22 21:21:06 UTC 2010


On 03/22/2010 01:05 PM, Daniel P. Berrange wrote:
> Use the new virDomainUpdateDeviceFlags API to allow the VNC password
> to be changed on the fly
> 
> * src/internal.h: Define STREQ_NULLABLE() which is like STREQ()
>   but does not crash if either argument is NULL, and treats two
>   NULLs as equal.
...

> +++ b/src/internal.h
> @@ -58,6 +58,12 @@
>  # define STRCASENEQLEN(a,b,n) (strncasecmp(a,b,n) != 0)
>  # define STRPREFIX(a,b) (strncmp(a,b,strlen(b)) == 0)
>  
> +# define STREQ_NULLABLE(a, b)                   \
> +    ((!a && !b) || (a && b && STREQ(a, b)))
> +# define STRNEQ_NULLABLE(a, b)                  \
> +    ((!a && b) || (a && !b) || (a && b && STRNEQ(a, b)))

This seems like an independently useful change, and one worth
documenting in docs/hacking.html.in next to the existing documentation
on STREQ.  It also has a bug - it is under-parenthesized.  And you can
use ^ for compactness:

# define STREQ_NULLABLE(a, b)                   \
    ((!(a) && !(b)) || ((a) && (b) && STREQ(a, b)))
# define STRNEQ_NULLABLE(a, b)                  \
    ((!(a) ^ !(b)) || ((a) && (b) && STRNEQ(a, b)))

Hmmm.  The existing STREQ and STRNEQ only evaluate arguments once, but
this evaluates arguments multiple times.  Then again, so does the
existing STRPREFIX.  Are any of these three worth making static inline
functions, rather than macros, to avoid side-effects of multiple evaluation?

I did not closely review the rest of the patch.

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 323 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20100322/3da83ac8/attachment-0001.sig>


More information about the libvir-list mailing list