[PATCHv3 1/2] virsh: Reject negative numbers in vshCommandOptUInt

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

 



Use virStrToLong_uip instead of virStrToLong_ui to reject negative
numbers in the helper. None of the callers expects the wraparound
"feature" for negative numbers.

Also be explicit about the new semantics in the function docs.
---
 tools/virsh.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index 15f3025..483dc04 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -1501,7 +1501,7 @@ vshCommandOptInt(const vshCmd *cmd, const char *name, int *value)
  * @name option name
  * @value result
  *
- * Convert option to unsigned int
+ * Convert option to unsigned int, reject negative numbers
  * See vshCommandOptInt()
  */
 int
@@ -1514,7 +1514,7 @@ vshCommandOptUInt(const vshCmd *cmd, const char *name, unsigned int *value)
     if (ret <= 0)
         return ret;

-    if (virStrToLong_ui(arg->data, NULL, 10, value) < 0)
+    if (virStrToLong_uip(arg->data, NULL, 10, value) < 0)
         return -1;
     return 1;
 }
-- 
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]