]> git.ipfire.org Git - thirdparty/glibc.git/blobdiff - rt/tst-aio.c
malloc: set NON_MAIN_ARENA flag for reclaimed memalign chunk (BZ #30101)
[thirdparty/glibc.git] / rt / tst-aio.c
index 24efad3e233c236ac25a6498aa9f3af8bfac2dea..d8b0788f2e7766fe8f3b803f75caa0c4c21cc380 100644 (file)
@@ -1,7 +1,6 @@
 /* Tests for AIO in librt.
-   Copyright (C) 1998,2000,02 Free Software Foundation, Inc.
+   Copyright (C) 1998-2023 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
 
    The GNU C Library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
 
 #include <aio.h>
 #include <errno.h>
 #include <error.h>
+#include <fcntl.h>
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
@@ -34,9 +33,6 @@ extern int do_test (int argc, char *argv[]);
 /* We have a preparation function.  */
 #define PREPARE do_prepare
 
-/* We might need a bit longer timeout.  */
-#define TIMEOUT 20 /* sec */
-
 /* This defines the `main' function and some more.  */
 #include <test-skeleton.c>
 
@@ -48,18 +44,18 @@ int fd;
 void
 do_prepare (int argc, char *argv[])
 {
-  char name_len;
+  size_t name_len;
 
   name_len = strlen (test_dir);
-  name = malloc (name_len + sizeof ("/aioXXXXXX"));
+  name = xmalloc (name_len + sizeof ("/aioXXXXXX"));
   mempcpy (mempcpy (name, test_dir, name_len),
           "/aioXXXXXX", sizeof ("/aioXXXXXX"));
-  add_temp_file (name);
 
   /* Open our test file.   */
   fd = mkstemp (name);
   if (fd == -1)
     error (EXIT_FAILURE, errno, "cannot open test file `%s'", name);
+  add_temp_file (name);
 }
 
 
@@ -278,7 +274,7 @@ do_test (int argc, char *argv[])
   for (cnt = 10; cnt > 0; )
     if (aio_cancel (fd, cbp[--cnt]) == -1)
       /* This is not an error.  The request can simply be finished.  */
-      printf ("aio_cancel (fd, cbp[%Zd]) cannot be canceled\n", cnt);
+      printf ("aio_cancel (fd, cbp[%zd]) cannot be canceled\n", cnt);
   puts ("finished2");
 
   result |= do_wait (cbp, 10, ECANCELED);