提交 8d30e5f7 编写于 作者: S Stefan Berger

Use the virStrToLong_ui() function rather than the virStrToLong_i()

where possible.
上级 d9292cfe
...@@ -1125,6 +1125,7 @@ virNWFilterRuleDetailsParse(virConnectPtr conn ATTRIBUTE_UNUSED, ...@@ -1125,6 +1125,7 @@ virNWFilterRuleDetailsParse(virConnectPtr conn ATTRIBUTE_UNUSED,
enum virNWFilterEntryItemFlags *flags ,match_flag = 0, flags_set = 0; enum virNWFilterEntryItemFlags *flags ,match_flag = 0, flags_set = 0;
nwItemDesc *item; nwItemDesc *item;
int int_val; int int_val;
unsigned int uint_val;
void *data_ptr, *storage_ptr; void *data_ptr, *storage_ptr;
valueValidator validator; valueValidator validator;
char *match = virXMLPropString(node, "match"); char *match = virXMLPropString(node, "match");
...@@ -1174,12 +1175,12 @@ virNWFilterRuleDetailsParse(virConnectPtr conn ATTRIBUTE_UNUSED, ...@@ -1174,12 +1175,12 @@ virNWFilterRuleDetailsParse(virConnectPtr conn ATTRIBUTE_UNUSED,
case DATATYPE_UINT8: case DATATYPE_UINT8:
storage_ptr = &item->u.u8; storage_ptr = &item->u.u8;
if (virStrToLong_i(prop, NULL, 10, &int_val) >= 0) { if (virStrToLong_ui(prop, NULL, 10, &uint_val) >= 0) {
if (int_val >= 0 && int_val <= 0xff) { if (uint_val <= 0xff) {
if (!validator) if (!validator)
*(uint8_t *)storage_ptr = int_val; *(uint8_t *)storage_ptr = uint_val;
found = 1; found = 1;
data_ptr = &int_val; data_ptr = &uint_val;
} else } else
rc = -1; rc = -1;
} else } else
...@@ -1188,12 +1189,12 @@ virNWFilterRuleDetailsParse(virConnectPtr conn ATTRIBUTE_UNUSED, ...@@ -1188,12 +1189,12 @@ virNWFilterRuleDetailsParse(virConnectPtr conn ATTRIBUTE_UNUSED,
case DATATYPE_UINT16: case DATATYPE_UINT16:
storage_ptr = &item->u.u16; storage_ptr = &item->u.u16;
if (virStrToLong_i(prop, NULL, 10, &int_val) >= 0) { if (virStrToLong_ui(prop, NULL, 10, &uint_val) >= 0) {
if (int_val >= 0 && int_val <= 0xffff) { if (uint_val <= 0xffff) {
if (!validator) if (!validator)
*(uint16_t *)storage_ptr = int_val; *(uint16_t *)storage_ptr = uint_val;
found = 1; found = 1;
data_ptr = &int_val; data_ptr = &uint_val;
} else } else
rc = -1; rc = -1;
} else } else
...@@ -1211,13 +1212,13 @@ virNWFilterRuleDetailsParse(virConnectPtr conn ATTRIBUTE_UNUSED, ...@@ -1211,13 +1212,13 @@ virNWFilterRuleDetailsParse(virConnectPtr conn ATTRIBUTE_UNUSED,
case DATATYPE_IPMASK: case DATATYPE_IPMASK:
storage_ptr = &item->u.u8; storage_ptr = &item->u.u8;
if (virStrToLong_i(prop, NULL, 10, &int_val) == 0) { if (virStrToLong_ui(prop, NULL, 10, &uint_val) == 0) {
if (int_val >= 0 && int_val <= 32) { if (uint_val <= 32) {
if (!validator) if (!validator)
*(uint8_t *)storage_ptr = *(uint8_t *)storage_ptr =
(uint8_t)int_val; (uint8_t)uint_val;
found = 1; found = 1;
data_ptr = &int_val; data_ptr = &uint_val;
} else } else
rc = -1; rc = -1;
} else { } else {
...@@ -1265,13 +1266,13 @@ virNWFilterRuleDetailsParse(virConnectPtr conn ATTRIBUTE_UNUSED, ...@@ -1265,13 +1266,13 @@ virNWFilterRuleDetailsParse(virConnectPtr conn ATTRIBUTE_UNUSED,
case DATATYPE_IPV6MASK: case DATATYPE_IPV6MASK:
storage_ptr = &item->u.u8; storage_ptr = &item->u.u8;
if (virStrToLong_i(prop, NULL, 10, &int_val) == 0) { if (virStrToLong_ui(prop, NULL, 10, &uint_val) == 0) {
if (int_val >= 0 && int_val <= 128) { if (uint_val <= 128) {
if (!validator) if (!validator)
*(uint8_t *)storage_ptr = *(uint8_t *)storage_ptr =
(uint8_t)int_val; (uint8_t)uint_val;
found = 1; found = 1;
data_ptr = &int_val; data_ptr = &uint_val;
} else } else
rc = -1; rc = -1;
} else { } else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册