[libvirt] [PATCH 2/2] conf: switch virDomainSchedulerFormat to use virXMLFormatElement

Andrea Bolognani abologna at redhat.com
Tue Apr 16 09:57:36 UTC 2019


On Mon, 2019-04-15 at 16:55 +0200, Ján Tomko wrote:
[...]
>      switch (sched->policy) {
>          case VIR_PROC_POLICY_BATCH:
>          case VIR_PROC_POLICY_IDLE:
> -            virBufferAsprintf(buf, "<%s "
> -                              "%s='%zu' scheduler='%s'/>\n",
> -                              elementName, idAttributeName, id,
> +            virBufferAsprintf(&attrBuf, " %s='%zu'", idAttributeName, id);
> +            virBufferAsprintf(&attrBuf, " scheduler='%s'",
>                                virProcessSchedPolicyTypeToString(sched->policy));

Since these two attributes (idAttributeName and 'scheduler') are
formatted the same way for the two cases below, how about replacing
the 'break' with 'ATTRIBUTE_FALLTHROUGH' to avoid repetition?

I'm also not sure why you turned a single call to virBufferAsprintf()
into two or three separate calls to it.

Looks good otherwise.

-- 
Andrea Bolognani / Red Hat / Virtualization




More information about the libvir-list mailing list