From nobody Tue May 13 11:18:10 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; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1532639199617740.6433407207434; Thu, 26 Jul 2018 14:06:39 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DB0E585A04; Thu, 26 Jul 2018 21:06:36 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DF4676314E; Thu, 26 Jul 2018 21:06:35 +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 EC1271800543; Thu, 26 Jul 2018 21:06:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6QL5YGt024953 for ; Thu, 26 Jul 2018 17:05:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id 72246608F8; Thu, 26 Jul 2018 21:05:34 +0000 (UTC) Received: from mx1.redhat.com (ext-mx18.extmail.prod.ext.phx2.redhat.com [10.5.110.47]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 19702608F7 for ; Thu, 26 Jul 2018 21:05:22 +0000 (UTC) Received: from mail-pg1-f194.google.com (mail-pg1-f194.google.com [209.85.215.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 91DC630820D4 for ; Thu, 26 Jul 2018 21:05:21 +0000 (UTC) Received: by mail-pg1-f194.google.com with SMTP id y5-v6so1889350pgv.1 for ; Thu, 26 Jul 2018 14:05:21 -0700 (PDT) Received: from centos.localdomain ([42.106.3.93]) by smtp.gmail.com with ESMTPSA id z10-v6sm3279182pfh.83.2018.07.26.14.05.19 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Jul 2018 14:05:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=QxWjWl4tEjL90x0V27zQ1a8E2fH5GK0rweYU/vac7C8=; b=r6mLKYVApsfwSP403Nytno1QksjxMg/KfexOwxVV/wS3PltqIq+88p8IcYATrCcmMa PN9V8unQUEFpyfJ4XbUsusK+PYuaL8OHyBWieyDlgVGIQKCWpg2lIriumy2USYESwvYV hvv9JaGd1DT5f+vSRQJ8BBZUpSlNzkc2nqFHGlQ0q0ZVpY4Fa7G8vwrTt75ih2eAIOnl 9rXp+Nmo63aK1VyFb/HBGNKIavv7htJ57LVpAI8nLpQqAz01em6xdY7pFLo51UKoTkXT TR5mUWN20uz32kjV1CerVcKcqqqV6TojTtFwGUm776WGvgiWdvKoSD+ZSzc2coxrsp94 krqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=QxWjWl4tEjL90x0V27zQ1a8E2fH5GK0rweYU/vac7C8=; b=pBGLI0wh1wihROBzo5ZVXJ6X5Qxc9+hQFc4SLn5ElEPDqWOntb7KSC4SpW18WWd41A 9WqN+pOvRGYnDURmuMSzmEwoozPlZ7LcIN+t44OsXNqzYg1gG135PReXuWAoit2RZwMq lx4182GvoNcjUbFGs5Mrj02OMFJekui8KtKGJBHgHVOSZ/ke3fHmbGISiZdPS+oFzVA/ BjL3nUBC7dMwfuchg8lGrmoTd4bWDZUcM16DK+yfP24qWnwu6FGkINqygqQ9pB8Ere32 Fr0v1NA40iOygrBySjn+Gvs6nGb5Pacpdl4GtV9pcb0EA4vNmGaiFTV+MDDsiKN10V14 +8Tw== X-Gm-Message-State: AOUpUlEtnE7j9N4r1Y6KzSut2ItBf4NnDHcV+BByBFch1vUiNBOY5eaP cUNFK9FRd+xSAS30Iu0nwHm8dc7d X-Google-Smtp-Source: AAOMgpe/weSyd+g+/rMsQOxpOUuMYc1Z142i1hzlJcwcVfyLVg5Gy56npnvlwvNFFSIQLZSIn42mAA== X-Received: by 2002:a63:8a41:: with SMTP id y62-v6mr3266811pgd.291.1532639120835; Thu, 26 Jul 2018 14:05:20 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Tue, 24 Jul 2018 21:22:23 +0530 Message-Id: <1532447562-24010-23-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1532447562-24010-1-git-send-email-skrtbhtngr@gmail.com> References: <1532447562-24010-1-git-send-email-skrtbhtngr@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Thu, 26 Jul 2018 21:05:21 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Thu, 26 Jul 2018 21:05:21 +0000 (UTC) for IP:'209.85.215.194' DOMAIN:'mail-pg1-f194.google.com' HELO:'mail-pg1-f194.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.389 * (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, RCVD_IN_SORBS_WEB, SPF_PASS) 209.85.215.194 mail-pg1-f194.google.com 209.85.215.194 mail-pg1-f194.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.47 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 22/41] util: usb: modify virUSBDeviceListAdd to take double pointer 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Thu, 26 Jul 2018 21:06:38 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Modify virUSBDeviceListAdd to take a double pointer to virUSBDevicePtr as the second argument. This will enable usage of cleanup macros upon the virUSBDevicePtr item which is to be added to the list as it will be cleared by virInsertElementsN upon success. Signed-off-by: Sukrit Bhatnagar Reviewed-by: Erik Skultety --- src/util/virhostdev.c | 6 +++--- src/util/virusb.c | 10 +++++----- src/util/virusb.h | 2 +- tests/virusbtest.c | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c index f4bd19d..d5075ac 100644 --- a/src/util/virhostdev.c +++ b/src/util/virhostdev.c @@ -1236,7 +1236,7 @@ virHostdevUpdateActiveUSBDevices(virHostdevManagerPtr= mgr, =20 virUSBDeviceSetUsedBy(usb, drv_name, dom_name); =20 - if (virUSBDeviceListAdd(mgr->activeUSBHostdevs, usb) < 0) { + if (virUSBDeviceListAdd(mgr->activeUSBHostdevs, &usb) < 0) { virUSBDeviceFree(usb); goto cleanup; } @@ -1406,7 +1406,7 @@ virHostdevMarkUSBDevices(virHostdevManagerPtr mgr, * from the virUSBDeviceList that passed in on success, * perform rollback on failure. */ - if (virUSBDeviceListAdd(mgr->activeUSBHostdevs, usb) < 0) + if (virUSBDeviceListAdd(mgr->activeUSBHostdevs, &usb) < 0) goto error; } =20 @@ -1555,7 +1555,7 @@ virHostdevPrepareUSBDevices(virHostdevManagerPtr mgr, if (virHostdevFindUSBDevice(hostdev, required, &usb) < 0) goto cleanup; =20 - if (usb && virUSBDeviceListAdd(list, usb) < 0) { + if (usb && virUSBDeviceListAdd(list, &usb) < 0) { virUSBDeviceFree(usb); goto cleanup; } diff --git a/src/util/virusb.c b/src/util/virusb.c index 2fe1bfc..7818232 100644 --- a/src/util/virusb.c +++ b/src/util/virusb.c @@ -181,7 +181,7 @@ virUSBDeviceSearch(unsigned int vendor, if (!usb) goto cleanup; =20 - if (virUSBDeviceListAdd(list, usb) < 0) { + if (virUSBDeviceListAdd(list, &usb) < 0) { virUSBDeviceFree(usb); goto cleanup; } @@ -463,15 +463,15 @@ virUSBDeviceListDispose(void *obj) =20 int virUSBDeviceListAdd(virUSBDeviceListPtr list, - virUSBDevicePtr dev) + virUSBDevicePtr *dev) { - if (virUSBDeviceListFind(list, dev)) { + if (virUSBDeviceListFind(list, *dev)) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Device %s is already in use"), - dev->name); + (*dev)->name); return -1; } - return VIR_APPEND_ELEMENT(list->devs, list->count, dev); + return VIR_APPEND_ELEMENT(list->devs, list->count, *dev); } =20 virUSBDevicePtr diff --git a/src/util/virusb.h b/src/util/virusb.h index 716e8c6..078dee6 100644 --- a/src/util/virusb.h +++ b/src/util/virusb.h @@ -88,7 +88,7 @@ int virUSBDeviceFileIterate(virUSBDevicePtr dev, =20 virUSBDeviceListPtr virUSBDeviceListNew(void); int virUSBDeviceListAdd(virUSBDeviceListPtr list, - virUSBDevicePtr dev); + virUSBDevicePtr *dev); virUSBDevicePtr virUSBDeviceListGet(virUSBDeviceListPtr list, int idx); size_t virUSBDeviceListCount(virUSBDeviceListPtr list); diff --git a/tests/virusbtest.c b/tests/virusbtest.c index 8728fe9..05bba2b 100644 --- a/tests/virusbtest.c +++ b/tests/virusbtest.c @@ -173,7 +173,7 @@ testUSBList(const void *opaque ATTRIBUTE_UNUSED) dev =3D virUSBDeviceListGet(devlist, 0); dev =3D virUSBDeviceListSteal(devlist, dev); =20 - if (virUSBDeviceListAdd(list, dev) < 0) + if (virUSBDeviceListAdd(list, &dev) < 0) goto cleanup; dev =3D NULL; } @@ -196,7 +196,7 @@ testUSBList(const void *opaque ATTRIBUTE_UNUSED) dev =3D virUSBDeviceListGet(devlist, 0); dev =3D virUSBDeviceListSteal(devlist, dev); =20 - if (virUSBDeviceListAdd(list, dev) < 0) + if (virUSBDeviceListAdd(list, &dev) < 0) goto cleanup; dev =3D NULL; } --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list