1
0
mirror of https://gitlab.com/libvirt/libvirt-python.git synced 2025-08-02 04:21:59 +03:00

libvirt_charPtrUnwrap: remove unnecessary check of returned string

Function libvirt_charPtrUnwrap() either fails or always sets the
unwrapped string so there is no need to check it explicitly.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
Pavel Hrdina
2018-06-12 07:12:15 +02:00
parent 0c2d0c9be9
commit a950b08317
2 changed files with 7 additions and 15 deletions

View File

@ -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;
}
}

View File

@ -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)) {