Function libvirt_charPtrUnwrap() either fails or always sets the
unwrapped string so there is no need to check it explicitly.
Signed-off-by: Pavel Hrdina <phrdina(a)redhat.com>
---
libvirt-override.c | 12 ++++--------
libvirt-utils.c | 10 +++-------
2 files changed, 7 insertions(+), 15 deletions(-)
diff --git a/libvirt-override.c b/libvirt-override.c
index dac481b..2f2c4ff 100644
--- a/libvirt-override.c
+++ b/libvirt-override.c
@@ -4639,8 +4639,7 @@ libvirt_virConnectBaselineCPU(PyObject *self ATTRIBUTE_UNUSED,
for (i = 0; i < ncpus; i++) {
if (libvirt_charPtrUnwrap(PyList_GetItem(list, i),
- &(xmlcpus[i])) < 0 ||
- xmlcpus[i] == NULL) {
+ &(xmlcpus[i])) < 0) {
for (j = 0 ; j < i ; j++)
VIR_FREE(xmlcpus[j]);
VIR_FREE(xmlcpus);
@@ -8245,8 +8244,7 @@ libvirt_virDomainFSFreeze(PyObject *self ATTRIBUTE_UNUSED,
for (i = 0; i < nmountpoints; i++) {
if (libvirt_charPtrUnwrap(PyList_GetItem(pyobj_list, i),
- mountpoints+i) < 0 ||
- mountpoints[i] == NULL)
+ mountpoints+i) < 0)
goto cleanup;
}
}
@@ -8293,8 +8291,7 @@ libvirt_virDomainFSThaw(PyObject *self ATTRIBUTE_UNUSED,
for (i = 0; i < nmountpoints; i++) {
if (libvirt_charPtrUnwrap(PyList_GetItem(pyobj_list, i),
- mountpoints+i) < 0 ||
- mountpoints[i] == NULL)
+ mountpoints+i) < 0)
goto cleanup;
}
}
@@ -9743,8 +9740,7 @@ libvirt_virConnectBaselineHypervisorCPU(PyObject *self
ATTRIBUTE_UNUSED,
for (i = 0; i < ncpus; i++) {
if (libvirt_charPtrUnwrap(PyList_GetItem(list, i),
- &(xmlCPUs[i])) < 0 ||
- !xmlCPUs[i])
+ &(xmlCPUs[i])) < 0)
goto cleanup;
}
}
diff --git a/libvirt-utils.c b/libvirt-utils.c
index e17e794..78b94ca 100644
--- a/libvirt-utils.c
+++ b/libvirt-utils.c
@@ -302,8 +302,7 @@ setPyVirTypedParameter(PyObject *info,
while (PyDict_Next(info, &pos, &key, &value)) {
char *keystr = NULL;
- if (libvirt_charPtrUnwrap(key, &keystr) < 0 ||
- keystr == NULL)
+ if (libvirt_charPtrUnwrap(key, &keystr) < 0)
goto cleanup;
for (i = 0; i < nparams; i++) {
@@ -359,8 +358,7 @@ setPyVirTypedParameter(PyObject *info,
case VIR_TYPED_PARAM_STRING:
{
char *string_val;
- if (libvirt_charPtrUnwrap(value, &string_val) < 0 ||
- !string_val)
+ if (libvirt_charPtrUnwrap(value, &string_val) < 0)
goto cleanup;
temp->value.s = string_val;
break;
@@ -489,7 +487,6 @@ virPyDictToTypedParamOne(virTypedParameterPtr *params,
{
char *val;;
if (libvirt_charPtrUnwrap(value, &val) < 0 ||
- !val ||
virTypedParamsAddString(params, n, max, keystr, val) < 0) {
VIR_FREE(val);
goto cleanup;
@@ -541,8 +538,7 @@ virPyDictToTypedParams(PyObject *dict,
return -1;
while (PyDict_Next(dict, &pos, &key, &value)) {
- if (libvirt_charPtrUnwrap(key, &keystr) < 0 ||
- !keystr)
+ if (libvirt_charPtrUnwrap(key, &keystr) < 0)
goto cleanup;
if (PyList_Check(value) || PyTuple_Check(value)) {
--
2.17.1