From nobody Sun Feb 8 20:53:39 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.120 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=1573728312; cv=none; d=zoho.com; s=zohoarc; b=LtwT/RWnuAuUENLlHmTrnJ1urEtL9e4nJ9ByPbU0vt1EO3PTJcflpLEXgscsxn4ogTk/YEZ9G6+JfoMvlA3j77+3tAdmdGY2oACholtaQJtFeYAcowC7AU+155JNn3dry6HR8vo7KsW65f5QOS5TxUYRzyTQaQ7poFZxfc2Ez2E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573728312; 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=uJCjT7hiIiOYqOnPy6sZr9Skuk9VNFK9Is5w2bgJDCY=; b=FC+kSA8aUnPsJ0BvPVc+GJBJKBoqEhPmRzmSx6gkDMTT6pklp2yK7iKVLjo/2G2H1ACc+pu07XqMqwbWj/d4L0IYV8xwFJhUayXRMWhx7F1MSDRKUkJ/JA+HQdmEvs7TR95krGB7YLjk8XeyBILRj02G6Of9Zw19MhtMoJqDYac= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 157372831233536.72243599630917; Thu, 14 Nov 2019 02:45:12 -0800 (PST) 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-387-PEZjGiSUPziKBMs1khqTFA-1; Thu, 14 Nov 2019 05:43:55 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3462ADB70; Thu, 14 Nov 2019 10:43:49 +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 0B68834D33; Thu, 14 Nov 2019 10:43:49 +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 B90C81808855; Thu, 14 Nov 2019 10:43:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id xAEAhh3M005675 for ; Thu, 14 Nov 2019 05:43:43 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7B84D5F762; Thu, 14 Nov 2019 10:43:43 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 06E1C5F76C for ; Thu, 14 Nov 2019 10:43:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573728311; 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=uJCjT7hiIiOYqOnPy6sZr9Skuk9VNFK9Is5w2bgJDCY=; b=O0WUWPzgdF0cDEQZbqaDiHa3K1JMmhubRBQtS1gOfk9x9cA7r5LF+MlV39QrooXLOr6iy4 i0PNZCfyEa0nanqMQNWbneme9fLCZANjlT06rro2sFS5xD0jWy4TU89cPTvW1cYRZsUPyj EPWCQY1s3jA/bHJ3MDYaXYbPS1NxbCg= From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 14 Nov 2019 11:43:32 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/5] util: file: Replace use of 'strsep' with virStringSplit 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.84 on 10.5.11.23 X-MC-Unique: PEZjGiSUPziKBMs1khqTFA-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Use our helper instead of the gnulib one. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko Reviewed-by: Pavel Hrdina --- src/util/virfile.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/util/virfile.c b/src/util/virfile.c index c077639c1c..55705c8463 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -1634,9 +1634,8 @@ char * virFindFileInPath(const char *file) { const char *origpath =3D NULL; - g_autofree char *path =3D NULL; - char *pathiter; - char *pathseg; + VIR_AUTOSTRINGLIST paths =3D NULL; + char **pathiter; if (file =3D=3D NULL) return NULL; @@ -1660,14 +1659,16 @@ virFindFileInPath(const char *file) origpath =3D getenv("PATH"); if (!origpath) origpath =3D "/bin:/usr/bin"; - path =3D g_strdup(origpath); /* for each path segment, append the file to search for and test for * it. return it if found. */ - pathiter =3D path; - while ((pathseg =3D strsep(&pathiter, ":")) !=3D NULL) { - g_autofree char *fullpath =3D g_strdup_printf("%s/%s", pathseg, fi= le); + + if (!(paths =3D virStringSplit(origpath, ":", 0))) + return NULL; + + for (pathiter =3D paths; *pathiter; pathiter++) { + g_autofree char *fullpath =3D g_strdup_printf("%s/%s", *pathiter, = file); if (virFileIsExecutable(fullpath)) return g_steal_pointer(&fullpath); } --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list