#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);
#include <sys/uio.h>
#include <unistd.h>
#include <netinet/in.h>
+#include <libc-diag.h>
/* This is not an exhaustive test: only system calls that can be
persuaded to fail with a consistent error code and no side effects
fails |= test_wrp (EBADF, fstatfs, -1, &sfs);
fails |= test_wrp (EBADF, fsync, -1);
fails |= test_wrp (EBADF, ftruncate, -1, 0);
+
+#if __GNUC_PREREQ (7, 0)
+ DIAG_PUSH_NEEDS_COMMENT;
+ /* Avoid warnings about the second (size) argument being negative. */
+ DIAG_IGNORE_NEEDS_COMMENT (10.1, "-Wstringop-overflow");
+#endif
fails |= test_wrp (EINVAL, getgroups, -1, 0);
+#if __GNUC_PREREQ (7, 0)
+ DIAG_POP_NEEDS_COMMENT;
+#endif
fails |= test_wrp (EBADF, getpeername, -1, &sa, &sl);
fails |= test_wrp (EBADF, getsockname, -1, &sa, &sl);
fails |= test_wrp (EBADF, getsockopt, -1, 0, 0, buf, &sl);
fails |= test_wrp (EINVAL, munmap, (void *) -1, 0);
fails |= test_wrp (EISDIR, open, "/bin", EISDIR, O_WRONLY);
fails |= test_wrp (EBADF, read, -1, buf, 1);
- fails |= test_wrp (EINVAL, readlink, "/", buf, -1);
+ fails |= test_wrp (EINVAL, readlink, "/", buf, sizeof buf);
fails |= test_wrp (EBADF, readv, -1, iov, 1);
fails |= test_wrp (EBADF, recv, -1, buf, 1, 0);
fails |= test_wrp (EBADF, recvfrom, -1, buf, 1, 0, &sa, &sl);