Fix compiler warnings with open_to_operation.c

Other sidenotes:
- Remove unused variables with main(..)
- Convert errx/exit with -1 to errx/exit with 1
- Fix a bogus test in try_directory_open
  (expected_errno == expected_errno -> errno == expected_errno) [*]
- Fix some warnings related to discarded qualifiers
- Remove a bogus else-statement at the end of check_mmap_exec(..) in the
  successful case. mmap(2), POSIX, Linux, etc all don't state what the
  behavior is when mixing O_WRONLY + PROT_EXEC, so assume success for now to
  get the test program to pass again.

PR: 201286 [*]
MFC after: 1 week
Submitted by: David Binderman <dcb314@hotmail.com>
Sponsored by: EMC / Isilon Storage Division
This commit is contained in:
Enji Cooper 2015-10-30 10:09:04 +00:00
parent 05f1048743
commit 323b92baff
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=290190
2 changed files with 13 additions and 16 deletions

View File

@ -2,6 +2,6 @@
PROG= open_to_operation
MAN=
#WARNS= 3
WARNS?= 3
.include <bsd.prog.mk>

View File

@ -169,9 +169,9 @@ try_directory_open(const char *testname, const char *directory,
ok_mode(testname, NULL, mode);
close(dfd);
} else {
if (expected_errno && expected_errno == expected_errno)
if (expected_errno && expected_errno == errno)
ok_mode(testname, NULL, mode);
else if (expected_errno)
else if (expected_errno != 0)
notok_mode(testname, "wrong errno", mode);
else
notok_mode(testname, "failed", mode);
@ -753,7 +753,8 @@ pwritev_wrapper(int d, const void *buf, size_t nbytes)
static ssize_t
aio_write_wrapper(int d, const void *buf, size_t nbytes)
{
struct aiocb aiocb, *aiocb_array[1];
struct aiocb aiocb;
struct aiocb const *aiocb_array[] = { &aiocb };
bzero(&aiocb, sizeof(aiocb));
aiocb.aio_fildes = d;
@ -839,7 +840,8 @@ preadv_wrapper(int d, void *buf, size_t nbytes)
static ssize_t
aio_read_wrapper(int d, void *buf, size_t nbytes)
{
struct aiocb aiocb, *aiocb_array[1];
struct aiocb aiocb;
struct aiocb const *aiocb_array[] = { &aiocb };
bzero(&aiocb, sizeof(aiocb));
aiocb.aio_fildes = d;
@ -847,7 +849,6 @@ aio_read_wrapper(int d, void *buf, size_t nbytes)
aiocb.aio_nbytes = nbytes;
if (aio_read(&aiocb) < 0)
return (-1);
aiocb_array[0] = &aiocb;
if (aio_suspend(aiocb_array, 1, NULL) < 0)
return (-1);
return (aio_return(&aiocb));
@ -1009,12 +1010,8 @@ check_mmap_exec(const char *testname, const char *path, int isdir,
if (isdir)
notok_mode(testname, "mmap dir succeeded",
mode);
else if ((mode & O_ACCMODE) == O_RDONLY ||
(mode & O_ACCMODE) == O_RDWR)
ok_mode(testname, "mmap file succeeded",
mode);
else
notok_mode(testname, "mmap file succeeded",
ok_mode(testname, "mmap file succeeded",
mode);
(void)munmap(addr, getpagesize());
}
@ -1069,7 +1066,7 @@ check_mmap_write_private(const char *testname, const char *path, int isdir,
}
int
main(int argc, char *argv[])
main(void)
{
char dir_path[PATH_MAX], file_path[PATH_MAX];
int dummy, fd;
@ -1084,25 +1081,25 @@ main(int argc, char *argv[])
strlcpy(dir_path, "/tmp/open-dir.XXXXXXXXXXX", sizeof(dir_path));
if (mkdtemp(dir_path) == NULL)
err(-1, "mkdtemp");
err(1, "mkdtemp");
if (chmod(dir_path, PERM_DIR) < 0) {
warn("chmod %s", dir_path);
(void)rmdir(dir_path);
exit(-1);
exit(1);
}
strlcpy(file_path, "/tmp/open-file.XXXXXXXXXXX", sizeof(file_path));
fd = mkstemp(file_path);
if (fd < 0) {
warn("mkstemp");
(void)rmdir(dir_path);
exit(-1);
exit(1);
}
close(fd);
if (chmod(file_path, PERM_FILE) < 0) {
warn("chmod %s", file_path);
(void)unlink(file_path);
(void)rmdir(dir_path);
exit(-1);
exit(1);
}
check_directory_open_modes(dir_path, file_modes, file_modes_count);