]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
storage: Resolve Coverity OVERFLOW_BEFORE_WIDEN
authorJohn Ferlan <jferlan@redhat.com>
Thu, 4 Sep 2014 14:34:43 +0000 (10:34 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Thu, 11 Sep 2014 11:33:19 +0000 (07:33 -0400)
Coverity complains that when multiplying to 32 bit values that eventually
will be stored in a 64 bit value that it's possible the math could
overflow unless one of the values being multiplied is type cast to
the proper size.

Signed-off-by: John Ferlan <jferlan@redhat.com>
src/storage/storage_backend_disk.c

index cb6a8d54696ea761180d2feeb7279626727d728b..abab1e19d6f0215a69f21ab35f17f363394e5443 100644 (file)
@@ -560,7 +560,7 @@ virStorageBackendDiskPartBoundaries(virStoragePoolObjPtr pool,
     unsigned long long extraBytes = 0;
     unsigned long long alignedAllocation = allocation;
     virStoragePoolSourceDevicePtr dev = &pool->def->source.devices[0];
-    unsigned long long cylinderSize = dev->geometry.heads *
+    unsigned long long cylinderSize = (unsigned long long)dev->geometry.heads *
                                       dev->geometry.sectors * SECTOR_SIZE;
 
     VIR_DEBUG("find free area: allocation %llu, cyl size %llu", allocation,