From nobody Fri Apr 19 15:59:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678264136; cv=none; d=zohomail.com; s=zohoarc; b=IPG4VQAJeD19DKATlHMsCZK7gAKobx7kpChvDy/yJ42bzXlKIGzAUhLhOJstf8ldFOu3qmTsehOqRXOyGZkSrCEkFPSzXmXTatfAE9RaKabp1wQDk6KKIWCqFcwQxi00go4Ia7qlm8R9hO/lKaKrl+uK2rVZ8mgF+ViRQy6p5m0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678264136; h=Content-Type:Content-Transfer-Encoding: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=IlhkdD4t4gVkH1bbFivcC1GFLhehkvfBwYPyi8uo6Q0=; b=Hss23tmCHs0GNkHQVlS/x68mBXBe5CNcIdxrT2Y5XsTuBOcfnxGKV3Au3rlklL1NUtXH9RLs+5dCNRCTBVr9sa7XaBfhUcszBF2tlw1F7Cigi+7dkUkVHilPC/asIj36Vjv+XXON+wnm0ZA0ahAnGNEsfo7ns0aTp29qblTP0VI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1678264136246159.73143754230512; Wed, 8 Mar 2023 00:28:56 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-631-XncL9KGtMTSMCYQ1f0Gkug-1; Wed, 08 Mar 2023 03:28:48 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 42255100B180; Wed, 8 Mar 2023 08:28:45 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1A10E4411E; Wed, 8 Mar 2023 08:28:44 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9ABDB1946A41; Wed, 8 Mar 2023 08:28:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9818D19465B1 for ; Wed, 8 Mar 2023 08:28:23 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 2B585440DF; Wed, 8 Mar 2023 08:28:23 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id C0E56440DD for ; Wed, 8 Mar 2023 08:28:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678264135; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=IlhkdD4t4gVkH1bbFivcC1GFLhehkvfBwYPyi8uo6Q0=; b=dexC6bzD/XMJDzQO5gQulmSzqgsnwGD58rjoA4LJh+1dBK0hH5Mo7eolwC/0GXv9tKu7M8 +4ra2S4AzaS/W5g8fwaicxUb3JPADre5WNhLCTUVhlh3QtvSpOCEqBkv1s611qoVmVEeFL PSS/Opm9cz9jN1Mk/MGWoh11V+BpCpM= X-MC-Unique: XncL9KGtMTSMCYQ1f0Gkug-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 1/4] virscsihost: use g_autofree more Date: Wed, 8 Mar 2023 09:28:18 +0100 Message-Id: <5287d426e50f9f9a9d49bab44c1175a1638d6d9c.1678264076.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678264137412100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Remove some obvious uses of VIR_FREE() in favor of automatic cleanup. This also means, that some variables affected are brought into the inner most block, so that automatic cleanup is effective. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/util/virscsihost.c | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/src/util/virscsihost.c b/src/util/virscsihost.c index 969cdd9f79..54ba9ddb9b 100644 --- a/src/util/virscsihost.c +++ b/src/util/virscsihost.c @@ -95,18 +95,19 @@ virSCSIHostFindByPCI(const char *sysfs_prefix, const char *prefix =3D sysfs_prefix ? sysfs_prefix : SYSFS_SCSI_HOST_P= ATH; struct dirent *entry =3D NULL; g_autoptr(DIR) dir =3D NULL; - char *host_link =3D NULL; - char *host_path =3D NULL; char *p =3D NULL; char *ret =3D NULL; - char *buf =3D NULL; - char *unique_path =3D NULL; unsigned int read_unique_id; =20 if (virDirOpen(&dir, prefix) < 0) return NULL; =20 while (virDirRead(dir, &entry, prefix) > 0) { + g_autofree char *host_link =3D NULL; + g_autofree char *host_path =3D NULL; + g_autofree char *unique_path =3D NULL; + g_autofree char *buf =3D NULL; + if (!virFileIsLink(entry->d_name)) continue; =20 @@ -116,17 +117,12 @@ virSCSIHostFindByPCI(const char *sysfs_prefix, goto cleanup; =20 if (!strstr(host_path, parentaddr)) { - VIR_FREE(host_link); - VIR_FREE(host_path); continue; } - VIR_FREE(host_link); - VIR_FREE(host_path); =20 unique_path =3D g_strdup_printf("%s/%s/unique_id", prefix, entry->= d_name); =20 if (!virFileExists(unique_path)) { - VIR_FREE(unique_path); continue; } =20 @@ -139,10 +135,7 @@ virSCSIHostFindByPCI(const char *sysfs_prefix, if (virStrToLong_ui(buf, NULL, 10, &read_unique_id) < 0) goto cleanup; =20 - VIR_FREE(buf); - if (read_unique_id !=3D unique_id) { - VIR_FREE(unique_path); continue; } =20 @@ -151,10 +144,6 @@ virSCSIHostFindByPCI(const char *sysfs_prefix, } =20 cleanup: - VIR_FREE(unique_path); - VIR_FREE(host_link); - VIR_FREE(host_path); - VIR_FREE(buf); return ret; } =20 @@ -226,7 +215,7 @@ virSCSIHostGetNameByParentaddr(unsigned int domain, unsigned int unique_id) { char *name =3D NULL; - char *parentaddr =3D NULL; + g_autofree char *parentaddr =3D NULL; =20 parentaddr =3D g_strdup_printf("%04x:%02x:%02x.%01x", domain, bus, slo= t, function); @@ -239,7 +228,6 @@ virSCSIHostGetNameByParentaddr(unsigned int domain, } =20 cleanup: - VIR_FREE(parentaddr); return name; } =20 --=20 2.39.2 From nobody Fri Apr 19 15:59:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678264131; cv=none; d=zohomail.com; s=zohoarc; b=CyfBBMVlOzRc6v4d/3c+itAotpCsaSyTGOWo9pg8MKpQKwTLQBxPaBTWUXyEjLZW6WxnBcb0yeKD3KvJ3i4m/g2xIbe2rm+fPEymCxrwOYAtHO92oPxThI2s/rEVQ4b3T4M3SdP7YeRCxZronyT904n3lO6nxwGXwiKaAUbhQUQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678264131; h=Content-Type:Content-Transfer-Encoding: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=9Amyatz3NZ9c4ULjENRumwHKG5hstpWQdiDbvRZKY1E=; b=lshrR7ZYCeJKoeM5fwPYpEnYJpYAdHL3UgZj7yUgPweookybkJcDkrOp4AcumuBkefhaJFRRC8WhoFK2qe038fIhlxfk0W7O/cCGUSmlsC/u2aR4cedD2DqLI0y3Bk6PkY0iU/onYVH7BgPpsQ5aft+CjhSq850xjo4yI17H+6w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1678264131734655.3677079615276; Wed, 8 Mar 2023 00:28:51 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-42--KIbXnjhOgG6c_PFoeGePw-1; Wed, 08 Mar 2023 03:28:48 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3D067855717; Wed, 8 Mar 2023 08:28:45 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4C6ED492B00; Wed, 8 Mar 2023 08:28:44 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id AF2FE1946A49; Wed, 8 Mar 2023 08:28:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9A95419465B2 for ; Wed, 8 Mar 2023 08:28:23 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C4051440E0; Wed, 8 Mar 2023 08:28:23 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 65B44440DD for ; Wed, 8 Mar 2023 08:28:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678264130; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=9Amyatz3NZ9c4ULjENRumwHKG5hstpWQdiDbvRZKY1E=; b=cYJDIgASeR4YaodOrcDoNwcXvjCxuy1wRToLVDAoSGXsuUDCPu/0xChlY+lwVw3xwe1tQX VKmMSDotEygIKSkM1vo0PqskKxBHgTDn2/3mUpf9f8yFwvctqpEcycVT2vw2V8/14raus4 FRvzxHWHvphjNHt8xSPjUQ1vJNJi4q0= X-MC-Unique: -KIbXnjhOgG6c_PFoeGePw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/4] virSCSIHostFindByPCI: Decrease scope of some variables Date: Wed, 8 Mar 2023 09:28:19 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678264133389100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Inside of virSCSIHostFindByPCI() there're some variables that are used from a while() loop exclusively. Bring their declaration into the loop. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/util/virscsihost.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/util/virscsihost.c b/src/util/virscsihost.c index 54ba9ddb9b..c816b21f64 100644 --- a/src/util/virscsihost.c +++ b/src/util/virscsihost.c @@ -95,9 +95,7 @@ virSCSIHostFindByPCI(const char *sysfs_prefix, const char *prefix =3D sysfs_prefix ? sysfs_prefix : SYSFS_SCSI_HOST_P= ATH; struct dirent *entry =3D NULL; g_autoptr(DIR) dir =3D NULL; - char *p =3D NULL; char *ret =3D NULL; - unsigned int read_unique_id; =20 if (virDirOpen(&dir, prefix) < 0) return NULL; @@ -107,6 +105,8 @@ virSCSIHostFindByPCI(const char *sysfs_prefix, g_autofree char *host_path =3D NULL; g_autofree char *unique_path =3D NULL; g_autofree char *buf =3D NULL; + char *p =3D NULL; + unsigned int read_unique_id; =20 if (!virFileIsLink(entry->d_name)) continue; --=20 2.39.2 From nobody Fri Apr 19 15:59:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678264144; cv=none; d=zohomail.com; s=zohoarc; b=Pqk2Gil/N1ix59Doye9tn1QFUC8n981ks4s0d32IJZM0oAtfyoweNJdDtljjDc/dHvwxEjoOa4P36Ntm2qCgoASLTbmZV4qe27Z0cJiQebXYTmrcKs++Mp2dUSxDxUuDe5DdY03DRD0/NolTKbMwGajvTPNxeaSj/zLAQyJT8pE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678264144; h=Content-Type:Content-Transfer-Encoding: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=jRIqKl7o6l6obor1i7bFpWk5/7Xix175kNlrZz2nt0g=; b=HkwmnY/is4XmZkF9KkuzHLgKcZ5Ye2ig9/7TA12kpgTipq0CQ1eNO5km2oRufvg7h9xTUw8WPKL46rpi8oE5r1GzcvzaixcNpHk6599/NxGE7Y+xj8PLzZbpXHGNfwRs10WO6jDudrUcSIgIkivBPQ52Lgz9GnhC8TgQtaQDO5A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1678264144539344.2739770125096; Wed, 8 Mar 2023 00:29:04 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-458-5bXuOo2zNr6OSAmHKk-1ug-1; Wed, 08 Mar 2023 03:28:49 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ABB81857F5E; Wed, 8 Mar 2023 08:28:45 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8E4CB14171C3; Wed, 8 Mar 2023 08:28:45 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 2E95C19472C7; Wed, 8 Mar 2023 08:28:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9CBDD19465B3 for ; Wed, 8 Mar 2023 08:28:24 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 693A1440E1; Wed, 8 Mar 2023 08:28:24 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A4E8440DD for ; Wed, 8 Mar 2023 08:28:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678264143; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=jRIqKl7o6l6obor1i7bFpWk5/7Xix175kNlrZz2nt0g=; b=i6CipsD9H3IJOiIXCu6jm+K5PNIYliH1dKv28BQyvqQiio/Jvc+81RmRArvBPaglR2yART WPhuIdZmFRONfho9QtCfB7e1N+rqLDaGmN1IiJLX6iMR0UClwDGj8xB6Dz+WNXbx+JJowW 7aaQf8iqMkWW1fIh/9gEnVsEvURXgpE= X-MC-Unique: 5bXuOo2zNr6OSAmHKk-1ug-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 3/4] virscsihost: Drop needless labels Date: Wed, 8 Mar 2023 09:28:20 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678264145493100002 Content-Type: text/plain; charset="utf-8"; x-default="true" After previous cleanups, we're left with a couple of needless labels, that contain nothing but a return statement. Drop those. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/util/virscsihost.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/util/virscsihost.c b/src/util/virscsihost.c index c816b21f64..014b96452c 100644 --- a/src/util/virscsihost.c +++ b/src/util/virscsihost.c @@ -95,7 +95,6 @@ virSCSIHostFindByPCI(const char *sysfs_prefix, const char *prefix =3D sysfs_prefix ? sysfs_prefix : SYSFS_SCSI_HOST_P= ATH; struct dirent *entry =3D NULL; g_autoptr(DIR) dir =3D NULL; - char *ret =3D NULL; =20 if (virDirOpen(&dir, prefix) < 0) return NULL; @@ -114,7 +113,7 @@ virSCSIHostFindByPCI(const char *sysfs_prefix, host_link =3D g_strdup_printf("%s/%s", prefix, entry->d_name); =20 if (virFileResolveLink(host_link, &host_path) < 0) - goto cleanup; + return NULL; =20 if (!strstr(host_path, parentaddr)) { continue; @@ -127,24 +126,22 @@ virSCSIHostFindByPCI(const char *sysfs_prefix, } =20 if (virFileReadAll(unique_path, 1024, &buf) < 0) - goto cleanup; + return NULL; =20 if ((p =3D strchr(buf, '\n'))) *p =3D '\0'; =20 if (virStrToLong_ui(buf, NULL, 10, &read_unique_id) < 0) - goto cleanup; + return NULL; =20 if (read_unique_id !=3D unique_id) { continue; } =20 - ret =3D g_strdup(entry->d_name); - break; + return g_strdup(entry->d_name); } =20 - cleanup: - return ret; + return NULL; } =20 =20 @@ -224,10 +221,9 @@ virSCSIHostGetNameByParentaddr(unsigned int domain, _("Failed to find scsi_host using PCI '%s' " "and unique_id=3D'%u'"), parentaddr, unique_id); - goto cleanup; + return NULL; } =20 - cleanup: return name; } =20 --=20 2.39.2 From nobody Fri Apr 19 15:59:52 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678264149; cv=none; d=zohomail.com; s=zohoarc; b=T6bvY9UHOliEVa/bK5oqXO/uI0EG2Y7RB1IDxztCCJx5qgolG2zfLj3B5B2TSBZWrUJAUhlwRWM/TNdcADTFuiobpkWNQSOqKQX8ShmWuVd2iZ0Smkhd8h2hyviAbtFwvCgdc47oo1ao7GBbyq1QxV8cQ33DjmMx+ZAPGGPNPD4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678264149; h=Content-Type:Content-Transfer-Encoding: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=r5hdTVJ6HqZhK3KEVxHG7p12mXdi95hgWCNipJtHn5s=; b=mbODRSMTHkqxGbXWsOqiAkuEH3oYuspc+vKpeAbQ1DmNfcDSIXyOh2Jiv6MRgvhYDW8ctUpBr7jJE1GqTjkOxARZKIuNgKC/FHPMbskZoLzqyNdyP5kvBZjRMOHnD7HDM5YwaiZfLoeKtsAFveciDr1YxRaenW8YYi7vn5p6KYA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1678264149790714.8749297768946; Wed, 8 Mar 2023 00:29:09 -0800 (PST) Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-42-2mGPoEPdOLS2N9o5oumjzg-1; Wed, 08 Mar 2023 03:28:48 -0500 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3CE2038035A0; Wed, 8 Mar 2023 08:28:45 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A35E492B08; Wed, 8 Mar 2023 08:28:45 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id EC9C01946A7A; Wed, 8 Mar 2023 08:28:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id A0B5019465B6 for ; Wed, 8 Mar 2023 08:28:25 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 0DE5E47CE3; Wed, 8 Mar 2023 08:28:25 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id A3C40440DD for ; Wed, 8 Mar 2023 08:28:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678264148; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=r5hdTVJ6HqZhK3KEVxHG7p12mXdi95hgWCNipJtHn5s=; b=Q6GdjoOdAZ8f+9yquc/bTal4VsaJw18truURHi8JsLKZ023BGNfOUwHvFUwifZB7LgVr3v q+oMKuAeisL1CxbjkIh4OJjmJV3h/mZoi6R/3KWVEGlyY9qnQqBhdLS66RRmQO5MV+3Els DPzHWEwQQ2SSLVSEsAHopQ8SWVRF8CM= X-MC-Unique: 2mGPoEPdOLS2N9o5oumjzg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 4/4] virSCSIHostFindByPCI: Fix link detection Date: Wed, 8 Mar 2023 09:28:21 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678264151422100001 Content-Type: text/plain; charset="utf-8"; x-default="true" Inside of virSCSIHostFindByPCI() there's a loop which iterates of entries of "/sys/class/scsi_host" directory trying to identify all symlinks (which then point to a SCSI device, but that's not important right now). But the way virFileIsLink() is called can never return a truthful reply - because it's called over dent->d_name instead of full path. Fix this by moving the virFileIsLink() call and passing constructed path into it. Signed-off-by: Michal Privoznik Reviewed-by: J=C3=A1n Tomko --- src/util/virscsihost.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/util/virscsihost.c b/src/util/virscsihost.c index 014b96452c..32d7f2312f 100644 --- a/src/util/virscsihost.c +++ b/src/util/virscsihost.c @@ -107,11 +107,11 @@ virSCSIHostFindByPCI(const char *sysfs_prefix, char *p =3D NULL; unsigned int read_unique_id; =20 - if (!virFileIsLink(entry->d_name)) - continue; - host_link =3D g_strdup_printf("%s/%s", prefix, entry->d_name); =20 + if (!virFileIsLink(host_link)) + continue; + if (virFileResolveLink(host_link, &host_path) < 0) return NULL; =20 --=20 2.39.2