/* Test of getcwd function.
- Copyright (C) 2000-2017 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 Lesser General Public
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
- <http://www.gnu.org/licenses/>. */
+ <https://www.gnu.org/licenses/>. */
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <sys/param.h>
+#include <libc-diag.h>
#define TEST_FUNCTION do_test ()
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)
{
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);
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);