From 945eab406093f79e76aeb30ab8fe9b6b5d92aa3c Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Thu, 7 Mar 2019 17:48:08 +0100 Subject: [PATCH] conf: Avoid temporary variable in virDomainDiskBackingStoreFormat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Modify the check that the format is in range to be standalone and use the convertor function directly. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- src/conf/domain_conf.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index bbcc618001..940ef5aee7 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -23826,7 +23826,6 @@ virDomainDiskBackingStoreFormat(virBufferPtr buf, virDomainXMLOptionPtr xmlopt, unsigned int flags) { - const char *format; bool inactive = flags & VIR_DOMAIN_DEF_FORMAT_INACTIVE; if (!backingStore) @@ -23841,8 +23840,7 @@ virDomainDiskBackingStoreFormat(virBufferPtr buf, return 0; } - if (backingStore->format <= 0 || - !(format = virStorageFileFormatTypeToString(backingStore->format))) { + if (backingStore->format <= 0 || backingStore->format >= VIR_STORAGE_FILE_LAST) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unexpected disk backing store format %d"), backingStore->format); @@ -23856,7 +23854,8 @@ virDomainDiskBackingStoreFormat(virBufferPtr buf, virBufferAddLit(buf, ">\n"); virBufferAdjustIndent(buf, 2); - virBufferAsprintf(buf, "\n", format); + virBufferAsprintf(buf, "\n", + virStorageFileFormatTypeToString(backingStore->format)); if (virDomainDiskSourceFormat(buf, backingStore, 0, false, flags, xmlopt) < 0 || virDomainDiskBackingStoreFormat(buf, backingStore->backingStore, xmlopt, flags) < 0)