From patchwork Tue Aug 13 15:38:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 57671 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3EDBD1BDFD; Tue, 13 Aug 2019 17:38:32 +0200 (CEST) Received: from mail-pf1-f195.google.com (mail-pf1-f195.google.com [209.85.210.195]) by dpdk.org (Postfix) with ESMTP id B97FC1252 for ; Tue, 13 Aug 2019 17:38:30 +0200 (CEST) Received: by mail-pf1-f195.google.com with SMTP id o70so6480816pfg.5 for ; Tue, 13 Aug 2019 08:38:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=6cJuwSv1aPfdMLpjayxAl1IKYhmivwUondqK9dX4RDE=; b=ciDYgKIGFTC2/5Hc2KlGQaNCl6UE681xhIRRKac3YxkD2oMLtHRz4qZo35SRFGrtBS MaJneOne2oxYixYObjUNeVK4eLthYJuwUJvux44rvJkV+T1p2nEYgSufNolXTE+5o5N9 /BTO15tJs9SGUuRmNS1W1kOrw3uB7vuTWBRj5Zfcmc/z3LJ5YmqsbxXfhX+Moajx+rm9 EWoGnwvQp9kBviroGAAbZwzyWS12cvGl/nFsKNuwlhwLX4AkHpiWbPCfYIERRhJdABBs yymf0Xr6cB5Xm4unykTJDYlaRaO4P7CDXn1SpV5TNYGjR6QgwZvBsjbiTACgmOuzF+bg kDmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=6cJuwSv1aPfdMLpjayxAl1IKYhmivwUondqK9dX4RDE=; b=hXbG1bt6cJqRd48YasSpZSE9XdRKvpusut+mjV8aM43hRant41r0ttWsQK5sxD6xvY 98cXeGkyuf0coMx1XBNK0IYROGAedT0/JjiQ4p78alMXxZTIUaw28xMzsmMtJ3STt7Pk NoEaD0BjUqc5pkRc55SM55wINBRUP14fr+FnnT/UfFhfbg6EY3ejGAXbXGzGSeubYnpx 4brSjvsy7Gj/1pvrOgdneu7f0ikpByg4ckRKqQwgJ3ooe6mKenywfJO1z61Z5DB3FfGj lLil0NTkqKNEUcGuT0As57pTGoKV40C/a4/ciZ7nYZwNXnJeKaGfXi0BbRTUP/IQ1/Tq g1gg== X-Gm-Message-State: APjAAAXSS5BSD0gQEqTO2ElaFcnKZ4TDlJ8Tw7NitEgHs/r0CS45kiUI 6cAxsmesaMq0ZRlgFjlQHImktbRJ0Fs= X-Google-Smtp-Source: APXvYqxd5QTcj3QsBchamyECmN8cIuTqaK17I7HdtlcaxQ4mNh3XbLGx69jhqB7ELePbNEUklZoTyw== X-Received: by 2002:a62:144b:: with SMTP id 72mr5586977pfu.42.1565710709536; Tue, 13 Aug 2019 08:38:29 -0700 (PDT) Received: from hermes.lan (204-195-22-127.wavecable.com. [204.195.22.127]) by smtp.gmail.com with ESMTPSA id y11sm118535561pfb.119.2019.08.13.08.38.28 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 13 Aug 2019 08:38:28 -0700 (PDT) From: Stephen Hemminger To: dev@dpdk.org Cc: Stephen Hemminger Date: Tue, 13 Aug 2019 08:38:22 -0700 Message-Id: <20190813153822.29488-1-stephen@networkplumber.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [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" 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 Reviewed-by: David Marchand --- 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*/ + 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);