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.
This commit is contained in:
2026-08-05 17:39:36 +03:00
parent e05abf16b5
commit 9cd56ab66c
+1 -1
View File
@@ -1234,7 +1234,7 @@ PIEthernet::InterfaceList PIEthernet::interfaces() {
# ifdef QNX # ifdef QNX
# ifndef BLACKBERRY # ifndef BLACKBERRY
int fd = ::open((PIString("/dev/io-net/") + ci.name).dataAscii(), O_RDONLY); int fd = ::open((PIString("/dev/io-net/") + ci.name).dataAscii(), O_RDONLY);
if (fd != 0) { if (fd >= 0) {
nic_config_t nic; nic_config_t nic;
devctl(fd, DCMD_IO_NET_GET_CONFIG, &nic, sizeof(nic), 0); devctl(fd, DCMD_IO_NET_GET_CONFIG, &nic, sizeof(nic), 0);
::close(fd); ::close(fd);