From 657f762f0c646dafb4735b164d0372467267f6fd Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Mon, 26 Jun 2023 18:12:06 -0500 Subject: [PATCH] Update: Reduce NULL parameter requirements in f_file_select() regarding timeout. The man pages state that the read, write, and except can all be NULL if timeout is not NULL. Change the behavior of f_file_select() to allow this. --- level_0/f_file/c/file.c | 2 +- level_0/f_file/c/file.h | 2 +- level_0/f_file/tests/unit/c/test-file-select.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/level_0/f_file/c/file.c b/level_0/f_file/c/file.c index c6cbd8c..9157d3a 100644 --- a/level_0/f_file/c/file.c +++ b/level_0/f_file/c/file.c @@ -1900,7 +1900,7 @@ extern "C" { f_status_t f_file_select(const int highest_plus_one, fd_set * const read, fd_set * const write, fd_set * const except, struct timeval * const timeout) { if (!highest_plus_one) return F_data_not; - if (!read && !write && !except) return F_data_not; + if (!read && !write && !except && !timeout) return F_data_not; if (select(highest_plus_one, read, write, except, timeout) == -1) { if (errno == EBADF) return F_status_set_error(F_file_descriptor); diff --git a/level_0/f_file/c/file.h b/level_0/f_file/c/file.h index d913aef..a29487b 100644 --- a/level_0/f_file/c/file.h +++ b/level_0/f_file/c/file.h @@ -1985,7 +1985,7 @@ extern "C" { * * @return * F_none on success. - * F_data_not if all three read, write, and except are NULL (having at least one is required) or when highest_plus_one is 0. + * F_data_not if all of read, write, except, and timeout are NULL (having at least one is required) or when highest_plus_one is 0. * * F_file_descriptor (with error bit) if the file descriptor is invalid. * F_interrupt (with error bit) when program received an interrupt signal, halting operation. diff --git a/level_0/f_file/tests/unit/c/test-file-select.c b/level_0/f_file/tests/unit/c/test-file-select.c index 14b37ca..2a06690 100644 --- a/level_0/f_file/tests/unit/c/test-file-select.c +++ b/level_0/f_file/tests/unit/c/test-file-select.c @@ -137,7 +137,7 @@ void test__f_file_select__returns_data_not(void **state) { } { - const f_status_t status = f_file_select(1, 0, 0, 0, &timeout); + const f_status_t status = f_file_select(0, 0, 0, 0, &timeout); assert_int_equal(status, F_data_not); } -- 1.8.3.1