Even though the size parameter to epoll_create(2) is (otherwise) unused,
passing in size <= 0 is explicitly documented as an error.
This change fixes the LTP epoll01 testcase.
Change-Id: I044a38be823c2fa956b57e77cc66571dfae8a4bb
Signed-off-by: Greg Hackmann <ghackmann@google.com>
* SUCH DAMAGE.
*/
+#include <errno.h>
#include <sys/epoll.h>
-int epoll_create(int /*obsolete_size*/) {
+int epoll_create(int size) {
+ if (size <= 0) {
+ errno = EINVAL;
+ return -1;
+ }
return epoll_create1(0);
}
ASSERT_EQ(0, epoll_pwait(epoll_fd, events, 1, 1, &ss));
}
+TEST(sys_epoll, epoll_create_invalid_size) {
+ errno = 0;
+ ASSERT_EQ(-1, epoll_create(0));
+ ASSERT_EQ(EINVAL, errno);
+}
+
TEST(sys_epoll, epoll_event_data) {
int epoll_fd = epoll_create(1);
ASSERT_NE(-1, epoll_fd) << strerror(errno);