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

[libvirt] [PATCH 2/8] virtime: Resolve Coverity DEADCODE



Coverity complains that because of how 'offset' is initialized to
0 (zero), the resulting math and comparison on rem is pointless.

According to the origin commit id '3ec128989', the code is a
replacement for gmtime(), but without the localtime() or GMT
calculations - so just remove this code and add a comment
indicating the removal

Signed-off-by: John Ferlan <jferlan redhat com>
---
 src/util/virtime.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/src/util/virtime.c b/src/util/virtime.c
index 9fefb67..acbec41 100644
--- a/src/util/virtime.c
+++ b/src/util/virtime.c
@@ -127,22 +127,16 @@ const unsigned short int __mon_yday[2][13] = {
 void virTimeFieldsThen(unsigned long long when, struct tm *fields)
 {
     /* This code is taken from GLibC under terms of LGPLv2+ */
+    /* Remove the 'offset' or GMT manipulation since we don't care. See
+     * commit id '3ec12898' comments regarding localtime.
+     */
     long int days, rem, y;
     const unsigned short int *ip;
     unsigned long long whenSecs = when / 1000ull;
-    unsigned int offset = 0; /* We hardcoded GMT */
 
     days = whenSecs / SECS_PER_DAY;
     rem = whenSecs % SECS_PER_DAY;
-    rem += offset;
-    while (rem < 0) {
-        rem += SECS_PER_DAY;
-        --days;
-    }
-    while (rem >= SECS_PER_DAY) {
-        rem -= SECS_PER_DAY;
-        ++days;
-    }
+
     fields->tm_hour = rem / SECS_PER_HOUR;
     rem %= SECS_PER_HOUR;
     fields->tm_min = rem / 60;
-- 
1.9.3


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