mirror of
https://github.com/linux-can/can-utils.git
synced 2026-08-04 22:09:57 +02:00
j1939cat: fix error detection of poll function call
The poll function return -1 on error and set errno to indicate the error. Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
This commit is contained in:
+12
-8
@@ -368,10 +368,12 @@ static int j1939cat_send_loop(struct j1939cat_priv *priv, int out_fd, char *buf,
|
||||
int ret;
|
||||
|
||||
ret = poll(&fds, 1, priv->polltimeout);
|
||||
if (ret == -EINTR)
|
||||
continue;
|
||||
if (ret < 0)
|
||||
return -errno;
|
||||
if (ret == -1) {
|
||||
if (errno == -EINTR)
|
||||
continue;
|
||||
else
|
||||
return -errno;
|
||||
}
|
||||
if (!ret)
|
||||
return -ETIME;
|
||||
if (!(fds.revents & events)) {
|
||||
@@ -572,10 +574,12 @@ static int j1939cat_recv(struct j1939cat_priv *priv)
|
||||
int ret;
|
||||
|
||||
ret = poll(&fds, 1, priv->polltimeout);
|
||||
if (ret == -EINTR)
|
||||
continue;
|
||||
if (ret < 0)
|
||||
return -errno;
|
||||
if (ret == -1) {
|
||||
if (errno == -EINTR)
|
||||
continue;
|
||||
else
|
||||
return -errno;
|
||||
}
|
||||
if (!ret)
|
||||
continue;
|
||||
if (!(fds.revents & events)) {
|
||||
|
||||
Reference in New Issue
Block a user