[PATCH 1/2] tools: virsh-domain: refactor variable initialization

Shaleen Bathla shaleen.bathla at oracle.com
Wed Apr 26 05:26:55 UTC 2023


Signed-off-by: Shaleen Bathla <shaleen.bathla at oracle.com>
---
 tools/virsh-domain.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 6850843a259f..165aa0ee0f19 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -1722,12 +1722,10 @@ static void
 virshPrintJobProgress(const char *label, unsigned long long remaining,
                       unsigned long long total)
 {
-    int progress;
+    int progress = 100;
 
-    if (remaining == 0) {
-        /* migration has completed */
-        progress = 100;
-    } else {
+    /* if remaining == 0 migration has completed */
+    if (remaining != 0) {
         /* use float to avoid overflow */
         progress = (int)(100.0 - remaining * 100.0 / total);
         if (progress >= 100) {
-- 
2.31.1



More information about the libvir-list mailing list