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>pull/336/head
parent
7af4264a13
commit
25de6276e8
20
j1939cat.c
20
j1939cat.c
|
|
@ -368,10 +368,12 @@ static int j1939cat_send_loop(struct j1939cat_priv *priv, int out_fd, char *buf,
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = poll(&fds, 1, priv->polltimeout);
|
ret = poll(&fds, 1, priv->polltimeout);
|
||||||
if (ret == -EINTR)
|
if (ret == -1) {
|
||||||
continue;
|
if (errno == -EINTR)
|
||||||
if (ret < 0)
|
continue;
|
||||||
return -errno;
|
else
|
||||||
|
return -errno;
|
||||||
|
}
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return -ETIME;
|
return -ETIME;
|
||||||
if (!(fds.revents & events)) {
|
if (!(fds.revents & events)) {
|
||||||
|
|
@ -572,10 +574,12 @@ static int j1939cat_recv(struct j1939cat_priv *priv)
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = poll(&fds, 1, priv->polltimeout);
|
ret = poll(&fds, 1, priv->polltimeout);
|
||||||
if (ret == -EINTR)
|
if (ret == -1) {
|
||||||
continue;
|
if (errno == -EINTR)
|
||||||
if (ret < 0)
|
continue;
|
||||||
return -errno;
|
else
|
||||||
|
return -errno;
|
||||||
|
}
|
||||||
if (!ret)
|
if (!ret)
|
||||||
continue;
|
continue;
|
||||||
if (!(fds.revents & events)) {
|
if (!(fds.revents & events)) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue