[ruby PATCH] Fix default values for node_cpu_stats() and node_memory_stats()

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

 



ruby_libvirt_value_to_int() returns 0 if the optional value is
not defined, but in node_cpu_stats() and node_memory_stats()
the default value of cpuNum and cellNum is -1.

Reported-by: Charlie Smurthwaite <charlie@atech.media>
Signed-off-by: Stefano Garzarella <sgarzare@xxxxxxxxxx>
---
 ext/libvirt/connect.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/ext/libvirt/connect.c b/ext/libvirt/connect.c
index 5932535..b2d041b 100644
--- a/ext/libvirt/connect.c
+++ b/ext/libvirt/connect.c
@@ -2079,7 +2079,12 @@ static VALUE libvirt_connect_node_cpu_stats(int argc, VALUE *argv, VALUE c)
 
     rb_scan_args(argc, argv, "02", &intparam, &flags);
 
-    tmp = ruby_libvirt_value_to_int(intparam);
+    if (NIL_P(intparam)) {
+        tmp = -1;
+    }
+    else {
+        tmp = ruby_libvirt_value_to_int(intparam);
+    }
 
     return ruby_libvirt_get_parameters(c, ruby_libvirt_value_to_uint(flags),
                                        (void *)&tmp, sizeof(virNodeCPUStats),
@@ -2139,7 +2144,12 @@ static VALUE libvirt_connect_node_memory_stats(int argc, VALUE *argv, VALUE c)
 
     rb_scan_args(argc, argv, "02", &intparam, &flags);
 
-    tmp = ruby_libvirt_value_to_int(intparam);
+    if (NIL_P(intparam)) {
+        tmp = -1;
+    }
+    else {
+        tmp = ruby_libvirt_value_to_int(intparam);
+    }
 
     return ruby_libvirt_get_parameters(c, ruby_libvirt_value_to_uint(flags),
                                        (void *)&tmp, sizeof(virNodeMemoryStats),
-- 
2.21.0

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