[libvirt] [PATCH 1/5] vshCommandRun: avoid used-uninitialized timing-related report from clang

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Jim Meyering <meyering@xxxxxxxxxx>

* tools/virsh.c (vshCommandRun): Test only the initial value of
ctl->timing, so that static analyzers don't have to consider that
it might be changed by cmd->def->handler.
---
 tools/virsh.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index d5fe6c4..b2a1538 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -9411,16 +9411,17 @@ vshCommandRun(vshControl *ctl, const vshCmd *cmd)

     while (cmd) {
         struct timeval before, after;
+        bool enable_timing = ctl->timing;

         if ((ctl->conn == NULL) || (disconnected != 0))
             vshReconnect(ctl);

-        if (ctl->timing)
+        if (enable_timing)
             GETTIMEOFDAY(&before);

         ret = cmd->def->handler(ctl, cmd);

-        if (ctl->timing)
+        if (enable_timing)
             GETTIMEOFDAY(&after);

         if (ret == FALSE)
@@ -9440,7 +9441,7 @@ vshCommandRun(vshControl *ctl, const vshCmd *cmd)
         if (STREQ(cmd->def->name, "quit"))        /* hack ... */
             return ret;

-        if (ctl->timing)
+        if (enable_timing)
             vshPrint(ctl, _("\n(Time: %.3f ms)\n\n"),
                      DIFF_MSEC(&after, &before));
         else
-- 
1.7.1.rc1.248.gcefbb

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]