]> sourceware.org Git - glibc.git/blobdiff - io/tst-getcwd.c
x86: Unifies 'strnlen-evex' and 'strnlen-evex512' implementations.
[glibc.git] / io / tst-getcwd.c
index 4b5bc62c7cfb1e65cfed5bb00f92083bc67c16e2..6cd8975cead5d8b2952b0cdd5ca687ab586bc552 100644 (file)
@@ -1,22 +1,20 @@
 /* Test of getcwd function.
-   Copyright (C) 2000 Free Software Foundation, Inc.
+   Copyright (C) 2000-2024 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
-   Contributed by Ulrich Drepper <drepper@cygnus.com>, 2000.
 
    The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Library General Public License as
-   published by the Free Software Foundation; either version 2 of the
-   License, or (at your option) any later version.
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
 
    The GNU C Library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Library General Public License for more details.
+   Lesser General Public License for more details.
 
-   You should have received a copy of the GNU Library General Public
-   License along with the GNU C Library; see the file COPYING.LIB.  If not,
-   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
 
 #include <errno.h>
 #include <stdio.h>
@@ -24,6 +22,7 @@
 #include <string.h>
 #include <unistd.h>
 #include <sys/param.h>
+#include <libc-diag.h>
 
 
 #define TEST_FUNCTION do_test ()
@@ -36,8 +35,7 @@ do_test (void)
   char *bufs[10];
   size_t lens[10];
   size_t sbs;
-  size_t len;
-  int i;
+  size_t len, i;
 
   if (getcwd (thepath, sizeof thepath) == NULL)
     {
@@ -60,7 +58,13 @@ do_test (void)
       bufs[i] = (char *) malloc (sbs);
     }
 
+  /* Avoid warnings about the first argument being null when the second
+     is nonzero.  */
+  DIAG_PUSH_NEEDS_COMMENT;
+  DIAG_IGNORE_NEEDS_COMMENT (10.1, "-Wnonnull");
   bufs[i] = getcwd (NULL, sbs);
+  DIAG_POP_NEEDS_COMMENT;
+
   lens[i] = sbs;
   if (bufs[i] == NULL)
     {
@@ -98,12 +102,17 @@ getcwd (NULL, sbs) = \"%s\", getcwd (thepath, sizeof thepath) = \"%s\"\n",
     free (bufs[i]);
 
   /* Test whether the function signals success despite the buffer
-     being too small.  */
+     being too small.
+     Avoid warnings about the first argument being null when the second
+     is nonzero.  */
+  DIAG_PUSH_NEEDS_COMMENT;
+  DIAG_IGNORE_NEEDS_COMMENT (10.1, "-Wnonnull");
   if (getcwd (NULL, len) != NULL)
     {
       puts ("getcwd (NULL, len) didn't failed");
       return 1;
     }
+  DIAG_POP_NEEDS_COMMENT;
 
   bufs[0] = malloc (len);
   bufs[1] = malloc (len);
@@ -134,13 +143,18 @@ getcwd (NULL, sbs) = \"%s\", getcwd (thepath, sizeof thepath) = \"%s\"\n",
        return 1;
       }
 
-  /* Now test handling of correctly sized buffers.  */
+  /* Now test handling of correctly sized buffers.
+     Again. avoid warnings about the first argument being null when
+     the second is nonzero.  */
+  DIAG_PUSH_NEEDS_COMMENT;
+  DIAG_IGNORE_NEEDS_COMMENT (10.1, "-Wnonnull");
   bufs[0] = getcwd (NULL, len + 1);
   if (bufs[0] == NULL)
     {
       puts ("getcwd (NULL, len + 1) failed");
       return 1;
     }
+  DIAG_POP_NEEDS_COMMENT;
   free (bufs[0]);
 
   memset (thepath, '\xff', sizeof thepath);
@@ -153,7 +167,7 @@ getcwd (NULL, sbs) = \"%s\", getcwd (thepath, sizeof thepath) = \"%s\"\n",
   for (i = len + 1; i < sizeof thepath; ++i)
     if (thepath[i] != '\xff')
       {
-       printf ("thepath[%d] != '\xff'\n", i);
+       printf ("thepath[%zd] != '\xff'\n", i);
        return 1;
       }
 
This page took 0.031353 seconds and 5 git commands to generate.