[libvirt] [PATCH v2 1/6] tests: qemuxml2xml: Set name in testQemuInfo

Andrea Bolognani abologna at redhat.com
Tue Apr 16 08:36:49 UTC 2019


On Mon, 2019-04-15 at 19:09 -0400, Cole Robinson wrote:
[...]
> @@ -148,7 +146,6 @@ mymain(void)
>  {
>      int ret = 0;
>      char *fakerootdir;
> -    struct testQemuInfo info;
>      virQEMUDriverConfigPtr cfg = NULL;
>      virHashTablePtr capslatest = NULL;
>  
> @@ -168,39 +165,40 @@ mymain(void)
>  
>      setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, 1);
>  
> -    memset(&info, 0, sizeof(info));
> -
>      if (qemuTestDriverInit(&driver) < 0)
>          return EXIT_FAILURE;
>  
>      cfg = virQEMUDriverGetConfig(&driver);
>  
> -# define DO_TEST_FULL(name, when, ...) \
> +# define DO_TEST_FULL(_name, when, ...) \
>      do { \
> +        static struct testQemuInfo info = { \
> +            .name = _name, \
> +        }; \

Since we're calling testQemuInfoClear() at the end of the macro
already, we could probably avoid creating a new structure every
single time and reuse the same one over and over again, as this test
was doing. But we can do that in a later patch, and now that the
code is identical between xml2argv and xml2xml it's gonna be easier
to change both at the same time.

Reviewed-by: Andrea Bolognani <abologna at redhat.com>

-- 
Andrea Bolognani / Red Hat / Virtualization




More information about the libvir-list mailing list