[PATCH] build: avoid 32-bit failure on older gcc

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

 



On 32-bit platforms with old gcc (hello RHEL 5 gcc 4.1.2), the
build fails with:
virsh-domain.c: In function 'cmdBlockCopy':
virsh-domain.c:2172: warning: comparison is always false due to limited range of data type

Adjust the code to silence the warning.

* tools/virsh-domain.c (cmdBlockCopy): Pacify RHEL 5 gcc.

Signed-off-by: Eric Blake <eblake@xxxxxxxxxx>
---

Pushing under the build-breaker rule.

 tools/virsh-domain.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index 7184784..cf45a88 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -2169,7 +2169,8 @@ cmdBlockCopy(vshControl *ctl, const vshCmd *cmd)
             if (bandwidth) {
                 /* bandwidth is ulong MiB/s, but the typed parameter is
                  * ullong bytes/s; make sure we don't overflow */
-                if (bandwidth + 0ULL > ULLONG_MAX >> 20) {
+                unsigned long long limit = MIN(ULONG_MAX, ULLONG_MAX >> 20);
+                if (bandwidth > limit) {
                     virReportError(VIR_ERR_OVERFLOW,
                                    _("bandwidth must be less than %llu"),
                                    ULLONG_MAX >> 20);
-- 
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]

  Powered by Linux