From owner-svn-src-stable@freebsd.org Mon Nov 9 07:26:35 2015 Return-Path: Delivered-To: svn-src-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id E2F9DA2A885; Mon, 9 Nov 2015 07:26:35 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A2F5E1468; Mon, 9 Nov 2015 07:26:35 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id tA97QYqK081313; Mon, 9 Nov 2015 07:26:34 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id tA97QYh6081311; Mon, 9 Nov 2015 07:26:34 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201511090726.tA97QYh6081311@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Garrett Cooper Date: Mon, 9 Nov 2015 07:26:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r290580 - stable/10/tools/regression/security/open_to_operation X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Nov 2015 07:26:36 -0000 Author: ngie Date: Mon Nov 9 07:26:34 2015 New Revision: 290580 URL: https://svnweb.freebsd.org/changeset/base/290580 Log: MFC r290190,r290251: r290190: 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 [*] Submitted by: David Binderman Sponsored by: EMC / Isilon Storage Division r290251: Use nitems(x) instead of sizeof(x)/sizeof(x[0]) Sponsored by: EMC / Isilon Storage Division Modified: stable/10/tools/regression/security/open_to_operation/Makefile stable/10/tools/regression/security/open_to_operation/open_to_operation.c Directory Properties: stable/10/ (props changed) Modified: stable/10/tools/regression/security/open_to_operation/Makefile ============================================================================== --- stable/10/tools/regression/security/open_to_operation/Makefile Mon Nov 9 07:18:09 2015 (r290579) +++ stable/10/tools/regression/security/open_to_operation/Makefile Mon Nov 9 07:26:34 2015 (r290580) @@ -2,6 +2,6 @@ PROG= open_to_operation MAN= -#WARNS= 3 +WARNS?= 3 .include Modified: stable/10/tools/regression/security/open_to_operation/open_to_operation.c ============================================================================== --- stable/10/tools/regression/security/open_to_operation/open_to_operation.c Mon Nov 9 07:18:09 2015 (r290579) +++ stable/10/tools/regression/security/open_to_operation/open_to_operation.c Mon Nov 9 07:26:34 2015 (r290580) @@ -119,10 +119,10 @@ __FBSDID("$FreeBSD$"); */ static const int file_modes[] = { O_RDONLY, O_WRONLY, O_RDWR, O_RDONLY | O_TRUNC, O_WRONLY | O_TRUNC, O_RDWR | O_TRUNC }; -static const int file_modes_count = sizeof(file_modes) / sizeof(int); +static const int file_modes_count = nitems(file_modes); static const int dir_modes[] = { O_RDONLY }; -static const int dir_modes_count = sizeof(dir_modes) / sizeof(int); +static const int dir_modes_count = nitems(dir_modes); static int testnum; static int aio_present; @@ -169,9 +169,9 @@ try_directory_open(const char *testname, 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, 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 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_ 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, co 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 *tes } 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);