mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 00:14:22 +08:00
fs/vfs/fs_poll.c: Fix handling of sem_tickwait() return value sem_tickwait() does not return an -1+errno, it returns a negated errno value. Noted by Freddie Chopin.
This commit is contained in:
@@ -11402,3 +11402,6 @@
|
|||||||
Rename the x86 up_spiinitialize() to i486_spibus_intialize(),
|
Rename the x86 up_spiinitialize() to i486_spibus_intialize(),
|
||||||
Rename the z16f up_spiinitialize() to z16_spibus_intialize().
|
Rename the z16f up_spiinitialize() to z16_spibus_intialize().
|
||||||
up_spiinitialize() has been completely eliminated. (2016-01-27).
|
up_spiinitialize() has been completely eliminated. (2016-01-27).
|
||||||
|
* fs/vfs/fs_poll.c: Fix handling of sem_tickwait() return value
|
||||||
|
sem_tickwait() does not return an -1+errno, it returns a negated
|
||||||
|
errno value. Noted by Freddie Chopin."
|
||||||
|
|||||||
+1
-1
Submodule configs updated: b5e84e337c...b7138e5722
+10
-9
@@ -329,6 +329,7 @@ int poll(FAR struct pollfd *fds, nfds_t nfds, int timeout)
|
|||||||
{
|
{
|
||||||
sem_t sem;
|
sem_t sem;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
int err;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
sem_init(&sem, 0, 0);
|
sem_init(&sem, 0, 0);
|
||||||
@@ -354,20 +355,14 @@ int poll(FAR struct pollfd *fds, nfds_t nfds, int timeout)
|
|||||||
ret = sem_tickwait(&sem, clock_systimer(), MSEC2TICK(timeout));
|
ret = sem_tickwait(&sem, clock_systimer(), MSEC2TICK(timeout));
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
int err = get_errno();
|
if (ret == -ETIMEDOUT)
|
||||||
|
|
||||||
if (err == ETIMEDOUT)
|
|
||||||
{
|
{
|
||||||
/* Return zero (OK) in the event of a timeout */
|
/* Return zero (OK) in the event of a timeout */
|
||||||
|
|
||||||
ret = OK;
|
ret = OK;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
/* EINTR is the only other error expected in normal operation */
|
|
||||||
|
|
||||||
ret = -err;
|
/* EINTR is the only other error expected in normal operation */
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -379,9 +374,15 @@ int poll(FAR struct pollfd *fds, nfds_t nfds, int timeout)
|
|||||||
|
|
||||||
/* Teardown the poll operation and get the count of events. Zero will be
|
/* Teardown the poll operation and get the count of events. Zero will be
|
||||||
* returned in the case of a timeout.
|
* returned in the case of a timeout.
|
||||||
|
*
|
||||||
|
* Preserve ret, if negative, since it holds the result of the wait.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
ret = poll_teardown(fds, nfds, &count, ret);
|
err = poll_teardown(fds, nfds, &count, ret);
|
||||||
|
if (err < 0 && ret == OK)
|
||||||
|
{
|
||||||
|
ret = err;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sem_destroy(&sem);
|
sem_destroy(&sem);
|
||||||
|
|||||||
Reference in New Issue
Block a user