]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Fix incorrect setrlimit return value checks in tests
authorOsama Abdelkader <osama.abdelkader@gmail.com>
Tue, 28 Oct 2025 20:58:35 +0000 (23:58 +0300)
committerCollin Funk <collin.funk1@gmail.com>
Wed, 29 Oct 2025 01:51:51 +0000 (18:51 -0700)
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 <osama.abdelkader@gmail.com>
Reviewed-by: Collin Funk <collin.funk1@gmail.com>
debug/tst-sprintf-fortify-rdonly.c
io/tst-closefrom.c
posix/tst-spawn3.c
support/support-open-dev-null-range.c
support/tst-support-open-dev-null-range.c

index fafc8340eae8aa6dfc9d97504bd147485a77dbb1..33a22f5d87b4c31e75247bc563b22d0cffbd97ea 100644 (file)
@@ -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.  */
index 81011644fdcbc1d3162aa332cac2bc2efc3283de..6dc3000207f8910cf20721a4380e7272bb1d88b2 100644 (file)
@@ -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");
   }
 
index 3d637e8de6ef8648b6efc0c4e275aec05082144e..d17b6d2a06c05cd1abea1caf9b409337984de640 100644 (file)
@@ -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.  */
index 812d5795832833e9cce76fdd8354790989a4f00f..baf70b411859e9fad1b12b65d118ba5a8354c10b 100644 (file)
@@ -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");
 }
 
index 6db20f07030963831f34508a9b5f3b202703e5c4..545e22242d3275a9f3d2fd69c9e257123400066b 100644 (file)
@@ -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");
   }