From bc817ddfdd4283f786d59335e981fa8e2814aca9 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Tue, 5 Mar 2019 10:17:31 +0100 Subject: [PATCH] conf: Refactor virDomainPanicDefFormat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use virXMLFormatElement to format the internals along with simplifying cleanup code paths. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- src/conf/domain_conf.c | 28 +++++----------------------- 1 file changed, 5 insertions(+), 23 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index ed480bcf8e..766846a557 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -25921,36 +25921,18 @@ virDomainWatchdogDefFormat(virBufferPtr buf, static int virDomainPanicDefFormat(virBufferPtr buf, virDomainPanicDefPtr def) { - virBuffer childrenBuf = VIR_BUFFER_INITIALIZER; - int ret = -1; - - virBufferAddLit(buf, "model) - virBufferAsprintf(buf, " model='%s'", + virBufferAsprintf(&attrBuf, " model='%s'", virDomainPanicModelTypeToString(def->model)); virBufferSetChildIndent(&childrenBuf, buf); if (virDomainDeviceInfoFormat(&childrenBuf, &def->info, 0) < 0) - goto cleanup; + return -1; - if (virBufferCheckError(&childrenBuf) < 0) - goto cleanup; - - if (virBufferUse(&childrenBuf)) { - virBufferAddLit(buf, ">\n"); - virBufferAddBuffer(buf, &childrenBuf); - virBufferAddLit(buf, "\n"); - } else { - virBufferAddLit(buf, "/>\n"); - } - - ret = 0; - - cleanup: - virBufferFreeAndReset(&childrenBuf); - - return ret; + return virXMLFormatElement(buf, "panic", &attrBuf, &childrenBuf); } static int