mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
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.
This commit is contained in:
parent
274f09cbc5
commit
cd7ee20a68
@ -9411,16 +9411,17 @@ vshCommandRun(vshControl *ctl, const vshCmd *cmd)
|
|||||||
|
|
||||||
while (cmd) {
|
while (cmd) {
|
||||||
struct timeval before, after;
|
struct timeval before, after;
|
||||||
|
bool enable_timing = ctl->timing;
|
||||||
|
|
||||||
if ((ctl->conn == NULL) || (disconnected != 0))
|
if ((ctl->conn == NULL) || (disconnected != 0))
|
||||||
vshReconnect(ctl);
|
vshReconnect(ctl);
|
||||||
|
|
||||||
if (ctl->timing)
|
if (enable_timing)
|
||||||
GETTIMEOFDAY(&before);
|
GETTIMEOFDAY(&before);
|
||||||
|
|
||||||
ret = cmd->def->handler(ctl, cmd);
|
ret = cmd->def->handler(ctl, cmd);
|
||||||
|
|
||||||
if (ctl->timing)
|
if (enable_timing)
|
||||||
GETTIMEOFDAY(&after);
|
GETTIMEOFDAY(&after);
|
||||||
|
|
||||||
if (ret == FALSE)
|
if (ret == FALSE)
|
||||||
@ -9440,7 +9441,7 @@ vshCommandRun(vshControl *ctl, const vshCmd *cmd)
|
|||||||
if (STREQ(cmd->def->name, "quit")) /* hack ... */
|
if (STREQ(cmd->def->name, "quit")) /* hack ... */
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
if (ctl->timing)
|
if (enable_timing)
|
||||||
vshPrint(ctl, _("\n(Time: %.3f ms)\n\n"),
|
vshPrint(ctl, _("\n(Time: %.3f ms)\n\n"),
|
||||||
DIFF_MSEC(&after, &before));
|
DIFF_MSEC(&after, &before));
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user