From 73c1e87e6a1a6687bd24aeebe62a2b3ecd1ffb65 Mon Sep 17 00:00:00 2001 From: Peter Krempa Date: Thu, 7 Dec 2023 12:48:15 +0100 Subject: [PATCH] virNodeDeviceCapStorageDefFormat: Don't check argument for virBufferEscapeString MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit virBufferEscapeString is specifically designed for formatting XMLs and thus skips the whole formatting if the singular string argument is NULL. Remove redundant conditions. Signed-off-by: Peter Krempa Reviewed-by: Ján Tomko --- src/conf/node_device_conf.c | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index f722ab37c6..64bece59aa 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -540,23 +540,13 @@ static void virNodeDeviceCapStorageDefFormat(virBuffer *buf, const virNodeDevCapData *data) { - virBufferEscapeString(buf, "%s\n", - data->storage.block); - if (data->storage.bus) - virBufferEscapeString(buf, "%s\n", - data->storage.bus); - if (data->storage.drive_type) - virBufferEscapeString(buf, "%s\n", - data->storage.drive_type); - if (data->storage.model) - virBufferEscapeString(buf, "%s\n", - data->storage.model); - if (data->storage.vendor) - virBufferEscapeString(buf, "%s\n", - data->storage.vendor); - if (data->storage.serial) - virBufferEscapeString(buf, "%s\n", - data->storage.serial); + virBufferEscapeString(buf, "%s\n", data->storage.block); + virBufferEscapeString(buf, "%s\n", data->storage.bus); + virBufferEscapeString(buf, "%s\n", data->storage.drive_type); + virBufferEscapeString(buf, "%s\n", data->storage.model); + virBufferEscapeString(buf, "%s\n", data->storage.vendor); + virBufferEscapeString(buf, "%s\n", data->storage.serial); + if (data->storage.flags & VIR_NODE_DEV_CAP_STORAGE_REMOVABLE) { int avl = data->storage.flags & VIR_NODE_DEV_CAP_STORAGE_REMOVABLE_MEDIA_AVAILABLE; @@ -566,10 +556,7 @@ virNodeDeviceCapStorageDefFormat(virBuffer *buf, "\n", avl ? 1 : 0); virBufferAsprintf(buf, "%llu\n", data->storage.removable_media_size); - if (data->storage.media_label) - virBufferEscapeString(buf, - "%s\n", - data->storage.media_label); + virBufferEscapeString(buf, "%s\n", data->storage.media_label); if (data->storage.logical_block_size > 0) virBufferAsprintf(buf, "%llu" "\n",