[PATCH] conf: use proper maximum for parsing memory values

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

 



The value is stored in unsigned long long, so ULLONG_MAX is the proper
upper limit to use.

Signed-off-by: Martin Kletzander <mkletzan@xxxxxxxxxx>
---
Even though this is a build-breaker (for 32bit systems
memtune-unlimited fails to parse), I'm not pushing it as one because
it feels odd that such change wouldn't break anything else.

 src/conf/domain_conf.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index a351382..beb3d26 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -6388,16 +6388,10 @@ virDomainParseMemory(const char *xpath, xmlXPathContextPtr ctxt,
                      unsigned long long *mem, bool required)
 {
     int ret = -1;
-    unsigned long long bytes, max;
-
-    /* On 32-bit machines, our bound is 0xffffffff * KiB. On 64-bit
-     * machines, our bound is off_t (2^63).  */
-    if (sizeof(unsigned long) < sizeof(long long))
-        max = 1024ull * ULONG_MAX;
-    else
-        max = LLONG_MAX;
+    unsigned long long bytes;

-    ret = virDomainParseScaledValue(xpath, ctxt, &bytes, 1024, max, required);
+    ret = virDomainParseScaledValue(xpath, ctxt, &bytes, 1024,
+                                    ULLONG_MAX, required);
     if (ret < 0)
         goto cleanup;

--
2.1.2

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