From 9cd56ab66ceb1fd401cccc2814492587f738e192 Mon Sep 17 00:00:00 2001 From: "andrey.bychkov" Date: Wed, 5 Aug 2026 17:38:12 +0300 Subject: [PATCH] fix(PIEthernet): check open() return value with >= 0 instead of != 0 open() returns -1 on error. The check fd != 0 treated -1 as a valid fd (since -1 != 0 is true), causing devctl(-1, ...) and close(-1) on QNX. Fixed to fd >= 0. --- libs/main/io_devices/piethernet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/main/io_devices/piethernet.cpp b/libs/main/io_devices/piethernet.cpp index ad4a08b3..a1245cc1 100644 --- a/libs/main/io_devices/piethernet.cpp +++ b/libs/main/io_devices/piethernet.cpp @@ -383,7 +383,7 @@ void PIEthernet::applyBuffers() { void PIEthernet::applyTimeout(int fd, int opt, PISystemTime tm) { if (fd == 0) return; - // piCoutObj << "setReadIsBlocking" << yes; + // piCoutObj << "setReadIsBlocking" << yes; #ifdef WINDOWS DWORD _tm = tm.toMilliseconds(); #else @@ -1234,7 +1234,7 @@ PIEthernet::InterfaceList PIEthernet::interfaces() { # ifdef QNX # ifndef BLACKBERRY int fd = ::open((PIString("/dev/io-net/") + ci.name).dataAscii(), O_RDONLY); - if (fd != 0) { + if (fd >= 0) { nic_config_t nic; devctl(fd, DCMD_IO_NET_GET_CONFIG, &nic, sizeof(nic), 0); ::close(fd);