From: Kevin Day Date: Mon, 26 Jun 2023 23:12:06 +0000 (-0500) Subject: Update: Reduce NULL parameter requirements in f_file_select() regarding timeout. X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=657f762f0c646dafb4735b164d0372467267f6fd;p=fll 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. --- 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); }