From patchwork Thu Sep 21 15:59:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukasz Majczak X-Patchwork-Id: 29069 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 35B751B1A8; Thu, 21 Sep 2017 18:00:00 +0200 (CEST) Received: from mail-lf0-f54.google.com (mail-lf0-f54.google.com [209.85.215.54]) by dpdk.org (Postfix) with ESMTP id 54EF71B1A7 for ; Thu, 21 Sep 2017 17:59:59 +0200 (CEST) Received: by mail-lf0-f54.google.com with SMTP id k23so6204257lfi.11 for ; Thu, 21 Sep 2017 08:59:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=eZxiPJWIHu1VTU1auQrEm/uOsQ1eLEHaFbZJX6xu9JI=; b=auyAFqBakfnFd5gatE1yo4oMYyJEZ50umxYVAQ4A9eYKWRaPrTiOK56abLz6xWopSf DC5g7zIsGJ5SS5n+NTWMpkHHepUenvAb3EQE64kLXX1MGKB6iMGXKOUecuvytzNMXqor mRhE5KQ3fp43nBKgFiEoNr4H+F9N3SNa5Bu0IjARpzy+yRtD0N/IMlLAW0bC223qUxfj LqUk2ZYh73nCZLyjOPizjl16SpeHR1vIo8gSJsS5kH35Eu0EcpT8AQ1N55t2OqFO0sL6 kLSyPU/XxxJj8n50GIYCeutl7CMnueCC9zP9vWyFaVl867vwwGp5eo7mwwysNYYCc7k1 RXPA== 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; bh=eZxiPJWIHu1VTU1auQrEm/uOsQ1eLEHaFbZJX6xu9JI=; b=IFaIzreKYRRaTEAtQuRSZOQIes/oEXMUf9lt/PL1P5ehA5oOyLYZE/mbOrZ9/bYjCV LfKMb1Msi9F1QGn+YbAQN/2QFVSdiYcfIVqfQCPbtU2e+DXFgWgefq0tuQFMK9CbEF8+ lowJf3gYDh82MeflmRqi5qrg5oNE6slQ0HX3+7DgHZsEK8X8ZpwEiqjjCffayljcGYZP yI+4tFx7b2qbVQEJDiIjkHkLXEE2s+QPVQ3+5c7dQSwibUV+dslZrG9hdqT5uh3JPtgC a1737lKZntrFWathiLZCNz1+sZFnJyjRmmhXdO/ZsVcTlA4xnHA8hdN/aKJLEymd1j+p lEdw== X-Gm-Message-State: AHPjjUi6Luq7SE4EB2GWcoZLrAaiSvtakK3sTt7OTHb04krq5nROojnc P0g09e+SCpCLyjSn5AMlcKV5OA== X-Google-Smtp-Source: AOwi7QAgsbkAbMJacHJHllkRXEN0gmq+Atte1Bn8F4A7QKiuNnIdj4nHSWm76gYckFUBYl6UBRMHhA== X-Received: by 10.46.82.20 with SMTP id g20mr1187390ljb.150.1506009598876; Thu, 21 Sep 2017 08:59:58 -0700 (PDT) Received: from deadpool.semihalf.local (31-172-191-173.noc.fibertech.net.pl. [31.172.191.173]) by smtp.gmail.com with ESMTPSA id s66sm274691lfi.97.2017.09.21.08.59.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Sep 2017 08:59:58 -0700 (PDT) From: Lukasz Majczak To: viktorin@rehivetech.com, chaozhu@linux.vnet.ibm.com Cc: dev@dpdk.org, Lukasz Majczak Date: Thu, 21 Sep 2017 17:59:53 +0200 Message-Id: <20170921155953.9984-1-lma@semihalf.com> X-Mailer: git-send-email 2.14.1 Subject: [dpdk-dev] [PATCH v2] librte_eal: fix wrong assert for arm and ppc 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" The assertion of return value from the open() function is done against 0, while it is a correct value - open() returns -1 in case of an error. It causes problems while trying to run as a daemon, in which case, this call to open() will return 0 as a valid descriptor. Fixes: b94e5c9406b5 ("eal/arm: add CPU flags for ARMv7") Fixes: 97523f822ba9 ("eal/arm: add CPU flags for ARMv8") Fixes: 9ae155385686 ("eal/ppc: cpu flag checks for IBM Power") Signed-off-by: Lukasz Majczak Acked-by: Jan Viktorin --- lib/librte_eal/common/arch/arm/rte_cpuflags.c | 2 +- lib/librte_eal/common/arch/ppc_64/rte_cpuflags.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/librte_eal/common/arch/arm/rte_cpuflags.c b/lib/librte_eal/common/arch/arm/rte_cpuflags.c index 5636e9c1d..88f1cbe37 100644 --- a/lib/librte_eal/common/arch/arm/rte_cpuflags.c +++ b/lib/librte_eal/common/arch/arm/rte_cpuflags.c @@ -137,7 +137,7 @@ rte_cpu_get_features(hwcap_registers_t out) _Elfx_auxv_t auxv; auxv_fd = open("/proc/self/auxv", O_RDONLY); - assert(auxv_fd); + assert(auxv_fd != -1); while (read(auxv_fd, &auxv, sizeof(auxv)) == sizeof(auxv)) { if (auxv.a_type == AT_HWCAP) { out[REG_HWCAP] = auxv.a_un.a_val; diff --git a/lib/librte_eal/common/arch/ppc_64/rte_cpuflags.c b/lib/librte_eal/common/arch/ppc_64/rte_cpuflags.c index fcf96e045..970a61c5e 100644 --- a/lib/librte_eal/common/arch/ppc_64/rte_cpuflags.c +++ b/lib/librte_eal/common/arch/ppc_64/rte_cpuflags.c @@ -108,7 +108,7 @@ rte_cpu_get_features(hwcap_registers_t out) Elf64_auxv_t auxv; auxv_fd = open("/proc/self/auxv", O_RDONLY); - assert(auxv_fd); + assert(auxv_fd != -1); while (read(auxv_fd, &auxv, sizeof(Elf64_auxv_t)) == sizeof(Elf64_auxv_t)) { if (auxv.a_type == AT_HWCAP)