diff options
author | Dmitry V. Levin <ldv@altlinux.org> | 2017-03-16 13:46:36 +0000 |
---|---|---|
committer | Dmitry V. Levin <ldv@altlinux.org> | 2017-03-16 13:46:36 +0000 |
commit | eabace12c42399f03b8ae1a19df19ac6a1b0a4c0 (patch) | |
tree | 854d0be4ac07e1f432f25c83c250d68393a38b64 | |
parent | c36875b1709a3ed3f21ef71a84ef5a7a936c8a8e (diff) | |
download | strace-eabace12c42399f03b8ae1a19df19ac6a1b0a4c0.tar.gz |
tests: use TAIL_ALLOC_OBJECT_CONST_PTR
Automatically convert tests to use TAIL_ALLOC_OBJECT_CONST_PTR macro
with the following sed expression:
sed -ri \
's/^([[:space:]]*)(([^*]+[[:alnum:]_])( \*)?) *\*( *const )?([^ =]+) = tail_alloc\(sizeof\((\2|\*\6)\)\);/\1TAIL_ALLOC_OBJECT_CONST_PTR(\2, \6);/' \
tests/*.c
71 files changed, 121 insertions, 121 deletions
diff --git a/tests/adjtimex.c b/tests/adjtimex.c index 0eff97312..d0e36306a 100644 --- a/tests/adjtimex.c +++ b/tests/adjtimex.c @@ -43,7 +43,7 @@ main(void) int state = adjtimex(NULL); printf("adjtimex(NULL) = %s\n", sprintrc(state)); - struct timex *const tx = tail_alloc(sizeof(*tx)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct timex, tx); memset(tx, 0, sizeof(*tx)); state = adjtimex(tx); diff --git a/tests/aio.c b/tests/aio.c index 0766d23a7..4b114678f 100644 --- a/tests/aio.c +++ b/tests/aio.c @@ -198,7 +198,7 @@ main(void) }; const long *cbvs2 = tail_memdup(proto_cbvs2, sizeof(proto_cbvs2)); - unsigned long *ctx = tail_alloc(sizeof(unsigned long)); + TAIL_ALLOC_OBJECT_CONST_PTR(unsigned long, ctx); *ctx = 0; const unsigned int nr = ARRAY_SIZE(proto_cb); diff --git a/tests/copy_file_range.c b/tests/copy_file_range.c index 085010af0..f0d6a57c4 100644 --- a/tests/copy_file_range.c +++ b/tests/copy_file_range.c @@ -41,8 +41,8 @@ main(void) { const long int fd_in = (long int) 0xdeadbeefffffffff; const long int fd_out = (long int) 0xdeadbeeffffffffe; - long long int *const off_in = tail_alloc(sizeof(*off_in)); - long long int *const off_out = tail_alloc(sizeof(*off_out)); + TAIL_ALLOC_OBJECT_CONST_PTR(long long int, off_in); + TAIL_ALLOC_OBJECT_CONST_PTR(long long int, off_out); *off_in = 0xdeadbef1facefed1; *off_out = 0xdeadbef2facefed2; const size_t len = (size_t) 0xdeadbef3facefed3ULL; diff --git a/tests/epoll_ctl.c b/tests/epoll_ctl.c index ca4a959e2..2251b3589 100644 --- a/tests/epoll_ctl.c +++ b/tests/epoll_ctl.c @@ -18,7 +18,7 @@ invoke_syscall(unsigned long epfd, unsigned long op, unsigned long fd, void *ev) int main(void) { - struct epoll_event *const ev = tail_alloc(sizeof(*ev)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct epoll_event, ev); ev->events = EPOLLIN; long rc = invoke_syscall(-1U, EPOLL_CTL_ADD, -2U, ev); diff --git a/tests/epoll_pwait.c b/tests/epoll_pwait.c index eaaa34d62..841e7228c 100644 --- a/tests/epoll_pwait.c +++ b/tests/epoll_pwait.c @@ -12,7 +12,7 @@ int main(void) { sigset_t set[2]; - struct epoll_event *const ev = tail_alloc(sizeof(*ev)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct epoll_event, ev); long rc = syscall(__NR_epoll_pwait, -1, ev, 1, -2, set, (kernel_ulong_t) sizeof(set)); diff --git a/tests/epoll_wait.c b/tests/epoll_wait.c index 038bf1f78..caa30271e 100644 --- a/tests/epoll_wait.c +++ b/tests/epoll_wait.c @@ -10,7 +10,7 @@ int main(void) { - struct epoll_event *const ev = tail_alloc(sizeof(*ev)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct epoll_event, ev); long rc = syscall(__NR_epoll_wait, -1, ev, 1, -2); printf("epoll_wait(-1, %p, 1, -2) = %ld %s (%m)\n", diff --git a/tests/execve.c b/tests/execve.c index 74749e73e..d73a00da4 100644 --- a/tests/execve.c +++ b/tests/execve.c @@ -103,7 +103,7 @@ main(void) #endif ); - char **const empty = tail_alloc(sizeof(*empty)); + TAIL_ALLOC_OBJECT_CONST_PTR(char *, empty); char **const efault = empty + 1; *empty = NULL; diff --git a/tests/execveat.c b/tests/execveat.c index 9083830eb..e01fe4e60 100644 --- a/tests/execveat.c +++ b/tests/execveat.c @@ -108,7 +108,7 @@ main(void) #endif errno2name()); - char **const empty = tail_alloc(sizeof(*empty)); + TAIL_ALLOC_OBJECT_CONST_PTR(char *, empty); char **const efault = empty + 1; *empty = NULL; diff --git a/tests/file_handle.c b/tests/file_handle.c index 175cae0f9..d41f54af3 100644 --- a/tests/file_handle.c +++ b/tests/file_handle.c @@ -208,7 +208,7 @@ main(void) tail_alloc(sizeof(struct file_handle) + 128); struct file_handle *handle_256 = tail_alloc(sizeof(struct file_handle) + 256); - int *bogus_mount_id = tail_alloc(sizeof(*bogus_mount_id)); + TAIL_ALLOC_OBJECT_CONST_PTR(int, bogus_mount_id); char handle_0_addr[sizeof("0x") + sizeof(void *) * 2]; diff --git a/tests/file_ioctl.c b/tests/file_ioctl.c index 0fe17b15d..ded67a9c9 100644 --- a/tests/file_ioctl.c +++ b/tests/file_ioctl.c @@ -13,7 +13,7 @@ static void test_fiemap(void) { (void) tail_alloc(1); - struct fiemap *const args = tail_alloc(sizeof(*args)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct fiemap, args); printf("ioctl(-1, FS_IOC_FIEMAP, {fm_start=%" PRI__u64 ", fm_length=%" PRI__u64", fm_flags=", diff --git a/tests/futex.c b/tests/futex.c index 586b95d5e..81819c8c5 100644 --- a/tests/futex.c +++ b/tests/futex.c @@ -163,8 +163,8 @@ void invalid_op(int *val, int op, uint32_t argmask, ...) int main(int argc, char *argv[]) { - int *uaddr = tail_alloc(sizeof(*uaddr)); - int *uaddr2 = tail_alloc(sizeof(*uaddr2)); + TAIL_ALLOC_OBJECT_CONST_PTR(int, uaddr); + TAIL_ALLOC_OBJECT_CONST_PTR(int, uaddr2); int rc; unsigned i; unsigned j; diff --git a/tests/getcpu.c b/tests/getcpu.c index ec671f1e8..a58a375eb 100644 --- a/tests/getcpu.c +++ b/tests/getcpu.c @@ -47,8 +47,8 @@ main(void) (unsigned *) tail_alloc(sizeof(* bogus_tcache)) + 1; long res; - unsigned *cpu = tail_alloc(sizeof(*cpu)); - unsigned *node = tail_alloc(sizeof(*node)); + TAIL_ALLOC_OBJECT_CONST_PTR(unsigned, cpu); + TAIL_ALLOC_OBJECT_CONST_PTR(unsigned, node); long * tcache = tail_alloc(128); res = syscall(__NR_getcpu, NULL, NULL, NULL); diff --git a/tests/getresugid.c b/tests/getresugid.c index 0ee721cfe..7458ed947 100644 --- a/tests/getresugid.c +++ b/tests/getresugid.c @@ -34,9 +34,9 @@ int 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)); + TAIL_ALLOC_OBJECT_CONST_PTR(unsigned UGID_TYPE, r); + TAIL_ALLOC_OBJECT_CONST_PTR(unsigned UGID_TYPE, e); + TAIL_ALLOC_OBJECT_CONST_PTR(unsigned UGID_TYPE, s); if (syscall(SYSCALL_NR, r, e, s)) perror_msg_and_fail(SYSCALL_NAME); diff --git a/tests/getrusage.c b/tests/getrusage.c index 2ac049726..002420f0f 100644 --- a/tests/getrusage.c +++ b/tests/getrusage.c @@ -68,7 +68,7 @@ invoke_print(int who, const char *who_str, struct rusage *usage) int main(void) { - struct rusage *const usage = tail_alloc(sizeof(*usage)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct rusage, usage); if (invoke_print(ARG_STR(RUSAGE_SELF), usage)) { perror_msg_and_fail("RUSAGE_SELF"); } diff --git a/tests/ioctl_block.c b/tests/ioctl_block.c index f62b0b365..181eeb8bf 100644 --- a/tests/ioctl_block.c +++ b/tests/ioctl_block.c @@ -113,7 +113,7 @@ main(void) ioctl(-1, BLKFRASET, lmagic); printf("ioctl(-1, BLKFRASET, %lu) = -1 EBADF (%m)\n", lmagic); - int *const val_int = tail_alloc(sizeof(*val_int)); + TAIL_ALLOC_OBJECT_CONST_PTR(int, val_int); *val_int = magic; ioctl(-1, BLKROSET, val_int); @@ -144,7 +144,7 @@ main(void) " = -1 EBADF (%m)\n", pair_int64[0], pair_int64[1]); #endif - struct blkpg_ioctl_arg *const blkpg = tail_alloc(sizeof(*blkpg)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct blkpg_ioctl_arg, blkpg); blkpg->op = 3; blkpg->flags = 0xdeadbeef; blkpg->datalen = 0xbadc0ded; @@ -156,7 +156,7 @@ main(void) "BLKPG_RESIZE_PARTITION", blkpg->flags, blkpg->datalen, (unsigned long) blkpg->data); - struct blkpg_partition *const bp = tail_alloc(sizeof(*bp)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct blkpg_partition, bp); bp->start = 0xfac1fed2dad3bef4ULL; bp->length = 0xfac5fed6dad7bef8ULL; bp->pno = magic; @@ -177,7 +177,7 @@ main(void) (int) sizeof(bp->volname) - 1, bp->volname); #if defined BLKTRACESETUP && defined HAVE_STRUCT_BLK_USER_TRACE_SETUP - struct blk_user_trace_setup *const buts = tail_alloc(sizeof(*buts)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct blk_user_trace_setup, buts); fill_memory(buts, sizeof(*buts)); ioctl(-1, BLKTRACESETUP, buts); diff --git a/tests/ioctl_evdev.c b/tests/ioctl_evdev.c index d12323ee2..9e6de6c4e 100644 --- a/tests/ioctl_evdev.c +++ b/tests/ioctl_evdev.c @@ -148,7 +148,7 @@ main(void) void *const page = tail_alloc(size); fill_memory(page, size); - int *const val_int = tail_alloc(sizeof(*val_int)); + TAIL_ALLOC_OBJECT_CONST_PTR(int, val_int); *val_int = magic; # ifdef EVIOCSCLOCKID @@ -172,7 +172,7 @@ main(void) pair_int[0], "KEY_ESC"); # ifdef EVIOCSKEYCODE_V2 - struct input_keymap_entry *const ike = tail_alloc(sizeof(*ike)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct input_keymap_entry, ike); fill_memory(ike, sizeof(*ike)); ike->keycode = 2; @@ -196,7 +196,7 @@ main(void) printf("}) = -1 EBADF (%m)\n"); # endif - struct ff_effect *const ffe = tail_alloc(sizeof(*ffe)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct ff_effect, ffe); fill_memory(ffe, sizeof(*ffe)); ffe->type = FF_CONSTANT; diff --git a/tests/ioctl_loop.c b/tests/ioctl_loop.c index a95e775da..d973d8280 100644 --- a/tests/ioctl_loop.c +++ b/tests/ioctl_loop.c @@ -175,8 +175,8 @@ main(void) static const kernel_ulong_t kernel_mask = ((kernel_ulong_t) -1) - ((unsigned long) -1L); - struct loop_info * const info = tail_alloc(sizeof(*info)); - struct loop_info64 * const info64 = tail_alloc(sizeof(*info64)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct loop_info, info); + TAIL_ALLOC_OBJECT_CONST_PTR(struct loop_info64, info64); /* Unknown loop commands */ ioctl(-1, unknown_loop_cmd, magic); diff --git a/tests/ioctl_mtd.c b/tests/ioctl_mtd.c index a37d5d0f0..86b099c89 100644 --- a/tests/ioctl_mtd.c +++ b/tests/ioctl_mtd.c @@ -95,13 +95,13 @@ main(void) ioctl(-1, MTDFILEMODE, MTD_FILE_MODE_NORMAL); printf("ioctl(-1, MTDFILEMODE, MTD_FILE_MODE_NORMAL) = -1 EBADF (%m)\n"); - int *const opt = tail_alloc(sizeof(*opt)); + TAIL_ALLOC_OBJECT_CONST_PTR(int, opt); *opt = MTD_OTP_OFF; ioctl(-1, OTPSELECT, opt); printf("ioctl(-1, MIXER_READ(%u) or OTPSELECT, [MTD_OTP_OFF])" " = -1 EBADF (%m)\n", (unsigned int) _IOC_NR(OTPSELECT)); - uint64_t *const v64 = tail_alloc(sizeof(*v64)); + TAIL_ALLOC_OBJECT_CONST_PTR(uint64_t, v64); fill_memory(v64, sizeof(*v64)); ioctl(-1, MEMGETBADBLOCK, v64); @@ -114,7 +114,7 @@ main(void) " = -1 EBADF (%m)\n", (unsigned int) _IOC_NR(MEMSETBADBLOCK), *v64); - struct region_info_user *const riu = tail_alloc(sizeof(*riu)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct region_info_user, riu); fill_memory(riu, sizeof(*riu)); ioctl(-1, MEMGETREGIONINFO, riu); printf("ioctl(-1, %s, {regionindex=%#x}) = -1 EBADF (%m)\n", @@ -124,7 +124,7 @@ main(void) #endif , riu->regionindex); - struct erase_info_user *const eiu = tail_alloc(sizeof(*eiu)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct erase_info_user, eiu); fill_memory(eiu, sizeof(*eiu)); TEST_erase_info_user(MEMERASE, eiu); @@ -132,7 +132,7 @@ main(void) TEST_erase_info_user(MEMUNLOCK, eiu); TEST_erase_info_user(MEMISLOCKED, eiu); - struct erase_info_user64 *const eiu64 = tail_alloc(sizeof(*eiu64)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct erase_info_user64, eiu64); fill_memory(eiu64, sizeof(*eiu64)); ioctl(-1, MEMERASE64, eiu64); printf("ioctl(-1, MIXER_WRITE(%u) or %s, {start=%#llx, length=%#llx})" @@ -141,7 +141,7 @@ main(void) (unsigned long long) eiu64->start, (unsigned long long) eiu64->length); - struct mtd_oob_buf *const oob = tail_alloc(sizeof(*oob)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct mtd_oob_buf, oob); fill_memory(oob, sizeof(*oob)); ioctl(-1, MEMWRITEOOB, oob); @@ -152,7 +152,7 @@ main(void) printf("ioctl(-1, MEMREADOOB, {start=%#x, length=%#x, ptr=%p})" " = -1 EBADF (%m)\n", oob->start, oob->length, oob->ptr); - struct mtd_oob_buf64 *const oob64 = tail_alloc(sizeof(*oob64)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct mtd_oob_buf64, oob64); fill_memory(oob64, sizeof(*oob64)); ioctl(-1, MEMWRITEOOB64, oob64); @@ -168,14 +168,14 @@ main(void) (unsigned long long) oob64->usr_ptr); - struct otp_info *const oi = tail_alloc(sizeof(*oi)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct otp_info, oi); fill_memory(oi, sizeof(*oi)); ioctl(-1, OTPLOCK, oi); printf("ioctl(-1, MIXER_READ(%u) or OTPLOCK" ", {start=%#x, length=%#x, locked=%u}) = -1 EBADF (%m)\n", (unsigned int) _IOC_NR(OTPLOCK), oi->start, oi->length, oi->locked); - struct mtd_write_req *const wr = tail_alloc(sizeof(*wr)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct mtd_write_req, wr); fill_memory(wr, sizeof(*wr)); wr->mode = MTD_OPS_PLACE_OOB; ioctl(-1, MEMWRITE, wr); diff --git a/tests/ioctl_rtc.c b/tests/ioctl_rtc.c index 49d7ec7b0..52168ac8c 100644 --- a/tests/ioctl_rtc.c +++ b/tests/ioctl_rtc.c @@ -73,13 +73,13 @@ main(void) void *const page = tail_alloc(size); fill_memory(page, size); - struct rtc_time *rt = tail_alloc(sizeof(*rt)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct rtc_time, rt); fill_memory(rt, sizeof(*rt)); - struct rtc_wkalrm *wk = tail_alloc(sizeof(*wk)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct rtc_wkalrm, wk); fill_memory(wk, sizeof(*wk)); - struct rtc_pll_info *pll = tail_alloc(sizeof(*pll)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct rtc_pll_info, pll); fill_memory(pll, sizeof(*pll)); /* RTC_ALM_READ */ diff --git a/tests/ioctl_scsi.c b/tests/ioctl_scsi.c index 0db94d849..a9ecf2883 100644 --- a/tests/ioctl_scsi.c +++ b/tests/ioctl_scsi.c @@ -69,7 +69,7 @@ int main(void) { - int *const pint = tail_alloc(sizeof(*pint)); + TAIL_ALLOC_OBJECT_CONST_PTR(int, pint); *pint = (int) 0xfacefeed; TEST_NO_ARG(SG_GET_TIMEOUT); diff --git a/tests/ioctl_sg_io_v3.c b/tests/ioctl_sg_io_v3.c index ef25795b7..3808b2099 100644 --- a/tests/ioctl_sg_io_v3.c +++ b/tests/ioctl_sg_io_v3.c @@ -43,7 +43,7 @@ main(void) ioctl(-1, SG_IO, 0); printf("ioctl(-1, SG_IO, NULL) = -1 EBADF (%m)\n"); - struct sg_io_hdr *const sg_io = tail_alloc(sizeof(*sg_io)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct sg_io_hdr, sg_io); fill_memory(sg_io, sizeof(*sg_io)); const void *const efault = sg_io + 1; @@ -53,7 +53,7 @@ main(void) ioctl(-1, SG_IO, sg_io); printf("ioctl(-1, SG_IO, [%u]) = -1 EBADF (%m)\n", sg_io->interface_id); - unsigned int *const piid = tail_alloc(sizeof(*piid)); + TAIL_ALLOC_OBJECT_CONST_PTR(unsigned int, piid); *piid = (unsigned char) 'S'; ioctl(-1, SG_IO, piid); printf("ioctl(-1, SG_IO, {interface_id='S', %p}) = -1 EBADF (%m)\n", piid + 1); diff --git a/tests/ioctl_sg_io_v4.c b/tests/ioctl_sg_io_v4.c index 5f899eeea..9c1e9fa06 100644 --- a/tests/ioctl_sg_io_v4.c +++ b/tests/ioctl_sg_io_v4.c @@ -45,7 +45,7 @@ main(void) ioctl(-1, SG_IO, 0); printf("ioctl(-1, SG_IO, NULL) = -1 EBADF (%m)\n"); - struct sg_io_v4 *const sg_io = tail_alloc(sizeof(*sg_io)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct sg_io_v4, sg_io); fill_memory(sg_io, sizeof(*sg_io)); const void *const efault = sg_io + 1; @@ -55,7 +55,7 @@ main(void) ioctl(-1, SG_IO, sg_io); printf("ioctl(-1, SG_IO, [%u]) = -1 EBADF (%m)\n", sg_io->guard); - unsigned int *const pguard = tail_alloc(sizeof(*pguard)); + TAIL_ALLOC_OBJECT_CONST_PTR(unsigned int, pguard); *pguard = (unsigned char) 'Q'; ioctl(-1, SG_IO, pguard); printf("ioctl(-1, SG_IO, {guard='Q', %p}) = -1 EBADF (%m)\n", pguard + 1); diff --git a/tests/ioctl_sock_gifconf.c b/tests/ioctl_sock_gifconf.c index ae0bea4f8..e82b766ad 100644 --- a/tests/ioctl_sock_gifconf.c +++ b/tests/ioctl_sock_gifconf.c @@ -134,7 +134,7 @@ int main(int argc, char *argv[]) { struct ifreq *ifr = tail_alloc(2 * sizeof(*ifr)); - struct ifconf *ifc = tail_alloc(sizeof(*ifc)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct ifconf, ifc); struct sockaddr_in addr; int fd; diff --git a/tests/ioctl_uffdio.c b/tests/ioctl_uffdio.c index 10b8b843f..7d230cd58 100644 --- a/tests/ioctl_uffdio.c +++ b/tests/ioctl_uffdio.c @@ -54,7 +54,7 @@ main(void) perror_msg_and_skip("userfaultfd"); /* ---- API ---- */ - struct uffdio_api *api_struct = tail_alloc(sizeof(*api_struct)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct uffdio_api, api_struct); /* With a bad fd */ memset(api_struct, 0, sizeof(*api_struct)); @@ -127,7 +127,7 @@ main(void) * userfaultfd will cause us to stall. */ /* ---- COPY ---- */ - struct uffdio_copy *copy_struct = tail_alloc(sizeof(*copy_struct)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct uffdio_copy, copy_struct); memset(copy_struct, 0, sizeof(*copy_struct)); rc = ioctl(-1, UFFDIO_COPY, copy_struct); @@ -148,7 +148,7 @@ main(void) fd, area2, area1, pagesize, pagesize, rc); /* ---- ZEROPAGE ---- */ - struct uffdio_zeropage *zero_struct = tail_alloc(sizeof(*zero_struct)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct uffdio_zeropage, zero_struct); madvise(area2, pagesize, MADV_DONTNEED); memset(zero_struct, 0, sizeof(*zero_struct)); @@ -169,7 +169,7 @@ main(void) fd, area2, pagesize, pagesize, rc); /* ---- WAKE ---- */ - struct uffdio_range *range_struct = tail_alloc(sizeof(*range_struct)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct uffdio_range, range_struct); memset(range_struct, 0, sizeof(*range_struct)); rc = ioctl(-1, UFFDIO_WAKE, range_struct); diff --git a/tests/ioctl_v4l2.c b/tests/ioctl_v4l2.c index af8c3419a..bff5d4355 100644 --- a/tests/ioctl_v4l2.c +++ b/tests/ioctl_v4l2.c @@ -76,7 +76,7 @@ main(void ) ioctl(-1, VIDIOC_ENUM_FMT, 0); printf("ioctl(-1, VIDIOC_ENUM_FMT, NULL) = -1 EBADF (%m)\n"); - struct v4l2_fmtdesc *const p_fmtdesc = tail_alloc(sizeof(*p_fmtdesc)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct v4l2_fmtdesc, p_fmtdesc); p_fmtdesc->index = magic; p_fmtdesc->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; ioctl(-1, VIDIOC_ENUM_FMT, p_fmtdesc); @@ -88,7 +88,7 @@ main(void ) ioctl(-1, VIDIOC_G_FMT, 0); printf("ioctl(-1, VIDIOC_G_FMT, NULL) = -1 EBADF (%m)\n"); - struct v4l2_format *const p_format = tail_alloc(sizeof(*p_format)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct v4l2_format, p_format); p_format->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; ioctl(-1, VIDIOC_G_FMT, p_format); diff --git a/tests/ip_mreq.c b/tests/ip_mreq.c index fa0c504b4..d64898a7f 100644 --- a/tests/ip_mreq.c +++ b/tests/ip_mreq.c @@ -44,8 +44,8 @@ main(void) static const char multi6addr[] = "ff01::c"; static const char interface[] = "127.0.0.1"; - struct ip_mreq *const m4 = tail_alloc(sizeof(*m4)); - struct ipv6_mreq *const m6 = tail_alloc(sizeof(*m6)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct ip_mreq, m4); + TAIL_ALLOC_OBJECT_CONST_PTR(struct ipv6_mreq, m6); unsigned int i; int rc; diff --git a/tests/mq_sendrecv.c b/tests/mq_sendrecv.c index c151542ce..ce67335bd 100644 --- a/tests/mq_sendrecv.c +++ b/tests/mq_sendrecv.c @@ -242,7 +242,7 @@ main(void) kernel_long_t *bogus_attrs = tail_alloc(sizeof(*bogus_attrs) * NUM_ATTRS); char *msg = tail_alloc(MSG_SIZE); - unsigned *bogus_prio_ptr = tail_alloc(sizeof(*bogus_prio_ptr)); + TAIL_ALLOC_OBJECT_CONST_PTR(unsigned, bogus_prio_ptr); struct timespec *bogus_tmout = tail_memdup(&bogus_tmout_data, sizeof(*bogus_tmout)); struct timespec *future_tmout = tail_memdup(&future_tmout_data, diff --git a/tests/msg_control.c b/tests/msg_control.c index 709a30758..c6cca0c90 100644 --- a/tests/msg_control.c +++ b/tests/msg_control.c @@ -689,7 +689,7 @@ int main(int ac, const char **av) int rc = sendmsg(-1, 0, 0); printf("sendmsg(-1, NULL, 0) = %d %s (%m)\n", rc, errno2name()); - struct msghdr *mh = tail_alloc(sizeof(*mh)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct msghdr, mh); memset(mh, 0, sizeof(*mh)); test_big_len(mh); diff --git a/tests/msg_name.c b/tests/msg_name.c index c2ddda2ac..e5038cca1 100644 --- a/tests/msg_name.c +++ b/tests/msg_name.c @@ -47,13 +47,13 @@ send_recv(const int send_fd, const int recv_fd, static void test_msg_name(const int send_fd, const int recv_fd) { - char *const recv_buf = tail_alloc(sizeof(*recv_buf)); - struct iovec *const iov = tail_alloc(sizeof(*iov)); + TAIL_ALLOC_OBJECT_CONST_PTR(char, recv_buf); + TAIL_ALLOC_OBJECT_CONST_PTR(struct iovec, iov); iov->iov_base = recv_buf; iov->iov_len = sizeof(*recv_buf); - struct sockaddr_un *const addr = tail_alloc(sizeof(*addr)); - struct msghdr *const msg = tail_alloc(sizeof(*msg)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct sockaddr_un, addr); + TAIL_ALLOC_OBJECT_CONST_PTR(struct msghdr, msg); msg->msg_name = addr; msg->msg_namelen = sizeof(*addr); msg->msg_iov = iov; diff --git a/tests/net-icmp_filter.c b/tests/net-icmp_filter.c index f3f99f142..0d92f421c 100644 --- a/tests/net-icmp_filter.c +++ b/tests/net-icmp_filter.c @@ -43,9 +43,9 @@ main(void) printf("setsockopt(-1, SOL_RAW, ICMP_FILTER, NULL, 0) = -1 %s (%m)\n", errno2name()); - socklen_t *const plen = tail_alloc(sizeof(*plen)); + TAIL_ALLOC_OBJECT_CONST_PTR(socklen_t, plen); void *const efault = plen + 1; - struct icmp_filter *const f = tail_alloc(sizeof(*f)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct icmp_filter, f); getsockopt(-1, SOL_RAW, ICMP_FILTER, f, plen); printf("getsockopt(-1, SOL_RAW, ICMP_FILTER, %p, %p) = -1 %s (%m)\n", diff --git a/tests/net-y-unix.c b/tests/net-y-unix.c index 3efc2f645..0b27c79c0 100644 --- a/tests/net-y-unix.c +++ b/tests/net-y-unix.c @@ -49,7 +49,7 @@ main(int ac, const char **av) strncpy(addr.sun_path, av[1], sizeof(addr.sun_path)); struct sockaddr * const listen_sa = tail_memdup(&addr, sizeof(addr)); - socklen_t * const len = tail_alloc(sizeof(socklen_t)); + TAIL_ALLOC_OBJECT_CONST_PTR(socklen_t, len); *len = offsetof(struct sockaddr_un, sun_path) + strlen(av[1]) + 1; if (*len > sizeof(addr)) *len = sizeof(addr); @@ -71,7 +71,7 @@ main(int ac, const char **av) perror_msg_and_skip("listen"); printf("listen(%d<socket:[%lu]>, 1) = 0\n", listen_fd, listen_inode); - unsigned int * const optval = tail_alloc(sizeof(unsigned int)); + TAIL_ALLOC_OBJECT_CONST_PTR(unsigned int, optval); *len = sizeof(*optval); if (getsockopt(listen_fd, SOL_SOCKET, SO_PASSCRED, optval, len)) perror_msg_and_fail("getsockopt"); diff --git a/tests/net-yy-inet.c b/tests/net-yy-inet.c index f76f941dd..aa6e957ea 100644 --- a/tests/net-yy-inet.c +++ b/tests/net-yy-inet.c @@ -46,7 +46,7 @@ main(void) .sin_addr.s_addr = htonl(INADDR_LOOPBACK) }; struct sockaddr * const listen_sa = tail_memdup(&addr, sizeof(addr)); - socklen_t * const len = tail_alloc(sizeof(socklen_t)); + TAIL_ALLOC_OBJECT_CONST_PTR(socklen_t, len); *len = sizeof(addr); const int listen_fd = socket(AF_INET, SOCK_STREAM, 0); @@ -77,7 +77,7 @@ main(void) ", [%u]) = 0\n", listen_fd, listen_port, listen_port, (unsigned) *len); - unsigned int * const optval = tail_alloc(sizeof(unsigned int)); + TAIL_ALLOC_OBJECT_CONST_PTR(unsigned int, optval); *len = sizeof(*optval); if (getsockopt(listen_fd, SOL_TCP, TCP_MAXSEG, optval, len)) perror_msg_and_fail("getsockopt"); diff --git a/tests/net-yy-netlink.c b/tests/net-yy-netlink.c index 64d0efca5..2a855d747 100644 --- a/tests/net-yy-netlink.c +++ b/tests/net-yy-netlink.c @@ -53,7 +53,7 @@ main(void) .nl_pid = 1234 }; struct sockaddr *const sa = tail_memdup(&addr, sizeof(addr)); - socklen_t * const len = tail_alloc(sizeof(socklen_t)); + TAIL_ALLOC_OBJECT_CONST_PTR(socklen_t, len); *len = sizeof(addr); const int fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_SOCK_DIAG); diff --git a/tests/net-yy-unix.c b/tests/net-yy-unix.c index 63637bddb..0b0dd6ca1 100644 --- a/tests/net-yy-unix.c +++ b/tests/net-yy-unix.c @@ -49,7 +49,7 @@ main(int ac, const char **av) strncpy(addr.sun_path, av[1], sizeof(addr.sun_path)); struct sockaddr * const listen_sa = tail_memdup(&addr, sizeof(addr)); - socklen_t * const len = tail_alloc(sizeof(socklen_t)); + TAIL_ALLOC_OBJECT_CONST_PTR(socklen_t, len); *len = offsetof(struct sockaddr_un, sun_path) + strlen(av[1]) + 1; if (*len > sizeof(addr)) *len = sizeof(addr); @@ -72,7 +72,7 @@ main(int ac, const char **av) printf("listen(%d<UNIX:[%lu,\"%s\"]>, 1) = 0\n", listen_fd, listen_inode, av[1]); - unsigned int * const optval = tail_alloc(sizeof(unsigned int)); + TAIL_ALLOC_OBJECT_CONST_PTR(unsigned int, optval); *len = sizeof(*optval); if (getsockopt(listen_fd, SOL_SOCKET, SO_PASSCRED, optval, len)) perror_msg_and_fail("getsockopt"); diff --git a/tests/perf_event_open.c b/tests/perf_event_open.c index 0ffea292f..bdc040ad9 100644 --- a/tests/perf_event_open.c +++ b/tests/perf_event_open.c @@ -681,7 +681,7 @@ main(void) ATTR_REC(attr_big_size), }; - struct perf_event_attr *small_attr = tail_alloc(sizeof(*small_attr)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct perf_event_attr, small_attr); struct { struct perf_event_attr *attr; diff --git a/tests/perf_event_open_nonverbose.c b/tests/perf_event_open_nonverbose.c index 45d7c8f23..f9bbc092f 100644 --- a/tests/perf_event_open_nonverbose.c +++ b/tests/perf_event_open_nonverbose.c @@ -62,7 +62,7 @@ static const char *printaddr(void *ptr) int main(void) { - struct perf_event_attr *attr = tail_alloc(sizeof(*attr)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct perf_event_attr, attr); attr->type = PERF_TYPE_HARDWARE; attr->size = sizeof(*attr); diff --git a/tests/ppoll.c b/tests/ppoll.c index c925325b6..7570edef9 100644 --- a/tests/ppoll.c +++ b/tests/ppoll.c @@ -65,7 +65,7 @@ main(void) static const char *const USR2_CHLD_str = (SIGUSR2 < SIGCHLD) ? "USR2 CHLD" : "CHLD USR2"; void *const efault = tail_alloc(1024) + 1024; - struct timespec *const ts = tail_alloc(sizeof(*ts)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct timespec, ts); const unsigned int sigset_size = get_sigset_size(); void *const sigmask = tail_alloc(sigset_size); struct pollfd *fds; diff --git a/tests/prctl-arg2-intptr.c b/tests/prctl-arg2-intptr.c index ee000ebe2..f49e2f6f3 100644 --- a/tests/prctl-arg2-intptr.c +++ b/tests/prctl-arg2-intptr.c @@ -70,7 +70,7 @@ main(void) { 11, "PR_GET_FPEXC" }, }; - unsigned int *ptr = tail_alloc(sizeof(*ptr)); + TAIL_ALLOC_OBJECT_CONST_PTR(unsigned int, ptr); long rc; unsigned int i; diff --git a/tests/prctl-no-args.c b/tests/prctl-no-args.c index 57e1b733e..2e60c8c48 100644 --- a/tests/prctl-no-args.c +++ b/tests/prctl-no-args.c @@ -57,7 +57,7 @@ main(void) { 32, "PR_TASK_PERF_EVENTS_ENABLE" }, }; - unsigned int *ptr = tail_alloc(sizeof(*ptr)); + TAIL_ALLOC_OBJECT_CONST_PTR(unsigned int, ptr); unsigned int i; for (i = 0; i < ARRAY_SIZE(options); i++) { diff --git a/tests/prctl-pdeathsig.c b/tests/prctl-pdeathsig.c index c17603072..c7e5e4898 100644 --- a/tests/prctl-pdeathsig.c +++ b/tests/prctl-pdeathsig.c @@ -44,7 +44,7 @@ main(void) static const kernel_ulong_t bogus_signal = (kernel_ulong_t) 0xbadc0deddeadfeedULL; - int *pdeathsig = tail_alloc(sizeof(*pdeathsig)); + TAIL_ALLOC_OBJECT_CONST_PTR(int, pdeathsig); long rc; rc = syscall(__NR_prctl, PR_SET_PDEATHSIG, bogus_signal); diff --git a/tests/prctl-tid_address.c b/tests/prctl-tid_address.c index 24e45031b..59a2ee68b 100644 --- a/tests/prctl-tid_address.c +++ b/tests/prctl-tid_address.c @@ -59,7 +59,7 @@ main(void) (kernel_ulong_t) 0xfffffffffffffffdULL; /* Note that kernel puts kernel-sized pointer even on x32 */ - kernel_ulong_t *ptr = tail_alloc(sizeof(*ptr)); + TAIL_ALLOC_OBJECT_CONST_PTR(kernel_ulong_t, ptr); long rc; long set_ok; diff --git a/tests/prctl-tsc.c b/tests/prctl-tsc.c index fd9362d76..0f8e4ec07 100644 --- a/tests/prctl-tsc.c +++ b/tests/prctl-tsc.c @@ -43,7 +43,7 @@ main(void) static const kernel_ulong_t bogus_tsc = (kernel_ulong_t) 0xdeadc0defacebeefULL; - int *tsc = tail_alloc(sizeof(*tsc)); + TAIL_ALLOC_OBJECT_CONST_PTR(int, tsc); long rc; rc = syscall(__NR_prctl, PR_SET_TSC, 0); diff --git a/tests/preadv.c b/tests/preadv.c index fb5d3ad78..81bb46f09 100644 --- a/tests/preadv.c +++ b/tests/preadv.c @@ -66,7 +66,7 @@ main(void) { const off_t offset = 0xdefaceddeadbeefLL; char *buf = tail_alloc(LEN); - struct iovec *iov = tail_alloc(sizeof(*iov)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct iovec, iov); iov->iov_base = buf; iov->iov_len = LEN; diff --git a/tests/ptrace.c b/tests/ptrace.c index 67e746e6a..bb29d5a9d 100644 --- a/tests/ptrace.c +++ b/tests/ptrace.c @@ -179,7 +179,7 @@ main(void) const unsigned int sigset_size = get_sigset_size(); void *const k_set = tail_alloc(sigset_size); - siginfo_t *const sip = tail_alloc(sizeof(*sip)); + TAIL_ALLOC_OBJECT_CONST_PTR(siginfo_t, sip); do_ptrace(bad_request, pid, 0, 0); printf("ptrace(%#lx /* PTRACE_??? */, %u, NULL, NULL) = %s\n", diff --git a/tests/quotactl-xfs.c b/tests/quotactl-xfs.c index e420d1c9d..7244b3364 100644 --- a/tests/quotactl-xfs.c +++ b/tests/quotactl-xfs.c @@ -207,10 +207,10 @@ main(void) char unterminated_str[sizeof(void *) * 2 + sizeof("0x")]; long rc; - struct fs_disk_quota *xdq = tail_alloc(sizeof(*xdq)); - struct fs_quota_stat *xqstat = tail_alloc(sizeof(*xqstat)); - struct fs_quota_statv *xqstatv = tail_alloc(sizeof(*xqstatv)); - uint32_t *flags = tail_alloc(sizeof(*flags)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct fs_disk_quota, xdq); + TAIL_ALLOC_OBJECT_CONST_PTR(struct fs_quota_stat, xqstat); + TAIL_ALLOC_OBJECT_CONST_PTR(struct fs_quota_statv, xqstatv); + TAIL_ALLOC_OBJECT_CONST_PTR(uint32_t, flags); char *unterminated = tail_memdup(unterminated_data, sizeof(unterminated_data)); diff --git a/tests/quotactl.c b/tests/quotactl.c index 3a7c11323..990083f60 100644 --- a/tests/quotactl.c +++ b/tests/quotactl.c @@ -173,10 +173,10 @@ main(void) long rc; char *unterminated = tail_memdup(unterminated_data, sizeof(unterminated_data)); - struct if_dqblk *dqblk = tail_alloc(sizeof(*dqblk)); - struct if_dqinfo *dqinfo = tail_alloc(sizeof(*dqinfo)); - uint32_t *fmt = tail_alloc(sizeof(*fmt)); - struct if_nextdqblk *nextdqblk = tail_alloc(sizeof(*nextdqblk)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct if_dqblk, dqblk); + TAIL_ALLOC_OBJECT_CONST_PTR(struct if_dqinfo, dqinfo); + TAIL_ALLOC_OBJECT_CONST_PTR(uint32_t, fmt); + TAIL_ALLOC_OBJECT_CONST_PTR(struct if_nextdqblk, nextdqblk); snprintf(bogus_special_str, sizeof(bogus_special_str), "%p", diff --git a/tests/rt_sigpending.c b/tests/rt_sigpending.c index accf69134..71cb80f14 100644 --- a/tests/rt_sigpending.c +++ b/tests/rt_sigpending.c @@ -78,7 +78,7 @@ main(void) const unsigned int big_size = 1024 / 8; void *k_set = tail_alloc(big_size); - sigset_t *const libc_set = tail_alloc(sizeof(sigset_t)); + TAIL_ALLOC_OBJECT_CONST_PTR(sigset_t, libc_set); sigemptyset(libc_set); if (sigprocmask(SIG_SETMASK, libc_set, NULL)) diff --git a/tests/rt_sigprocmask.c b/tests/rt_sigprocmask.c index 27e357fab..dd927f8a1 100644 --- a/tests/rt_sigprocmask.c +++ b/tests/rt_sigprocmask.c @@ -91,7 +91,7 @@ main(void) void *const k_set = tail_alloc(set_size); void *const old_set = tail_alloc(set_size); - sigset_t *const libc_set = tail_alloc(sizeof(sigset_t)); + TAIL_ALLOC_OBJECT_CONST_PTR(sigset_t, libc_set); memset(k_set, 0, set_size); if (k_sigprocmask(SIG_SETMASK, k_set, NULL, set_size)) diff --git a/tests/rt_sigsuspend.c b/tests/rt_sigsuspend.c index 73e133646..3107937e2 100644 --- a/tests/rt_sigsuspend.c +++ b/tests/rt_sigsuspend.c @@ -88,7 +88,7 @@ main(void) void *k_set = tail_alloc(big_size); memset(k_set, 0, big_size); - sigset_t *const libc_set = tail_alloc(sizeof(sigset_t)); + TAIL_ALLOC_OBJECT_CONST_PTR(sigset_t, libc_set); sigemptyset(libc_set); sigaddset(libc_set, SIGUSR1); if (sigprocmask(SIG_SETMASK, libc_set, NULL)) diff --git a/tests/rt_sigtimedwait.c b/tests/rt_sigtimedwait.c index 10311e6ef..a64a128c5 100644 --- a/tests/rt_sigtimedwait.c +++ b/tests/rt_sigtimedwait.c @@ -86,8 +86,8 @@ main(void) { tprintf("%s", ""); - siginfo_t *const info = tail_alloc(sizeof(*info)); - struct timespec *const timeout = tail_alloc(sizeof(*timeout)); + TAIL_ALLOC_OBJECT_CONST_PTR(siginfo_t, info); + TAIL_ALLOC_OBJECT_CONST_PTR(struct timespec, timeout); timeout->tv_sec = 0; timeout->tv_nsec = 42; @@ -111,7 +111,7 @@ main(void) (intmax_t) timeout->tv_sec, (intmax_t) timeout->tv_nsec, set_size); - sigset_t *const libc_set = tail_alloc(sizeof(sigset_t)); + TAIL_ALLOC_OBJECT_CONST_PTR(sigset_t, libc_set); sigemptyset(libc_set); sigaddset(libc_set, SIGHUP); memcpy(k_set, libc_set, set_size); diff --git a/tests/rt_tgsigqueueinfo.c b/tests/rt_tgsigqueueinfo.c index 09ff3212a..ad6d465e0 100644 --- a/tests/rt_tgsigqueueinfo.c +++ b/tests/rt_tgsigqueueinfo.c @@ -57,7 +57,7 @@ main (void) if (sigaction(SIGUSR1, &sa, NULL)) perror_msg_and_fail("sigaction"); - siginfo_t *const info = tail_alloc(sizeof(*info)); + TAIL_ALLOC_OBJECT_CONST_PTR(siginfo_t, info); memset(info, 0, sizeof(*info)); info->si_signo = SIGUSR1; info->si_errno = ENOENT; diff --git a/tests/sched_rr_get_interval.c b/tests/sched_rr_get_interval.c index 0aacd2b77..bda9dd874 100644 --- a/tests/sched_rr_get_interval.c +++ b/tests/sched_rr_get_interval.c @@ -11,7 +11,7 @@ int main(void) { - struct timespec *const tp = tail_alloc(sizeof(struct timespec)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct timespec, tp); long rc; rc = syscall(__NR_sched_rr_get_interval, 0, NULL); diff --git a/tests/sched_xetattr.c b/tests/sched_xetattr.c index 23eb19cfd..4b381d25c 100644 --- a/tests/sched_xetattr.c +++ b/tests/sched_xetattr.c @@ -67,8 +67,8 @@ main(void) static const kernel_ulong_t bogus_flags = (kernel_ulong_t) 0xdefaceddeadc0deULL; - struct sched_attr *const attr = tail_alloc(sizeof(*attr)); - unsigned int *const psize = tail_alloc(sizeof(*psize)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct sched_attr, attr); + TAIL_ALLOC_OBJECT_CONST_PTR(unsigned int, psize); void *const efault = attr + 1; sys_sched_getattr(0, 0, 0, 0); diff --git a/tests/sched_xetscheduler.c b/tests/sched_xetscheduler.c index 7faee8cd0..8248a0c03 100644 --- a/tests/sched_xetscheduler.c +++ b/tests/sched_xetscheduler.c @@ -10,7 +10,7 @@ int main(void) { - struct sched_param *const param = tail_alloc(sizeof(struct sched_param)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct sched_param, param); long rc = syscall(__NR_sched_getscheduler, 0); const char *scheduler; switch (rc) { diff --git a/tests/scm_rights.c b/tests/scm_rights.c index 42caed7ca..42ba099f7 100644 --- a/tests/scm_rights.c +++ b/tests/scm_rights.c @@ -44,11 +44,11 @@ int main(int ac, const char **av) void *data = tail_alloc(data_size); memcpy(data, sample, data_size); - struct iovec *iov = tail_alloc(sizeof(struct iovec)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct iovec, iov); iov->iov_base = data; iov->iov_len = data_size; - struct msghdr *mh = tail_alloc(sizeof(struct msghdr)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct msghdr, mh); memset(mh, 0, sizeof(*mh)); mh->msg_iov = iov; mh->msg_iovlen = 1; diff --git a/tests/seccomp-filter-v.c b/tests/seccomp-filter-v.c index dbf686d14..5adb6717a 100644 --- a/tests/seccomp-filter-v.c +++ b/tests/seccomp-filter-v.c @@ -105,7 +105,7 @@ main(void) tail_memdup(filter_c, sizeof(filter_c)); struct sock_filter *const big_filter = tail_alloc(sizeof(*big_filter) * (BPF_MAXINSNS + 1)); - struct sock_fprog *const prog = tail_alloc(sizeof(*prog)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct sock_fprog, prog); int fds[2]; if (pipe(fds)) diff --git a/tests/seccomp-filter.c b/tests/seccomp-filter.c index d4d76dd35..db14ef527 100644 --- a/tests/seccomp-filter.c +++ b/tests/seccomp-filter.c @@ -49,7 +49,7 @@ main(void) { struct sock_filter *const filter = tail_alloc(sizeof(*filter) * N); const void *const efault = tail_alloc(1); - struct sock_fprog *const prog = tail_alloc(sizeof(*prog)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct sock_fprog, prog); long rc; prog->filter = filter; diff --git a/tests/semop.c b/tests/semop.c index a2ff2635a..c5b470c4b 100644 --- a/tests/semop.c +++ b/tests/semop.c @@ -47,8 +47,8 @@ main(void) if (semctl(id, 0, SETVAL, sem_union) == -1) perror_msg_and_skip("semctl"); - struct sembuf *const sem_b = tail_alloc(sizeof(*sem_b)); - struct sembuf *const sem_b2 = tail_alloc(sizeof(*sem_b2)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct sembuf, sem_b); + TAIL_ALLOC_OBJECT_CONST_PTR(struct sembuf, sem_b2); rc = semop(bogus_semid, NULL, bogus_nsops); printf("semop(%d, NULL, %u) = %s\n", diff --git a/tests/sendfile64.c b/tests/sendfile64.c index 7208c3006..a6c53f4d1 100644 --- a/tests/sendfile64.c +++ b/tests/sendfile64.c @@ -69,7 +69,7 @@ main(int ac, const char **av) printf("sendfile64(0, 1, NULL, %lu) = -1 EBADF (%m)\n", (unsigned long) page_len); - uint64_t *p_off = tail_alloc(sizeof(uint64_t)); + TAIL_ALLOC_OBJECT_CONST_PTR(uint64_t, p_off); void *p = p_off + 1; *p_off = 0; diff --git a/tests/setgroups.c b/tests/setgroups.c index eef41b6f7..b6000dec7 100644 --- a/tests/setgroups.c +++ b/tests/setgroups.c @@ -91,7 +91,7 @@ main(void) printf("%s(%d, NULL) = %s\n", SYSCALL_NAME, -1, sprintrc(rc)); /* check how the second argument is decoded */ - const GID_TYPE *const g1 = tail_alloc(sizeof(*g1)); + TAIL_ALLOC_OBJECT_CONST_PTR(const GID_TYPE, g1); GID_TYPE *const g2 = tail_alloc(sizeof(*g2) * 2); GID_TYPE *const g3 = tail_alloc(sizeof(*g3) * 3); diff --git a/tests/sockname.c b/tests/sockname.c index c5072cac4..21eef3e77 100644 --- a/tests/sockname.c +++ b/tests/sockname.c @@ -74,7 +74,7 @@ static void test_sockname_syscall(const int fd) { - socklen_t *const plen = tail_alloc(sizeof(*plen)); + TAIL_ALLOC_OBJECT_CONST_PTR(socklen_t, plen); *plen = sizeof(struct sockaddr_un); struct sockaddr_un *addr = tail_alloc(*plen); diff --git a/tests/splice.c b/tests/splice.c index b6f252560..c00dbfacd 100644 --- a/tests/splice.c +++ b/tests/splice.c @@ -40,8 +40,8 @@ main(void) { const long int fd_in = (long int) 0xdeadbeefffffffffULL; const long int fd_out = (long int) 0xdeadbeeffffffffeULL; - long long int *const off_in = tail_alloc(sizeof(*off_in)); - long long int *const off_out = tail_alloc(sizeof(*off_out)); + TAIL_ALLOC_OBJECT_CONST_PTR(long long int, off_in); + TAIL_ALLOC_OBJECT_CONST_PTR(long long int, off_out); *off_in = 0xdeadbef1facefed1ULL; *off_out = 0xdeadbef2facefed2ULL; const size_t len = (size_t) 0xdeadbef3facefed3ULL; diff --git a/tests/sysinfo.c b/tests/sysinfo.c index 377bdc9c1..8b05da161 100644 --- a/tests/sysinfo.c +++ b/tests/sysinfo.c @@ -38,7 +38,7 @@ main(void) sysinfo(NULL); printf("sysinfo(NULL) = -1 EFAULT (%m)\n"); - struct sysinfo * const si = tail_alloc(sizeof(*si)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct sysinfo, si); if (sysinfo(si)) perror_msg_and_skip("sysinfo"); diff --git a/tests/time.c b/tests/time.c index 4a5cde9c1..f9c4830a7 100644 --- a/tests/time.c +++ b/tests/time.c @@ -40,7 +40,7 @@ int main(void) { - time_t *p = tail_alloc(sizeof(time_t)); + TAIL_ALLOC_OBJECT_CONST_PTR(time_t, p); time_t t = syscall(__NR_time, NULL); if ((time_t) -1 == t) diff --git a/tests/uname.c b/tests/uname.c index cd6f51cde..96db75356 100644 --- a/tests/uname.c +++ b/tests/uname.c @@ -10,7 +10,7 @@ int main(int ac, char **av) { int abbrev = ac > 1; - struct utsname *const uname = tail_alloc(sizeof(struct utsname)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct utsname, uname); int rc = syscall(__NR_uname, uname); printf("uname({sysname=\""); print_quoted_string(uname->sysname); diff --git a/tests/ustat.c b/tests/ustat.c index 57bb29c27..3341c70ed 100644 --- a/tests/ustat.c +++ b/tests/ustat.c @@ -47,7 +47,7 @@ main(void) long rc; # ifdef HAVE_USTAT_H - struct ustat *const ust = tail_alloc(sizeof(*ust)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct ustat, ust); struct stat st; if (stat(".", &st)) perror_msg_and_fail("stat"); diff --git a/tests/wait4.c b/tests/wait4.c index ccb3ebb9a..5f8894008 100644 --- a/tests/wait4.c +++ b/tests/wait4.c @@ -119,12 +119,12 @@ main(void) (void) close(0); - int *const s = tail_alloc(sizeof(*s)); + TAIL_ALLOC_OBJECT_CONST_PTR(int, s); if (wait4(pid, s, WNOHANG|__WALL, NULL)) perror_msg_and_fail("wait4 #1"); tprintf("wait4(%d, %p, WNOHANG|__WALL, NULL) = 0\n", pid, s); - struct rusage *const rusage = tail_alloc(sizeof(*rusage)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct rusage, rusage); if (wait4(pid, s, WNOHANG|__WALL, rusage)) perror_msg_and_fail("wait4 #2"); tprintf("wait4(%d, %p, WNOHANG|__WALL, %p) = 0\n", pid, s, rusage); diff --git a/tests/waitid.c b/tests/waitid.c index 6a102990a..66825b298 100644 --- a/tests/waitid.c +++ b/tests/waitid.c @@ -185,9 +185,9 @@ main(void) perror_msg_and_fail("waitid #1"); tprintf("waitid(P_PID, %d, NULL, WNOHANG|WEXITED, NULL) = 0\n", pid); - siginfo_t *const sinfo = tail_alloc(sizeof(*sinfo)); + TAIL_ALLOC_OBJECT_CONST_PTR(siginfo_t, sinfo); memset(sinfo, 0, sizeof(*sinfo)); - struct rusage *const rusage = tail_alloc(sizeof(*rusage)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct rusage, rusage); if (do_waitid(P_PID, pid, sinfo, WNOHANG|WEXITED|WSTOPPED, rusage)) perror_msg_and_fail("waitid #2"); tprintf("waitid(P_PID, %d, {}, WNOHANG|WEXITED|WSTOPPED, %s) = 0\n", diff --git a/tests/xet_robust_list.c b/tests/xet_robust_list.c index 211dec459..c39feaf94 100644 --- a/tests/xet_robust_list.c +++ b/tests/xet_robust_list.c @@ -51,8 +51,8 @@ main(void) { const pid_t pid = getpid(); const long long_pid = (unsigned long) (0xdeadbeef00000000LL | pid); - void **p_head = tail_alloc(sizeof(void *)); - size_t *p_len = tail_alloc(sizeof(size_t)); + TAIL_ALLOC_OBJECT_CONST_PTR(void *, p_head); + TAIL_ALLOC_OBJECT_CONST_PTR(size_t, p_len); if (syscall(__NR_get_robust_list, long_pid, p_head, p_len)) perror_msg_and_skip("get_robust_list"); diff --git a/tests/xetitimer.c b/tests/xetitimer.c index 096978d9d..1e1785605 100644 --- a/tests/xetitimer.c +++ b/tests/xetitimer.c @@ -46,7 +46,7 @@ main(void) static const kernel_ulong_t bogus_timer = (kernel_ulong_t) 0xfacefeeddeadbeefULL; - struct itimerval *const p_old = tail_alloc(sizeof(*p_old)); + TAIL_ALLOC_OBJECT_CONST_PTR(struct itimerval, p_old); struct itimerval *const p_new = tail_memdup(&new, sizeof(new)); void *const efault = tail_alloc(sizeof(new) - 8); long rc; diff --git a/tests/xstatfsx.c b/tests/xstatfsx.c index d8288f1ff..94af08461 100644 --- a/tests/xstatfsx.c +++ b/tests/xstatfsx.c @@ -64,7 +64,7 @@ print_statfs(const char *const sample, const char *magic_str) if (fd < 0) perror_msg_and_fail("open: %s", sample); - STRUCT_STATFS *const b = tail_alloc(sizeof(*b)); + TAIL_ALLOC_OBJECT_CONST_PTR(STRUCT_STATFS, b); long rc = SYSCALL_INVOKE(sample, fd, b, sizeof(*b)); if (rc) perror_msg_and_skip(SYSCALL_NAME); |