librte_eal: fix wrong assert for arm and ppc
PATCH 1/1 librte_eal: fix wrong assert for arm and ppc
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.
Signed-off-by Lukasz Majczak <[email protected]>
--- 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(-)
lib/librte_eal/common/arch/arm/rte_cpuflags.c +1 -1
@@ -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;
lib/librte_eal/common/arch/ppc_64/rte_cpuflags.c +1 -1
@@ -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 )
Signature · 1 line
2.14.1
Quoted 4 lines · On Thu, 21 Sep 2017 15:04:04 +0200 Lukasz Majczak <[email protected]> wrote:
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 toopen()will return 0 as a valid descriptor.
Good catch! Please add also:
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")
Quoted 2 lines
Signed-off-by Lukasz Majczak <[email protected]>
Acked-by Jan Viktorin <[email protected]>