From: Dmitry V. Levin Date: Sun, 22 May 2016 22:29:33 +0000 (+0000) Subject: tests: remove manual creation of memory mapping holes X-Git-Tag: v4.12~108 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=62a35fa57216d7576b76e3835c886393f3760a50;p=strace tests: remove manual creation of memory mapping holes We used to call tail_alloc(1) to create memory mapping holes around regular tail_alloc allocations. This is no longer needed since regular tail_alloc allocations create additional memory mapping holes. * tests/clock_adjtime.c (main): Remove creation of memory mapping holes using tail_alloc(1). * tests/futimesat.c (main): Likewise. * tests/get_mempolicy.c (print_nodes, main): Likewise. * tests/getgroups.c (main): Likewise. * tests/getresugid.c (main): Likewise. * tests/ioctl_uffdio.c (main): Likewise. * tests/ioctl_v4l2.c (main): Likewise. * tests/move_pages.c (main): Likewise. * tests/net-icmp_filter.c (main): Likewise. * tests/ptrace.c (test_peeksiginfo, main): Likewise. * tests/pwritev.c (main): Likewise. * tests/set_mempolicy.c (print_nodes): Likewise. * tests/setgroups.c (main): Likewise. * tests/umovestr3.c (main): Likewise. * tests/utimes.c (main): Likewise. * tests/xattr.c (main): Likewise. --- diff --git a/tests/clock_adjtime.c b/tests/clock_adjtime.c index c9bacf45..93c58b7b 100644 --- a/tests/clock_adjtime.c +++ b/tests/clock_adjtime.c @@ -44,7 +44,6 @@ main(void) rc, errno2name()); void *efault = tail_alloc(1); - (void) tail_alloc(1); rc = syscall(__NR_clock_adjtime, CLOCK_REALTIME, efault); printf("clock_adjtime(CLOCK_REALTIME, %p) = %ld %s (%m)\n", diff --git a/tests/futimesat.c b/tests/futimesat.c index b6702703..785c894e 100644 --- a/tests/futimesat.c +++ b/tests/futimesat.c @@ -56,7 +56,6 @@ main(void) sample, rc, errno2name()); struct timeval *const ts = tail_alloc(sizeof(*ts) * 2); - (void) tail_alloc(1); dirfd = (unsigned long) 0xdeadbeefffffffff; rc = syscall(__NR_futimesat, dirfd, 0, ts + 1); diff --git a/tests/get_mempolicy.c b/tests/get_mempolicy.c index dbecc8d4..6923a216 100644 --- a/tests/get_mempolicy.c +++ b/tests/get_mempolicy.c @@ -47,7 +47,6 @@ print_nodes(unsigned long maxnode) { unsigned long *const nodemask = tail_alloc(sizeof(*nodemask) * NLONGS(maxnode)); - (void) tail_alloc(1); if (syscall(__NR_get_mempolicy, 0, nodemask, maxnode, 0, 0)) { printf("get_mempolicy(NULL, %p, %lu, NULL, 0) = -1 %s (%m)\n", @@ -92,9 +91,7 @@ main(void) "MPOL_F_NODE|MPOL_F_ADDR", flags & ~3, rc, errno2name()); - (void) tail_alloc(1); mode = tail_alloc(sizeof(*mode)); - (void) tail_alloc(1); rc = syscall(__NR_get_mempolicy, mode, 0, 0, 0, 0); printf("get_mempolicy(["); diff --git a/tests/getgroups.c b/tests/getgroups.c index f3611fb7..d70689c7 100644 --- a/tests/getgroups.c +++ b/tests/getgroups.c @@ -125,7 +125,6 @@ main(void) tail_alloc(ngroups ? sizeof(*g1) * ngroups : 1); GID_TYPE *const g2 = tail_alloc(sizeof(*g2) * (ngroups + 1)); void *efault = g2 + ngroups + 1; - (void) tail_alloc(1); get_groups(ngroups, g1); get_groups(ngroups + 1, g1); diff --git a/tests/getresugid.c b/tests/getresugid.c index 1ed134ff..0ee721cf 100644 --- a/tests/getresugid.c +++ b/tests/getresugid.c @@ -37,7 +37,6 @@ main(void) unsigned UGID_TYPE *const r = tail_alloc(sizeof(*r)); unsigned UGID_TYPE *const e = tail_alloc(sizeof(*e)); unsigned UGID_TYPE *const s = tail_alloc(sizeof(*s)); - (void) tail_alloc(1); if (syscall(SYSCALL_NR, r, e, s)) perror_msg_and_fail(SYSCALL_NAME); diff --git a/tests/ioctl_uffdio.c b/tests/ioctl_uffdio.c index 4f27e6d9..73a8a994 100644 --- a/tests/ioctl_uffdio.c +++ b/tests/ioctl_uffdio.c @@ -54,7 +54,6 @@ main(void) perror_msg_and_skip("userfaultfd"); /* ---- API ---- */ - (void) tail_alloc(1); struct uffdio_api *api_struct = tail_alloc(sizeof(*api_struct)); /* With a bad fd */ @@ -96,7 +95,6 @@ main(void) *(char *)area1 = 42; /* ---- REGISTER ---- */ - (void) tail_alloc(1); struct uffdio_register *register_struct = tail_alloc(sizeof(*register_struct)); memset(register_struct, 0, sizeof(*register_struct)); @@ -129,7 +127,6 @@ main(void) * userfaultfd will cause us to stall. */ /* ---- COPY ---- */ - (void) tail_alloc(1); struct uffdio_copy *copy_struct = tail_alloc(sizeof(*copy_struct)); memset(copy_struct, 0, sizeof(*copy_struct)); @@ -151,7 +148,6 @@ main(void) fd, area2, area1, pagesize, pagesize, rc); /* ---- ZEROPAGE ---- */ - (void) tail_alloc(1); struct uffdio_zeropage *zero_struct = tail_alloc(sizeof(*zero_struct)); madvise(area2, pagesize, MADV_DONTNEED); @@ -173,7 +169,6 @@ main(void) fd, area2, pagesize, pagesize, rc); /* ---- WAKE ---- */ - (void) tail_alloc(1); struct uffdio_range *range_struct = tail_alloc(sizeof(*range_struct)); memset(range_struct, 0, sizeof(*range_struct)); diff --git a/tests/ioctl_v4l2.c b/tests/ioctl_v4l2.c index 7969c06f..850783d5 100644 --- a/tests/ioctl_v4l2.c +++ b/tests/ioctl_v4l2.c @@ -47,11 +47,8 @@ init_magic(void *addr, const unsigned int size) int main(void ) { - (void) tail_alloc(1); const unsigned int size = get_page_size(); - (void) tail_alloc(1); void *const page = tail_alloc(size); - (void) tail_alloc(1); init_magic(page, size); const union u_pixel_format { diff --git a/tests/move_pages.c b/tests/move_pages.c index d95b7360..1059366c 100644 --- a/tests/move_pages.c +++ b/tests/move_pages.c @@ -199,14 +199,12 @@ main(void) const unsigned long pid = (unsigned long) 0xfacefeed00000000 | getpid(); unsigned long count = 1; - (void) tail_alloc(1); const unsigned page_size = get_page_size(); const void *const page = tail_alloc(page_size); const void *const efault = page + page_size; const void **pages = tail_alloc(sizeof(*pages)); int *nodes = tail_alloc(sizeof(*nodes)); int *status = tail_alloc(sizeof(*status)); - (void) tail_alloc(1); print_stat_pages(pid, 0, pages, status); print_move_pages(pid, 0, 0, pages, nodes, status); diff --git a/tests/net-icmp_filter.c b/tests/net-icmp_filter.c index c710906f..d3f956d3 100644 --- a/tests/net-icmp_filter.c +++ b/tests/net-icmp_filter.c @@ -43,7 +43,6 @@ main(void) printf("setsockopt(-1, SOL_RAW, ICMP_FILTER, NULL, 0) = -1 %s (%m)\n", errno2name()); - (void) tail_alloc(1); socklen_t *const plen = tail_alloc(sizeof(*plen)); void *const efault = plen + 1; struct icmp_filter *const f = tail_alloc(sizeof(*f)); diff --git a/tests/ptrace.c b/tests/ptrace.c index 3810bd63..2fbefdd4 100644 --- a/tests/ptrace.c +++ b/tests/ptrace.c @@ -59,7 +59,6 @@ test_peeksiginfo(unsigned long pid, const unsigned long bad_request) unsigned long long off; unsigned int flags, nr; } *const psi = tail_alloc(sizeof(*psi)); - (void) tail_alloc(1); psi->off = 0xdeadbeeffacefeed; psi->flags = 1; @@ -100,7 +99,6 @@ test_peeksiginfo(unsigned long pid, const unsigned long bad_request) const unsigned int nsigs = 4; const uid_t uid = geteuid(); siginfo_t *sigs = tail_alloc(sizeof(*sigs) * nsigs); - (void) tail_alloc(1); psi->off = 0; psi->flags = 0; @@ -188,10 +186,8 @@ main(void) if (!sigset_size) perror_msg_and_fail("rt_sigprocmask"); - (void) tail_alloc(1); void *const k_set = tail_alloc(sigset_size); siginfo_t *const sip = tail_alloc(sizeof(*sip)); - (void) tail_alloc(1); long rc = do_ptrace(bad_request, pid, 0, 0); printf("ptrace(%#lx /* PTRACE_??? */, %u, NULL, NULL) = %ld %s (%m)\n", diff --git a/tests/pwritev.c b/tests/pwritev.c index 0b7b8752..ae05b7af 100644 --- a/tests/pwritev.c +++ b/tests/pwritev.c @@ -95,7 +95,6 @@ main(void) iov[i].iov_base = &buf[i]; iov[i].iov_len = LEN - i; } - tail_alloc(1); const off_t offset = 0xdefaceddeadbeefLL; long rc; diff --git a/tests/set_mempolicy.c b/tests/set_mempolicy.c index efc26633..e59e89fd 100644 --- a/tests/set_mempolicy.c +++ b/tests/set_mempolicy.c @@ -56,7 +56,6 @@ print_nodes(const unsigned long maxnode, unsigned int offset) unsigned long *const nodemask = tail_alloc(size ? size : (offset ? 1 : 0)); memset(nodemask, 0, size); - (void) tail_alloc(1); long rc = syscall(__NR_set_mempolicy, 0, nodemask, maxnode); int saved_errno = errno; diff --git a/tests/setgroups.c b/tests/setgroups.c index 30f363a2..8355301c 100644 --- a/tests/setgroups.c +++ b/tests/setgroups.c @@ -88,7 +88,6 @@ main(void) const GID_TYPE *const g1 = tail_alloc(sizeof(*g1)); GID_TYPE *const g2 = tail_alloc(sizeof(*g2) * 2); GID_TYPE *const g3 = tail_alloc(sizeof(*g3) * 3); - (void) tail_alloc(1); if (syscall(SYSCALL_NR, 0, g1 + 1)) printf("%s(0, []) = -1 %s (%m)\n", diff --git a/tests/umovestr3.c b/tests/umovestr3.c index 7b2e6388..cf2fa7d4 100644 --- a/tests/umovestr3.c +++ b/tests/umovestr3.c @@ -33,12 +33,9 @@ int main(void) { - (void) tail_alloc(1); const unsigned int size = PATH_MAX - 1; const char *p = tail_alloc(size); const char *const efault = p + size; - (void) tail_alloc(1); - (void) tail_alloc(1); for (; p <= efault; ++p) { int rc = chdir(p); diff --git a/tests/utimes.c b/tests/utimes.c index e350770e..e9fe931a 100644 --- a/tests/utimes.c +++ b/tests/utimes.c @@ -55,7 +55,6 @@ main(void) sample, rc, errno2name()); struct timeval *const ts = tail_alloc(sizeof(*ts) * 2); - (void) tail_alloc(1); rc = syscall(__NR_utimes, 0, ts + 1); printf("utimes(NULL, %p) = %ld %s (%m)\n", diff --git a/tests/xattr.c b/tests/xattr.c index c7a33423..e72436ca 100644 --- a/tests/xattr.c +++ b/tests/xattr.c @@ -44,12 +44,10 @@ main(void) static const char c_value[] = "foo\0bar"; static const char q_value[] = "foo\\0bar"; - tail_alloc(1); const char *const z_value = tail_memdup(c_value, sizeof(c_value)); char *const efault = tail_alloc(1) + 1; const char *const value = tail_memdup(c_value, sizeof(c_value) - 1); char *const big = tail_alloc(XATTR_SIZE_MAX + 1); - tail_alloc(1); assert(fsetxattr(-1, 0, 0, 0, XATTR_CREATE) == -1); printf("fsetxattr(-1, NULL, NULL, 0, XATTR_CREATE) = -1 %s (%m)\n",