From nobody Sun Feb 8 19:59:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.81 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=1573728233; cv=none; d=zoho.com; s=zohoarc; b=TBVqeR2YefawclFc5mxMM5YSJV0iJ0U6FN8eb8fMHFQBmWlgHd6D1N9MjK0B4KtWVKEfGA9un/AOFwDjlO8JIzu8W7ML2m+O6nAA1gNrI8FR+7cxEj1oEC5I1qMjgvVzTpIqiRtJVS5/0dSneQRper/nO3q67AZHv1wm5mi8p9s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573728233; 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=/pr3R8OGGtty7FoSWz5C8lUDyQ90xn+7107RIZf0PBE=; b=dKw4WZ2sEuzT0mtDVq/8iaNacX1r/Mh9X8vXuTAsZce1uYx7zw2X45+hhIJnNDjcVmphtTGbcHq+CwNBwqgBdBAU4Vow8j3k54JVx97l91a3i5PDmex4SDtvSIkx0yVGjH4TwA9RCM5hQfgR+oB9+LN70T56nSYro+TlWy0AuUw= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 207.211.31.81 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-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1573728233961938.9760255776985; Thu, 14 Nov 2019 02:43:53 -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-47-NfWZUsBMPu6n57Tc0dz-Fw-1; Thu, 14 Nov 2019 05:43:51 -0500 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 889AC107ACFC; Thu, 14 Nov 2019 10:43:44 +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 643C35C219; Thu, 14 Nov 2019 10:43:44 +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 23F7418089D7; Thu, 14 Nov 2019 10:43:44 +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 xAEAheHg005632 for ; Thu, 14 Nov 2019 05:43:40 -0500 Received: by smtp.corp.redhat.com (Postfix) id 1E3E45F76C; Thu, 14 Nov 2019 10:43:40 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9D8215F762 for ; Thu, 14 Nov 2019 10:43:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573728232; 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=/pr3R8OGGtty7FoSWz5C8lUDyQ90xn+7107RIZf0PBE=; b=JwZ61hZJJv9B2/cVnJHNctAHdn8kER1vqrrjKQcYbHT0/iJ4x5/V5ozay+DVjeWMYHGYj6 7B77adUBR5reyRTKyta8i4gyUgIMg8F6+Sj68vl7m45AJom7sUu7+5m/qJv094XbatYgVN Pyz36W5GeNw/SBXPdQPQyWQShm20Yus= From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 14 Nov 2019 11:43:31 +0100 Message-Id: <94f386ee24ae72fb8dbbab54ebac0c080e674c4b.1573727895.git.pkrempa@redhat.com> 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 3/5] util: file: Simplify logic of shortuct cases in virFindFileInPath 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.16 X-MC-Unique: NfWZUsBMPu6n57Tc0dz-Fw-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" Combine the terms in the two sets of nested conditionals an don't reuse a variable for a more obvious control flow. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/util/virfile.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/util/virfile.c b/src/util/virfile.c index 072a299b39..c077639c1c 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -1644,20 +1644,16 @@ virFindFileInPath(const char *file) /* if we are passed an absolute path (starting with /), return a * copy of that path, after validating that it is executable */ - if (IS_ABSOLUTE_FILE_NAME(file)) { - char *ret =3D NULL; - if (virFileIsExecutable(file)) - ret =3D g_strdup(file); - return ret; - } + if (IS_ABSOLUTE_FILE_NAME(file) && virFileIsExecutable(file)) + return g_strdup(file); /* If we are passed an anchored path (containing a /), then there * is no path search - it must exist in the current directory */ - if (strchr(file, '/')) { - if (virFileIsExecutable(file)) - ignore_value(virFileAbsPath(file, &path)); - return path; + if (strchr(file, '/') && virFileIsExecutable(file)) { + char *abspath =3D NULL; + ignore_value(virFileAbsPath(file, &abspath)); + return abspath; } /* copy PATH env so we can tweak it */ --=20 2.23.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list