mirror of https://gitee.com/openkylin/libvirt.git
Remove superfluous usage of virDomainDeviceInfoNeedsFormat
This function returns false if virDomainDeviceInfoFormat would not format anything. Using it as the sole condition to decide whether to call virDomainDeviceInfoFormat or not is pointless, since the conditions are repeated in virDomainDeviceInfoFormat.
This commit is contained in:
parent
2403dcce51
commit
6233e7bb74
|
@ -21916,8 +21916,7 @@ virDomainControllerDefFormat(virBufferPtr buf,
|
||||||
|
|
||||||
virDomainControllerDriverFormat(&childBuf, def);
|
virDomainControllerDriverFormat(&childBuf, def);
|
||||||
|
|
||||||
if (virDomainDeviceInfoNeedsFormat(&def->info, flags) &&
|
if (virDomainDeviceInfoFormat(&childBuf, &def->info, flags) < 0)
|
||||||
virDomainDeviceInfoFormat(&childBuf, &def->info, flags) < 0)
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI &&
|
if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI &&
|
||||||
|
@ -23053,10 +23052,8 @@ virDomainChrDefFormat(virBufferPtr buf,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virDomainDeviceInfoNeedsFormat(&def->info, flags)) {
|
if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
|
||||||
if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
|
return -1;
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
virBufferAdjustIndent(buf, -2);
|
virBufferAdjustIndent(buf, -2);
|
||||||
virBufferAsprintf(buf, "</%s>\n", elementName);
|
virBufferAsprintf(buf, "</%s>\n", elementName);
|
||||||
|
@ -23158,10 +23155,8 @@ virDomainTPMDefFormat(virBufferPtr buf,
|
||||||
virBufferAdjustIndent(buf, -2);
|
virBufferAdjustIndent(buf, -2);
|
||||||
virBufferAddLit(buf, "</backend>\n");
|
virBufferAddLit(buf, "</backend>\n");
|
||||||
|
|
||||||
if (virDomainDeviceInfoNeedsFormat(&def->info, flags)) {
|
if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
|
||||||
if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
|
return -1;
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
virBufferAdjustIndent(buf, -2);
|
virBufferAdjustIndent(buf, -2);
|
||||||
virBufferAddLit(buf, "</tpm>\n");
|
virBufferAddLit(buf, "</tpm>\n");
|
||||||
|
@ -23243,8 +23238,7 @@ virDomainMemballoonDefFormat(virBufferPtr buf,
|
||||||
if (def->period)
|
if (def->period)
|
||||||
virBufferAsprintf(&childrenBuf, "<stats period='%i'/>\n", def->period);
|
virBufferAsprintf(&childrenBuf, "<stats period='%i'/>\n", def->period);
|
||||||
|
|
||||||
if (virDomainDeviceInfoNeedsFormat(&def->info, flags) &&
|
if (virDomainDeviceInfoFormat(&childrenBuf, &def->info, flags) < 0) {
|
||||||
virDomainDeviceInfoFormat(&childrenBuf, &def->info, flags) < 0) {
|
|
||||||
virBufferFreeAndReset(&childrenBuf);
|
virBufferFreeAndReset(&childrenBuf);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -23283,8 +23277,7 @@ virDomainNVRAMDefFormat(virBufferPtr buf,
|
||||||
{
|
{
|
||||||
virBufferAddLit(buf, "<nvram>\n");
|
virBufferAddLit(buf, "<nvram>\n");
|
||||||
virBufferAdjustIndent(buf, 2);
|
virBufferAdjustIndent(buf, 2);
|
||||||
if (virDomainDeviceInfoNeedsFormat(&def->info, flags) &&
|
if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
|
||||||
virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
|
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
virBufferAdjustIndent(buf, -2);
|
virBufferAdjustIndent(buf, -2);
|
||||||
|
@ -23443,10 +23436,8 @@ virDomainRNGDefFormat(virBufferPtr buf,
|
||||||
virBufferAddLit(buf, "/>\n");
|
virBufferAddLit(buf, "/>\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virDomainDeviceInfoNeedsFormat(&def->info, flags)) {
|
if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
|
||||||
if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
|
return -1;
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
virBufferAdjustIndent(buf, -2);
|
virBufferAdjustIndent(buf, -2);
|
||||||
virBufferAddLit(buf, "</rng>\n");
|
virBufferAddLit(buf, "</rng>\n");
|
||||||
|
@ -23564,10 +23555,8 @@ virDomainMemoryDefFormat(virBufferPtr buf,
|
||||||
|
|
||||||
virDomainMemoryTargetDefFormat(buf, def);
|
virDomainMemoryTargetDefFormat(buf, def);
|
||||||
|
|
||||||
if (virDomainDeviceInfoNeedsFormat(&def->info, flags)) {
|
if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
|
||||||
if (virDomainDeviceInfoFormat(buf, &def->info, flags) < 0)
|
return -1;
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
virBufferAdjustIndent(buf, -2);
|
virBufferAdjustIndent(buf, -2);
|
||||||
virBufferAddLit(buf, "</memory>\n");
|
virBufferAddLit(buf, "</memory>\n");
|
||||||
|
|
Loading…
Reference in New Issue