From 8d30e5f74d51bf3db605f2544b5a48e5dd483a55 Mon Sep 17 00:00:00 2001 From: Stefan Berger Date: Fri, 2 Apr 2010 15:02:27 -0400 Subject: [PATCH] Use the virStrToLong_ui() function rather than the virStrToLong_i() where possible. --- src/conf/nwfilter_conf.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c index a961f1606f..08934fb0af 100644 --- a/src/conf/nwfilter_conf.c +++ b/src/conf/nwfilter_conf.c @@ -1125,6 +1125,7 @@ virNWFilterRuleDetailsParse(virConnectPtr conn ATTRIBUTE_UNUSED, 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"); @@ -1174,12 +1175,12 @@ virNWFilterRuleDetailsParse(virConnectPtr conn ATTRIBUTE_UNUSED, 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 @@ -1188,12 +1189,12 @@ virNWFilterRuleDetailsParse(virConnectPtr conn ATTRIBUTE_UNUSED, 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 @@ -1211,13 +1212,13 @@ virNWFilterRuleDetailsParse(virConnectPtr conn ATTRIBUTE_UNUSED, 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 { @@ -1265,13 +1266,13 @@ virNWFilterRuleDetailsParse(virConnectPtr conn ATTRIBUTE_UNUSED, 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 {