From d063389f10707a6694fb98a69f403a63e4d22245 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1n=20Tomko?= Date: Thu, 20 Apr 2023 15:57:24 +0200 Subject: [PATCH] conf: storage: remove redundant condition MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We exit early if poolOptions->formatToString is false. Fixes: 9dadc7302920f9fca0057c655d03c2b0206b9a70 Signed-off-by: Ján Tomko Reviewed-by: Pavel Hrdina --- src/conf/storage_conf.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index 3e584ad9b9..68842004b7 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -364,6 +364,7 @@ virStoragePoolOptionsFormatPool(virBuffer *buf, int type) { virStoragePoolOptions *poolOptions; + size_t i; if (!(poolOptions = virStoragePoolOptionsForPoolType(type))) return -1; @@ -374,22 +375,17 @@ virStoragePoolOptionsFormatPool(virBuffer *buf, virBufferAddLit(buf, "\n"); virBufferAdjustIndent(buf, 2); - if (poolOptions->formatToString) { - size_t i; + virBufferAsprintf(buf, "\n", + (poolOptions->formatToString)(poolOptions->defaultFormat)); - virBufferAsprintf(buf, "\n", - (poolOptions->formatToString)(poolOptions->defaultFormat)); + virBufferAddLit(buf, "\n"); + virBufferAdjustIndent(buf, 2); - virBufferAddLit(buf, "\n"); - virBufferAdjustIndent(buf, 2); + for (i = 0; i < poolOptions->lastFormat; i++) + virBufferAsprintf(buf, "%s\n", (poolOptions->formatToString)(i)); - for (i = 0; i < poolOptions->lastFormat; i++) - virBufferAsprintf(buf, "%s\n", - (poolOptions->formatToString)(i)); - - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); - } + virBufferAdjustIndent(buf, -2); + virBufferAddLit(buf, "\n"); virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "\n");