mirror of
https://gitlab.com/libvirt/libvirt-python.git
synced 2025-08-01 00: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:
@ -4639,8 +4639,7 @@ libvirt_virConnectBaselineCPU(PyObject *self ATTRIBUTE_UNUSED,
|
|||||||
|
|
||||||
for (i = 0; i < ncpus; i++) {
|
for (i = 0; i < ncpus; i++) {
|
||||||
if (libvirt_charPtrUnwrap(PyList_GetItem(list, i),
|
if (libvirt_charPtrUnwrap(PyList_GetItem(list, i),
|
||||||
&(xmlcpus[i])) < 0 ||
|
&(xmlcpus[i])) < 0) {
|
||||||
xmlcpus[i] == NULL) {
|
|
||||||
for (j = 0 ; j < i ; j++)
|
for (j = 0 ; j < i ; j++)
|
||||||
VIR_FREE(xmlcpus[j]);
|
VIR_FREE(xmlcpus[j]);
|
||||||
VIR_FREE(xmlcpus);
|
VIR_FREE(xmlcpus);
|
||||||
@ -8245,8 +8244,7 @@ libvirt_virDomainFSFreeze(PyObject *self ATTRIBUTE_UNUSED,
|
|||||||
|
|
||||||
for (i = 0; i < nmountpoints; i++) {
|
for (i = 0; i < nmountpoints; i++) {
|
||||||
if (libvirt_charPtrUnwrap(PyList_GetItem(pyobj_list, i),
|
if (libvirt_charPtrUnwrap(PyList_GetItem(pyobj_list, i),
|
||||||
mountpoints+i) < 0 ||
|
mountpoints+i) < 0)
|
||||||
mountpoints[i] == NULL)
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -8293,8 +8291,7 @@ libvirt_virDomainFSThaw(PyObject *self ATTRIBUTE_UNUSED,
|
|||||||
|
|
||||||
for (i = 0; i < nmountpoints; i++) {
|
for (i = 0; i < nmountpoints; i++) {
|
||||||
if (libvirt_charPtrUnwrap(PyList_GetItem(pyobj_list, i),
|
if (libvirt_charPtrUnwrap(PyList_GetItem(pyobj_list, i),
|
||||||
mountpoints+i) < 0 ||
|
mountpoints+i) < 0)
|
||||||
mountpoints[i] == NULL)
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -9743,8 +9740,7 @@ libvirt_virConnectBaselineHypervisorCPU(PyObject *self ATTRIBUTE_UNUSED,
|
|||||||
|
|
||||||
for (i = 0; i < ncpus; i++) {
|
for (i = 0; i < ncpus; i++) {
|
||||||
if (libvirt_charPtrUnwrap(PyList_GetItem(list, i),
|
if (libvirt_charPtrUnwrap(PyList_GetItem(list, i),
|
||||||
&(xmlCPUs[i])) < 0 ||
|
&(xmlCPUs[i])) < 0)
|
||||||
!xmlCPUs[i])
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -302,8 +302,7 @@ setPyVirTypedParameter(PyObject *info,
|
|||||||
while (PyDict_Next(info, &pos, &key, &value)) {
|
while (PyDict_Next(info, &pos, &key, &value)) {
|
||||||
char *keystr = NULL;
|
char *keystr = NULL;
|
||||||
|
|
||||||
if (libvirt_charPtrUnwrap(key, &keystr) < 0 ||
|
if (libvirt_charPtrUnwrap(key, &keystr) < 0)
|
||||||
keystr == NULL)
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
for (i = 0; i < nparams; i++) {
|
for (i = 0; i < nparams; i++) {
|
||||||
@ -359,8 +358,7 @@ setPyVirTypedParameter(PyObject *info,
|
|||||||
case VIR_TYPED_PARAM_STRING:
|
case VIR_TYPED_PARAM_STRING:
|
||||||
{
|
{
|
||||||
char *string_val;
|
char *string_val;
|
||||||
if (libvirt_charPtrUnwrap(value, &string_val) < 0 ||
|
if (libvirt_charPtrUnwrap(value, &string_val) < 0)
|
||||||
!string_val)
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
temp->value.s = string_val;
|
temp->value.s = string_val;
|
||||||
break;
|
break;
|
||||||
@ -489,7 +487,6 @@ virPyDictToTypedParamOne(virTypedParameterPtr *params,
|
|||||||
{
|
{
|
||||||
char *val;;
|
char *val;;
|
||||||
if (libvirt_charPtrUnwrap(value, &val) < 0 ||
|
if (libvirt_charPtrUnwrap(value, &val) < 0 ||
|
||||||
!val ||
|
|
||||||
virTypedParamsAddString(params, n, max, keystr, val) < 0) {
|
virTypedParamsAddString(params, n, max, keystr, val) < 0) {
|
||||||
VIR_FREE(val);
|
VIR_FREE(val);
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -541,8 +538,7 @@ virPyDictToTypedParams(PyObject *dict,
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
while (PyDict_Next(dict, &pos, &key, &value)) {
|
while (PyDict_Next(dict, &pos, &key, &value)) {
|
||||||
if (libvirt_charPtrUnwrap(key, &keystr) < 0 ||
|
if (libvirt_charPtrUnwrap(key, &keystr) < 0)
|
||||||
!keystr)
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
if (PyList_Check(value) || PyTuple_Check(value)) {
|
if (PyList_Check(value) || PyTuple_Check(value)) {
|
||||||
|
Reference in New Issue
Block a user