[PATCH 9/9] virstoragefile: Resolve Coverity DEADCODE

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

 



Coverity complains that the condition "size + 1 == 0" cannot happen.
Since 'size' is unsigned 32bit value set using virReadBufInt32BE.
Thus rather than + 1, it seems the comparison should be is it at
max now and if so, return the failure.

Signed-off-by: John Ferlan <jferlan@xxxxxxxxxx>
---
 src/util/virstoragefile.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c
index 299edcd..0219ce8 100644
--- a/src/util/virstoragefile.c
+++ b/src/util/virstoragefile.c
@@ -393,7 +393,7 @@ qcowXGetBackingStore(char **res,
     }
     if (offset + size > buf_size || offset + size < offset)
         return BACKING_STORE_INVALID;
-    if (size + 1 == 0)
+    if (size == UINT_MAX)
         return BACKING_STORE_INVALID;
     if (VIR_ALLOC_N(*res, size + 1) < 0)
         return BACKING_STORE_ERROR;
-- 
1.9.3

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