From nobody Tue May 13 23:29:18 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1528780634528586.8927013195068; Mon, 11 Jun 2018 22:17:14 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7B4FF30820E1; Tue, 12 Jun 2018 05:17:13 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 35B3CA293A; Tue, 12 Jun 2018 05:17:13 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id C8F204CA81; Tue, 12 Jun 2018 05:17:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w5C5Gijf006518 for ; Tue, 12 Jun 2018 01:16:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id B075A202660C; Tue, 12 Jun 2018 05:16:44 +0000 (UTC) Received: from antique-work.brq.redhat.com (unknown [10.43.2.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 53CBE2026609 for ; Tue, 12 Jun 2018 05:16:44 +0000 (UTC) From: Pavel Hrdina To: libvir-list@redhat.com Date: Tue, 12 Jun 2018 07:16:41 +0200 Message-Id: <1ef2499b37c690b74438fa67d410f159ac32c755.1528780553.git.phrdina@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [python PATCH 4/4] libvirt_charPtrUnwrap: remove unnecessary check of returned string X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Tue, 12 Jun 2018 05:17:14 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: J=EF=BF=BDn Tomko --- 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 ATTRIBUT= E_UNUSED, =20 for (i =3D 0; i < ncpus; i++) { if (libvirt_charPtrUnwrap(PyList_GetItem(list, i), - &(xmlcpus[i])) < 0 || - xmlcpus[i] =3D=3D NULL) { + &(xmlcpus[i])) < 0) { for (j =3D 0 ; j < i ; j++) VIR_FREE(xmlcpus[j]); VIR_FREE(xmlcpus); @@ -8245,8 +8244,7 @@ libvirt_virDomainFSFreeze(PyObject *self ATTRIBUTE_UN= USED, =20 for (i =3D 0; i < nmountpoints; i++) { if (libvirt_charPtrUnwrap(PyList_GetItem(pyobj_list, i), - mountpoints+i) < 0 || - mountpoints[i] =3D=3D NULL) + mountpoints+i) < 0) goto cleanup; } } @@ -8293,8 +8291,7 @@ libvirt_virDomainFSThaw(PyObject *self ATTRIBUTE_UNUS= ED, =20 for (i =3D 0; i < nmountpoints; i++) { if (libvirt_charPtrUnwrap(PyList_GetItem(pyobj_list, i), - mountpoints+i) < 0 || - mountpoints[i] =3D=3D NULL) + mountpoints+i) < 0) goto cleanup; } } @@ -9743,8 +9740,7 @@ libvirt_virConnectBaselineHypervisorCPU(PyObject *sel= f ATTRIBUTE_UNUSED, =20 for (i =3D 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 =3D NULL; =20 - if (libvirt_charPtrUnwrap(key, &keystr) < 0 || - keystr =3D=3D NULL) + if (libvirt_charPtrUnwrap(key, &keystr) < 0) goto cleanup; =20 for (i =3D 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 =3D 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; =20 while (PyDict_Next(dict, &pos, &key, &value)) { - if (libvirt_charPtrUnwrap(key, &keystr) < 0 || - !keystr) + if (libvirt_charPtrUnwrap(key, &keystr) < 0) goto cleanup; =20 if (PyList_Check(value) || PyTuple_Check(value)) { --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list