From nobody Sun Feb 8 04:11:31 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=linux.ibm.com ARC-Seal: i=1; a=rsa-sha256; t=1603474355; cv=none; d=zohomail.com; s=zohoarc; b=e+SfkgxLwSX+DWsuX4a59hZxG3vvTHBkQ6MZv2suJO2TWRt2kQARBVHBc7nCDqzwK9IRT7c6Rx+r+jzddGkSB3TURo3wPXGVefNIqqfuL5kvbqDYyYTq5Ea0pUxvBlOzJEcBIa7VarU5uf19gxEsPl69sTr2yBjwIDR2xF83owI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603474355; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=czRBonqJdCeWwwKu27Rg5e5edgWElCqYW49sLu39W+k=; b=hZFa+zskJpfrAvXcVvjICTi83J+7Cpy12xfslTMNOSxeRNkACN0h9sbfxCqkXSdi+L99DAKV1VHYTu5OvGbMZjkdK33DKRz53T2pSwnlLMbmFPObUbeX9QI51VTsiuaeFkkPPnQ7TEKD7niD2SoyD/6p63jtNfvp/y8UFtBAdT4= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1603474355686487.44471491935496; Fri, 23 Oct 2020 10:32:35 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-295-wjkDoRmkNI-zXEmqnRPgjw-1; Fri, 23 Oct 2020 13:32:31 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 42E971007283; Fri, 23 Oct 2020 17:32:25 +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 1EC9F5B4C7; Fri, 23 Oct 2020 17:32:25 +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 E365C92311; Fri, 23 Oct 2020 17:32:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09NHWIlN000774 for ; Fri, 23 Oct 2020 13:32:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9BD751000DBE; Fri, 23 Oct 2020 17:32:18 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast04.extmail.prod.ext.rdu2.redhat.com [10.11.55.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 97E9D1112861 for ; Fri, 23 Oct 2020 17:32:18 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 70B2A102F1E0 for ; Fri, 23 Oct 2020 17:32:18 +0000 (UTC) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-550-p0VUUXm4PuS-iAuXF1iBcw-1; Fri, 23 Oct 2020 13:32:15 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 09NHVrnV006358; Fri, 23 Oct 2020 13:32:14 -0400 Received: from ppma06ams.nl.ibm.com (66.31.33a9.ip4.static.sl-reverse.com [169.51.49.102]) by mx0a-001b2d01.pphosted.com with ESMTP id 34bx0s3dd1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 Oct 2020 13:32:13 -0400 Received: from pps.filterd (ppma06ams.nl.ibm.com [127.0.0.1]) by ppma06ams.nl.ibm.com (8.16.0.42/8.16.0.42) with SMTP id 09NHNHTQ029403; Fri, 23 Oct 2020 17:32:08 GMT Received: from b06cxnps3074.portsmouth.uk.ibm.com (d06relay09.portsmouth.uk.ibm.com [9.149.109.194]) by ppma06ams.nl.ibm.com with ESMTP id 347qvheupk-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 23 Oct 2020 17:32:08 +0000 Received: from d06av24.portsmouth.uk.ibm.com (d06av24.portsmouth.uk.ibm.com [9.149.105.60]) by b06cxnps3074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 09NHW6Fv31326590 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 23 Oct 2020 17:32:06 GMT Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E921742042; Fri, 23 Oct 2020 17:32:05 +0000 (GMT) Received: from d06av24.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CA8A542047; Fri, 23 Oct 2020 17:32:05 +0000 (GMT) Received: from localhost.localdomain (unknown [9.145.42.215]) by d06av24.portsmouth.uk.ibm.com (Postfix) with ESMTP; Fri, 23 Oct 2020 17:32:05 +0000 (GMT) X-MC-Unique: wjkDoRmkNI-zXEmqnRPgjw-1 X-MC-Unique: p0VUUXm4PuS-iAuXF1iBcw-1 From: Boris Fiuczynski To: libvir-list@redhat.com Subject: [PATCH 03/10] util: refactor mdev_types methods return code usage Date: Fri, 23 Oct 2020 19:31:45 +0200 Message-Id: <20201023173152.45238-4-fiuczy@linux.ibm.com> In-Reply-To: <20201023173152.45238-1-fiuczy@linux.ibm.com> References: <20201023173152.45238-1-fiuczy@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.235, 18.0.737 definitions=2020-10-23_12:2020-10-23, 2020-10-23 signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 malwarescore=0 adultscore=0 mlxscore=0 lowpriorityscore=0 suspectscore=3 impostorscore=0 clxscore=1015 spamscore=0 phishscore=0 mlxlogscore=999 priorityscore=1501 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2009150000 definitions=main-2010230109 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: eskultet@redhat.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Remove mix of array length and error code in the return code. Signed-off-by: Boris Fiuczynski Reviewed-by: Bjoern Walk Reviewed-by: J=C3=A1n Tomko --- src/conf/node_device_conf.c | 10 ++++------ src/util/virmdev.c | 14 ++++++++------ src/util/virmdev.h | 3 ++- 3 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index db1258436a..af8edded3c 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -2574,7 +2574,7 @@ virNodeDeviceGetPCIMdevTypesCaps(const char *sysfspat= h, virNodeDevCapPCIDevPtr pci_dev) { virMediatedDeviceTypePtr *types =3D NULL; - int rc =3D 0; + size_t ntypes =3D 0; size_t i; =20 /* this could be a refresh, so clear out the old data */ @@ -2584,13 +2584,11 @@ virNodeDeviceGetPCIMdevTypesCaps(const char *sysfsp= ath, pci_dev->nmdev_types =3D 0; pci_dev->flags &=3D ~VIR_NODE_DEV_CAP_FLAG_PCI_MDEV; =20 - rc =3D virMediatedDeviceGetMdevTypes(sysfspath, &types); - - if (rc <=3D 0) - return rc; + if (virMediatedDeviceGetMdevTypes(sysfspath, &types, &ntypes) < 0) + return -1; =20 pci_dev->mdev_types =3D g_steal_pointer(&types); - pci_dev->nmdev_types =3D rc; + pci_dev->nmdev_types =3D ntypes; pci_dev->flags |=3D VIR_NODE_DEV_CAP_FLAG_PCI_MDEV; =20 return 0; diff --git a/src/util/virmdev.c b/src/util/virmdev.c index 80f5f2a767..b02005bd1a 100644 --- a/src/util/virmdev.c +++ b/src/util/virmdev.c @@ -528,7 +528,8 @@ void virMediatedDeviceAttrFree(virMediatedDeviceAttrPtr= attr) =20 ssize_t virMediatedDeviceGetMdevTypes(const char *sysfspath, - virMediatedDeviceTypePtr **types) + virMediatedDeviceTypePtr **types, + size_t *ntypes) { ssize_t ret =3D -1; int dirret =3D -1; @@ -537,7 +538,7 @@ virMediatedDeviceGetMdevTypes(const char *sysfspath, g_autofree char *types_path =3D NULL; g_autoptr(virMediatedDeviceType) mdev_type =3D NULL; virMediatedDeviceTypePtr *mdev_types =3D NULL; - size_t ntypes =3D 0; + size_t nmdev_types =3D 0; size_t i; =20 types_path =3D g_strdup_printf("%s/mdev_supported_types", sysfspath); @@ -558,7 +559,7 @@ virMediatedDeviceGetMdevTypes(const char *sysfspath, if (virMediatedDeviceTypeReadAttrs(tmppath, &mdev_type) < 0) goto cleanup; =20 - if (VIR_APPEND_ELEMENT(mdev_types, ntypes, mdev_type) < 0) + if (VIR_APPEND_ELEMENT(mdev_types, nmdev_types, mdev_type) < 0) goto cleanup; } =20 @@ -566,10 +567,11 @@ virMediatedDeviceGetMdevTypes(const char *sysfspath, goto cleanup; =20 *types =3D g_steal_pointer(&mdev_types); - ret =3D ntypes; - ntypes =3D 0; + *ntypes =3D nmdev_types; + nmdev_types =3D 0; + ret =3D 0; cleanup: - for (i =3D 0; i < ntypes; i++) + for (i =3D 0; i < nmdev_types; i++) virMediatedDeviceTypeFree(mdev_types[i]); VIR_FREE(mdev_types); VIR_DIR_CLOSE(dir); diff --git a/src/util/virmdev.h b/src/util/virmdev.h index 846e1662e7..b6563a94fc 100644 --- a/src/util/virmdev.h +++ b/src/util/virmdev.h @@ -151,7 +151,8 @@ virMediatedDeviceTypeReadAttrs(const char *sysfspath, =20 ssize_t virMediatedDeviceGetMdevTypes(const char *sysfspath, - virMediatedDeviceTypePtr **types); + virMediatedDeviceTypePtr **types, + size_t *ntypes); =20 G_DEFINE_AUTOPTR_CLEANUP_FUNC(virMediatedDevice, virMediatedDeviceFree); G_DEFINE_AUTOPTR_CLEANUP_FUNC(virMediatedDeviceType, virMediatedDeviceType= Free); --=20 2.25.1