From nobody Mon Feb 9 09:22:22 2026 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=1662384876; cv=none; d=zohomail.com; s=zohoarc; b=ZllZasWfBoy/QvtC/aK1LfnX8FHSwrjeTsn/706MYFcuJaOQWE1zys5q166LaPsJvSwau7eIyjt1ZpwQ+RPXujt15BZ0etgat4qTGJe5FmMChIMIvrdXerKDEuENWxPClCDrIsppUp9sUwbIRSTB6Ldp4BPzE5/LBeW6Cvc/PSQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1662384876; 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=ytla2pQE2BHnDdYc/UWbipTm0uv/9zNY0FhMyxfmouk=; b=I9VQa9ajVqApoZaiqUOc6VFqiM6LJagZp69//2K5StkxRXL6iFf8qxW3LrCVesuVylMDLOegCZIfovLzSD7dLUJdpHahnsssEW3SS3guCS21PIS/r5g1HqITMrXbLpvEvDoFJEsEmxkf5Cdan2JyOE9a3yXpmyeBb1srS09Tixw= 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 1662384876633683.0247885509884; Mon, 5 Sep 2022 06:34:36 -0700 (PDT) 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-310-zEQ6wDnIOreq0nE39vJORg-1; Mon, 05 Sep 2022 09:34:31 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7999618E004F; Mon, 5 Sep 2022 13:34:29 +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 65BC32166B26; Mon, 5 Sep 2022 13:34:29 +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 584C0194B966; Mon, 5 Sep 2022 13:34:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 1EDD91946A47 for ; Mon, 5 Sep 2022 13:34:28 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 1183E40D2830; Mon, 5 Sep 2022 13:34:28 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6FF1840D282E for ; Mon, 5 Sep 2022 13:34:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1662384874; 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=ytla2pQE2BHnDdYc/UWbipTm0uv/9zNY0FhMyxfmouk=; b=BVNK1SzfoZW5+2B2kBmCbt2NPZ++uOKDCiF8aWWovm7LQnn7U+Rekl6D3IXiJA2ShBH9ps 610ORdfOfW7/8DcJwUAe7bH8HkIH8LxUZpJ4AOAAxWzlLDSDErXvmuYDMzzlnIyLjZXBz4 ag/BymXguNkz/N1LQmwD3ikGyrIPbZQ= X-MC-Unique: zEQ6wDnIOreq0nE39vJORg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 3/7] util: virFileIsSharedFixFUSE: Refactor cleanup Date: Mon, 5 Sep 2022 15:34:17 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.2 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 2.78 on 10.11.54.6 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: 1662384878146100001 Content-Type: text/plain; charset="utf-8" Automatically free memory of 'canonPath' so that the failure of 'setmntent' doesn't have to go to 'cleanup'. This allows us to remove the cleanup section and the 'ret' variable as the rest of the function can't fail. Signed-off-by: Peter Krempa --- src/util/virfile.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/util/virfile.c b/src/util/virfile.c index 1def05b6c4..a8443acf8d 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -3333,24 +3333,19 @@ virFileIsSharedFixFUSE(const char *path, char mntbuf[1024]; char *mntDir =3D NULL; char *mntType =3D NULL; - char *canonPath =3D NULL; + g_autofree char *canonPath =3D NULL; size_t maxMatching =3D 0; - int ret =3D -1; if (!(canonPath =3D virFileCanonicalizePath(path))) { - virReportSystemError(errno, - _("unable to canonicalize %s"), - path); + virReportSystemError(errno, _("unable to canonicalize %s"), path); return -1; } VIR_DEBUG("Path canonicalization: %s->%s", path, canonPath); if (!(f =3D setmntent(PROC_MOUNTS, "r"))) { - virReportSystemError(errno, - _("Unable to open %s"), - PROC_MOUNTS); - goto cleanup; + virReportSystemError(errno, _("Unable to open %s"), PROC_MOUNTS); + return -1; } while (getmntent_r(f, &mb, mntbuf, sizeof(mntbuf))) { @@ -3372,6 +3367,8 @@ virFileIsSharedFixFUSE(const char *path, } } + endmntent(f); + if (STREQ_NULLABLE(mntType, "fuse.glusterfs")) { VIR_DEBUG("Found gluster FUSE mountpoint=3D%s for path=3D%s. " "Fixing shared FS type", mntDir, canonPath); @@ -3382,13 +3379,9 @@ virFileIsSharedFixFUSE(const char *path, *f_type =3D QB_MAGIC; } - ret =3D 0; - cleanup: - VIR_FREE(canonPath); VIR_FREE(mntType); VIR_FREE(mntDir); - endmntent(f); - return ret; + return 0; } --=20 2.37.1