From: Osama Abdelkader Date: Tue, 28 Oct 2025 20:58:35 +0000 (+0300) Subject: Fix incorrect setrlimit return value checks in tests X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=96073e9f34acd58dd419584218351e86ba8cf6d8;p=thirdparty%2Fglibc.git Fix incorrect setrlimit return value checks in tests The setrlimit(2) function returns 0 on success and -1 on error, but several test files were incorrectly checking for a return value of 1 to detect errors. This means the error checks would never trigger, causing tests to continue silently even when setrlimit() failed. This commit fixes the error checks in five files to correctly test for -1, matching both the documented behavior and the pattern used correctly in other parts of the codebase. Signed-off-by: Osama Abdelkader Reviewed-by: Collin Funk --- diff --git a/debug/tst-sprintf-fortify-rdonly.c b/debug/tst-sprintf-fortify-rdonly.c index fafc8340ea..33a22f5d87 100644 --- a/debug/tst-sprintf-fortify-rdonly.c +++ b/debug/tst-sprintf-fortify-rdonly.c @@ -94,7 +94,7 @@ do_test (void) max_fd = (rl.rlim_cur < max_fd ? rl.rlim_cur : max_fd); rl.rlim_cur = max_fd; - if (setrlimit (RLIMIT_NOFILE, &rl) == 1) + if (setrlimit (RLIMIT_NOFILE, &rl) == -1) FAIL_EXIT1 ("setrlimit (RLIMIT_NOFILE): %m"); /* Exhaust the file descriptor limit with temporary files. */ diff --git a/io/tst-closefrom.c b/io/tst-closefrom.c index 81011644fd..6dc3000207 100644 --- a/io/tst-closefrom.c +++ b/io/tst-closefrom.c @@ -103,7 +103,7 @@ closefrom_test_file_desc_limit (void) max_fd = (rl.rlim_cur < max_fd ? rl.rlim_cur : max_fd); rl.rlim_cur = max_fd; - if (setrlimit (RLIMIT_NOFILE, &rl) == 1) + if (setrlimit (RLIMIT_NOFILE, &rl) == -1) FAIL_EXIT1 ("setrlimit (RLIMIT_NOFILE): %m"); } diff --git a/posix/tst-spawn3.c b/posix/tst-spawn3.c index 3d637e8de6..d17b6d2a06 100644 --- a/posix/tst-spawn3.c +++ b/posix/tst-spawn3.c @@ -62,7 +62,7 @@ do_test (void) max_fd = (rl.rlim_cur < max_fd ? rl.rlim_cur : max_fd); rl.rlim_cur = max_fd; - if (setrlimit (RLIMIT_NOFILE, &rl) == 1) + if (setrlimit (RLIMIT_NOFILE, &rl) == -1) FAIL_EXIT1 ("setrlimit (RLIMIT_NOFILE): %m"); /* Exhauste the file descriptor limit with temporary files. */ diff --git a/support/support-open-dev-null-range.c b/support/support-open-dev-null-range.c index 812d579583..baf70b4118 100644 --- a/support/support-open-dev-null-range.c +++ b/support/support-open-dev-null-range.c @@ -33,7 +33,7 @@ increase_nofile (void) rl.rlim_cur += 128; - if (setrlimit (RLIMIT_NOFILE, &rl) == 1) + if (setrlimit (RLIMIT_NOFILE, &rl) == -1) FAIL_EXIT1 ("setrlimit (RLIMIT_NOFILE): %m"); } diff --git a/support/tst-support-open-dev-null-range.c b/support/tst-support-open-dev-null-range.c index 6db20f0703..545e22242d 100644 --- a/support/tst-support-open-dev-null-range.c +++ b/support/tst-support-open-dev-null-range.c @@ -121,7 +121,7 @@ do_test (void) rl.rlim_cur = number_of_opened_files (); - if (setrlimit (RLIMIT_NOFILE, &rl) == 1) + if (setrlimit (RLIMIT_NOFILE, &rl) == -1) FAIL_EXIT1 ("setrlimit (RLIMIT_NOFILE): %m"); }