mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-26 03:21:44 +03:00
xm_internal.c: remove misleading dead code
* src/xen/xm_internal.c (xenXMConfigGetULong): Remove useless and misleading test (always false) for val->str == NULL before code that always dereferences val->str. "val" comes from virConfGetValue, and at that point, val->str is guaranteed to be non-NULL. (xenXMConfigGetBool): Likewise. * src/util/conf.c (virConfSetValue): Ensure that vir->str is never NULL, not even if someone tries to set such a value via virConfSetValue.
This commit is contained in:
parent
d37bca86d0
commit
11f6cc3279
@ -858,6 +858,9 @@ virConfSetValue (virConfPtr conf,
|
||||
{
|
||||
virConfEntryPtr cur, prev = NULL;
|
||||
|
||||
if (value && value->type == VIR_CONF_STRING && value->str == NULL)
|
||||
return -1;
|
||||
|
||||
cur = conf->entries;
|
||||
while (cur != NULL) {
|
||||
if ((cur->name != NULL) && (STREQ(cur->name, setting))) {
|
||||
|
@ -152,9 +152,6 @@ static int xenXMConfigGetBool(virConnectPtr conn,
|
||||
if (val->type == VIR_CONF_LONG) {
|
||||
*value = val->l ? 1 : 0;
|
||||
} else if (val->type == VIR_CONF_STRING) {
|
||||
if (!val->str) {
|
||||
*value = def;
|
||||
}
|
||||
*value = STREQ(val->str, "1") ? 1 : 0;
|
||||
} else {
|
||||
xenXMError(conn, VIR_ERR_INTERNAL_ERROR,
|
||||
@ -183,9 +180,6 @@ static int xenXMConfigGetULong(virConnectPtr conn,
|
||||
*value = val->l;
|
||||
} else if (val->type == VIR_CONF_STRING) {
|
||||
char *ret;
|
||||
if (!val->str) {
|
||||
*value = def;
|
||||
}
|
||||
*value = strtol(val->str, &ret, 10);
|
||||
if (ret == val->str) {
|
||||
xenXMError(conn, VIR_ERR_INTERNAL_ERROR,
|
||||
|
Loading…
Reference in New Issue
Block a user