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

For the "while (rem < 0)", the value of 'rem' must be between
0 and 86399 (SECS_PER_DAY = 86400ULL). Thus, the addition of
offset (0) does nothing and the while (rem < 0) is pointless.

For the "while (rem > SECS_PER_DAY)", we have the same issue.

Signed-off-by: John Ferlan <[email protected]>
---
 src/util/virtime.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/util/virtime.c b/src/util/virtime.c
index 9fefb67..99c7cf6 100644
--- a/src/util/virtime.c
+++ b/src/util/virtime.c
@@ -135,10 +135,12 @@ void virTimeFieldsThen(unsigned long long when, struct tm 
*fields)
     days = whenSecs / SECS_PER_DAY;
     rem = whenSecs % SECS_PER_DAY;
     rem += offset;
+    /* coverity[dead_error_condition] - when offset is calculated remove this 
*/
     while (rem < 0) {
         rem += SECS_PER_DAY;
         --days;
     }
+    /* coverity[dead_error_condition] - when offset is calculated remove this 
*/
     while (rem >= SECS_PER_DAY) {
         rem -= SECS_PER_DAY;
         ++days;
-- 
1.9.3

--
libvir-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/libvir-list

Reply via email to