From: Jim Meyering Date: Wed, 14 Apr 2010 07:04:28 +0000 (+0200) Subject: vshCommandRun: avoid used-uninitialized timing-related report from clang X-Git-Tag: v0.8.1~148 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cd7ee20a68ea4ece11c52dec4b06bf6bd06e0e42;p=thirdparty%2Flibvirt.git vshCommandRun: avoid used-uninitialized timing-related report from clang * 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. --- diff --git a/tools/virsh.c b/tools/virsh.c index d5fe6c4b9e..b2a1538b80 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