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

[libvirt] [PATCH] Use virStrToLong_ui rather than virStrToLong_i where possible



Use the virStrToLong_ui() function rather than the virStrToLong_i()
where possible.

Signed-off-by: Stefan Berger <stefanb us ibm com>

---
 src/conf/nwfilter_conf.c |   33 +++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)

Index: libvirt-acl/src/conf/nwfilter_conf.c
===================================================================
--- libvirt-acl.orig/src/conf/nwfilter_conf.c
+++ libvirt-acl/src/conf/nwfilter_conf.c
@@ -1126,6 +1126,7 @@ virNWFilterRuleDetailsParse(virConnectPt
     enum virNWFilterEntryItemFlags *flags ,match_flag = 0, flags_set = 0;
     nwItemDesc *item;
     int int_val;
+    unsigned int uint_val;
     void *data_ptr, *storage_ptr;
     valueValidator validator;
     char *match = virXMLPropString(node, "match");
@@ -1175,12 +1176,12 @@ virNWFilterRuleDetailsParse(virConnectPt
 
                         case DATATYPE_UINT8:
                             storage_ptr = &item->u.u8;
-                            if (virStrToLong_i(prop, NULL, 10, &int_val) >= 0) {
-                                if (int_val >= 0 && int_val <= 0xff) {
+                            if (virStrToLong_ui(prop, NULL, 10, &uint_val) >= 0) {
+                                if (uint_val <= 0xff) {
                                     if (!validator)
-                                        *(uint8_t *)storage_ptr = int_val;
+                                        *(uint8_t *)storage_ptr = uint_val;
                                     found = 1;
-                                    data_ptr = &int_val;
+                                    data_ptr = &uint_val;
                                 } else
                                     rc = -1;
                             } else
@@ -1189,12 +1190,12 @@ virNWFilterRuleDetailsParse(virConnectPt
 
                         case DATATYPE_UINT16:
                             storage_ptr = &item->u.u16;
-                            if (virStrToLong_i(prop, NULL, 10, &int_val) >= 0) {
-                                if (int_val >= 0 && int_val <= 0xffff) {
+                            if (virStrToLong_ui(prop, NULL, 10, &uint_val) >= 0) {
+                                if (uint_val <= 0xffff) {
                                     if (!validator)
-                                        *(uint16_t *)storage_ptr = int_val;
+                                        *(uint16_t *)storage_ptr = uint_val;
                                     found = 1;
-                                    data_ptr = &int_val;
+                                    data_ptr = &uint_val;
                                 } else
                                     rc = -1;
                             } else
@@ -1212,13 +1213,13 @@ virNWFilterRuleDetailsParse(virConnectPt
 
                         case DATATYPE_IPMASK:
                             storage_ptr = &item->u.u8;
-                            if (virStrToLong_i(prop, NULL, 10, &int_val) == 0) {
-                                if (int_val >= 0 && int_val <= 32) {
+                            if (virStrToLong_ui(prop, NULL, 10, &uint_val) == 0) {
+                                if (uint_val <= 32) {
                                     if (!validator)
                                         *(uint8_t *)storage_ptr =
-                                               (uint8_t)int_val;
+                                               (uint8_t)uint_val;
                                     found = 1;
-                                    data_ptr = &int_val;
+                                    data_ptr = &uint_val;
                                 } else
                                     rc = -1;
                             } else {
@@ -1266,13 +1267,13 @@ virNWFilterRuleDetailsParse(virConnectPt
 
                         case DATATYPE_IPV6MASK:
                             storage_ptr = &item->u.u8;
-                            if (virStrToLong_i(prop, NULL, 10, &int_val) == 0) {
-                                if (int_val >= 0 && int_val <= 128) {
+                            if (virStrToLong_ui(prop, NULL, 10, &uint_val) == 0) {
+                                if (uint_val <= 128) {
                                     if (!validator)
                                         *(uint8_t *)storage_ptr =
-                                               (uint8_t)int_val;
+                                               (uint8_t)uint_val;
                                     found = 1;
-                                    data_ptr = &int_val;
+                                    data_ptr = &uint_val;
                                 } else
                                     rc = -1;
                             } else {


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