Re: [PATCH 02/11] keepalive: Resolve Coverity complaint

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

 



On 2013年01月31日 03:36, John Ferlan wrote:
The Coverity analysis emitted a BAD_SIZEOF error when doing the math
within the TRACE macro. Doing the math outside the macro keeps Coverity quiet.
---
  src/rpc/virkeepalive.c | 14 +++++++-------
  1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/rpc/virkeepalive.c b/src/rpc/virkeepalive.c
index f57fed4..d1fa642 100644
--- a/src/rpc/virkeepalive.c
+++ b/src/rpc/virkeepalive.c
@@ -1,7 +1,7 @@
  /*
   * virkeepalive.c: keepalive handling
   *
- * Copyright (C) 2011 Red Hat, Inc.
+ * Copyright (C) 2011-2013 Red Hat, Inc.
   *
   * This library is free software; you can redistribute it and/or
   * modify it under the terms of the GNU Lesser General Public
@@ -117,28 +117,28 @@ virKeepAliveTimerInternal(virKeepAlivePtr ka,
                            virNetMessagePtr *msg)
  {
      time_t now = time(NULL);
+    int timeval;

      if (ka->interval<= 0 || ka->intervalStart == 0)
          return false;

      if (now - ka->intervalStart<  ka->interval) {
-        int timeout = ka->interval - (now - ka->intervalStart);
-        virEventUpdateTimeout(ka->timer, timeout * 1000);
+        timeval = ka->interval - (now - ka->intervalStart);
+        virEventUpdateTimeout(ka->timer, timeval * 1000);
          return false;
      }

+    timeval = now - ka->lastPacketReceived;
      PROBE(RPC_KEEPALIVE_TIMEOUT,
            "ka=%p client=%p countToDeath=%d idle=%d",
-          ka, ka->client, ka->countToDeath,
-          (int) (now - ka->lastPacketReceived));
-
+          ka, ka->client, ka->countToDeath, timeval);

      if (ka->countToDeath == 0) {
          VIR_WARN("No response from client %p after %d keepalive messages in"
                   " %d seconds",
                   ka->client,
                   ka->count,
-                 (int) (now - ka->lastPacketReceived));
+                 timeval);
          return true;
      } else {
          ka->countToDeath--;

ACK

--
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]