From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 3E3ADA046B for ; Mon, 19 Aug 2019 11:58:44 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E31011B9BF; Mon, 19 Aug 2019 11:58:42 +0200 (CEST) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id 80C5A1B93E for ; Mon, 19 Aug 2019 11:58:40 +0200 (CEST) Received: from mail-vk1-f197.google.com (mail-vk1-f197.google.com [209.85.221.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CB7805859E for ; Mon, 19 Aug 2019 09:58:39 +0000 (UTC) Received: by mail-vk1-f197.google.com with SMTP id s17so1521502vkm.10 for ; Mon, 19 Aug 2019 02:58:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=sGJvmj8wB0VhUtfXtDuCVzlhcWpvcMYP5RJxPdStBuY=; b=K+TrF84izmcaJqZMjDp2MBsDeBSpCwAW7EE/Wkqw6HAwKaCn8L8n60d6ANqNuJh0FD RUsPReoD8luIN+csvDoTm3EPq2VcU+9ZLwGikMzBYQN7vn6t6mMkP2ba7VMXOTjdMivl +FUYdyUvTEZzsQKL2CwzYyCmKMIuWpARsWYEtjXxomaUWnBPFbngY28yVjZRpEj3hC/C jujLjdMQTdbW7XK9LK2CnhpqKezG+VQNVWUaPFByPoqFD5lLhkyWxtOV9cN4AzApG5u7 woQVZuqhtGkwb9b9FeGKnckPySO1KJVi0nXhfHLQam7GdbxOrqGIOEUAWhL2dGTJ1YOM ekhw== X-Gm-Message-State: APjAAAWzQPmjaGcZrLmw+dtogS7PHoXYoG1OXcG91Tt6YmYkOxl07nDF VlPE8/7C822iLebrlraX2s5sMuEu2saINmQFNut/xrHepetI7obm7yDNQ111Ata+VKRCg6TNz7g 1u1F9YxiZGJdk2hyybCo= X-Received: by 2002:ab0:54d1:: with SMTP id q17mr6531885uaa.126.1566208718786; Mon, 19 Aug 2019 02:58:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqwxx5zpRAwai0up2Y2A5e+W4Vz0kG9djSC8C0ev5JArNuFYOWjt1tHRh+WwavCSsw1aI+UqhBF3DNsHzyfrJP4= X-Received: by 2002:ab0:54d1:: with SMTP id q17mr6531878uaa.126.1566208718544; Mon, 19 Aug 2019 02:58:38 -0700 (PDT) MIME-Version: 1.0 References: <20190813153822.29488-1-stephen@networkplumber.org> In-Reply-To: <20190813153822.29488-1-stephen@networkplumber.org> From: David Marchand Date: Mon, 19 Aug 2019 11:58:27 +0200 Message-ID: To: Stephen Hemminger Cc: dev Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-dev] [PATCH] pci: remove unnecessary access() check X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Tue, Aug 13, 2019 at 5:38 PM Stephen Hemminger wrote: > > Just open the sysfs file and handle failure, rather than > using access(). This eliminates Coverity warnings about > "time of check versus time of use"; although for this sysfs > file that is not really an issue anyway. > > Coverity ID: 347276 > Signed-off-by: Stephen Hemminger Title prefix should be "bus/pci: " (check-git-log.sh). > --- > drivers/bus/pci/linux/pci.c | 13 +++++++------ > 1 file changed, 7 insertions(+), 6 deletions(-) > > diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c > index 43debaa25114..6c444aa7ae3d 100644 > --- a/drivers/bus/pci/linux/pci.c > +++ b/drivers/bus/pci/linux/pci.c > @@ -512,18 +512,19 @@ pci_device_iommu_support_va(const struct rte_pci_device *dev) > "%s/" PCI_PRI_FMT "/iommu/intel-iommu/cap", > rte_pci_get_sysfs_path(), addr->domain, addr->bus, addr->devid, > addr->function); > - if (access(filename, F_OK) == -1) { > - /* We don't have an Intel IOMMU, assume VA supported*/ > - return true; > - } > > - /* We have an intel IOMMU */ > fp = fopen(filename, "r"); > if (fp == NULL) { > - RTE_LOG(ERR, EAL, "%s(): can't open %s\n", __func__, filename); > + /* We don't have an Intel IOMMU, assume VA supported*/ Nit: missing a space before closing the comment. > + if (errno == ENOENT) > + return true; > + > + RTE_LOG(ERR, EAL, "%s(): can't open %s: %s\n", > + __func__, filename, strerror(errno)); > return false; > } > > + /* We have an intel IOMMU */ > if (fscanf(fp, "%" PRIx64, &vtd_cap_reg) != 1) { > RTE_LOG(ERR, EAL, "%s(): can't read %s\n", __func__, filename); > fclose(fp); > -- > 2.20.1 > Reviewed-by: David Marchand -- David Marchand