mirror of
https://github.com/apache/nuttx.git
synced 2026-05-27 19:36:35 +08:00
VFS poll(): Add some error handling logic
This commit is contained in:
+14
-9
@@ -133,14 +133,19 @@ int select(int nfds, FAR fd_set *readfds, FAR fd_set *writefds,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (npfds <= 0)
|
||||||
|
{
|
||||||
|
errcode = EINVAL;
|
||||||
|
goto errout;
|
||||||
|
}
|
||||||
|
|
||||||
/* Allocate the descriptor list for poll() */
|
/* Allocate the descriptor list for poll() */
|
||||||
|
|
||||||
pollset = (struct pollfd *)kmm_zalloc(npfds * sizeof(struct pollfd));
|
pollset = (struct pollfd *)kmm_zalloc(npfds * sizeof(struct pollfd));
|
||||||
if (!pollset)
|
if (!pollset)
|
||||||
{
|
{
|
||||||
set_errno(ENOMEM);
|
errcode = ENOMEM;
|
||||||
leave_cancellation_point();
|
goto errout;
|
||||||
return ERROR;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize the descriptor list for poll() */
|
/* Initialize the descriptor list for poll() */
|
||||||
@@ -279,16 +284,16 @@ int select(int nfds, FAR fd_set *readfds, FAR fd_set *writefds,
|
|||||||
|
|
||||||
/* Did poll() fail above? */
|
/* Did poll() fail above? */
|
||||||
|
|
||||||
if (ret < 0)
|
if (ret >= 0)
|
||||||
{
|
{
|
||||||
/* Yes.. restore the errno value */
|
leave_cancellation_point();
|
||||||
|
return ret;
|
||||||
set_errno(errcode);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
errout:
|
||||||
|
set_errno(errcode);
|
||||||
leave_cancellation_point();
|
leave_cancellation_point();
|
||||||
return ret;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* CONFIG_DISABLE_POLL */
|
#endif /* CONFIG_DISABLE_POLL */
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user