Re: [PATCH 2/2] domain_conf: Use virXMLFormatElement*() more in virDomainDefFormatFeatures()

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

 



On Tue, Dec 14, 2021 at 03:01:19PM +0100, Michal Privoznik wrote:
>              case VIR_TRISTATE_SWITCH_ON:
> -               virBufferAsprintf(&childBuf, "<%s state='on'/>\n", name);
> -               break;
> -
>              case VIR_TRISTATE_SWITCH_OFF:
> -               virBufferAsprintf(&childBuf, "<%s state='off'/>\n", name);
> -               break;
> +                virBufferAsprintf(&tmpAttrBuf, " state='%s'",
> +                                  virTristateSwitchTypeToString(def->features[i]));
> +
> +                virXMLFormatElement(&childBuf, name, &tmpAttrBuf, NULL);
> +                break;

You even fixed indentation as a side effect! Very nice :)

>          case VIR_DOMAIN_FEATURE_GIC:
>              if (def->features[i] == VIR_TRISTATE_SWITCH_ON) {
> -                virBufferAddLit(&childBuf, "<gic");
>                  if (def->gic_version != VIR_GIC_VERSION_NONE)
> -                    virBufferAsprintf(&childBuf, " version='%s'",
> +                    virBufferAsprintf(&tmpAttrBuf, " version='%s'",
>                                        virGICVersionTypeToString(def->gic_version));
> -                virBufferAddLit(&childBuf, "/>\n");
> +                virXMLFormatElementEmpty(&childBuf, "gic", &tmpAttrBuf, NULL);

I think either adding an empty line before virXMLFormatElementEmpty()
or braces around the check on def->gic_version would improve
readability.

Regardless

  Reviewed-by: Andrea Bolognani <abologna@xxxxxxxxxx>

-- 
Andrea Bolognani / Red Hat / Virtualization




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux