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 | c36875b1709a3ed3f21ef71a84ef5a7a936c8a8e (patch) | |
tree | c1ce3d0fb16c81822f082c508ece1e44df5d6999 | |
parent | 72b7cfb3bf534c69cfa980fd6f4336e5a14d752b (diff) | |
download | strace-c36875b1709a3ed3f21ef71a84ef5a7a936c8a8e.tar.gz |
tests: use TAIL_ALLOC_OBJECT_VAR_PTR
Automatically convert tests to use TAIL_ALLOC_OBJECT_VAR_PTR macro
with the following sed expression:
sed -ri \
's/^([[:space:]]*)(([^*]+[[:alnum:]_])( \*)?) *\*([^ =]+) = tail_alloc\(sizeof\((\2|\*\5)\)\);/\1TAIL_ALLOC_OBJECT_VAR_PTR(\2, \5);/' \
tests/{move_pages,net-sockaddr,sendfile}.c
-rw-r--r-- | tests/move_pages.c | 6 | ||||
-rw-r--r-- | tests/net-sockaddr.c | 10 | ||||
-rw-r--r-- | tests/sendfile.c | 2 |
3 files changed, 9 insertions, 9 deletions
diff --git a/tests/move_pages.c b/tests/move_pages.c index f4ccafa2c..d97150019 100644 --- a/tests/move_pages.c +++ b/tests/move_pages.c @@ -190,9 +190,9 @@ main(void) 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)); + TAIL_ALLOC_OBJECT_VAR_PTR(const void *, pages); + TAIL_ALLOC_OBJECT_VAR_PTR(int, nodes); + TAIL_ALLOC_OBJECT_VAR_PTR(int, status); print_stat_pages(pid, 0, pages, status); print_move_pages(pid, 0, 0, pages, nodes, status); diff --git a/tests/net-sockaddr.c b/tests/net-sockaddr.c index bf37779f7..11243f167 100644 --- a/tests/net-sockaddr.c +++ b/tests/net-sockaddr.c @@ -57,7 +57,7 @@ extern unsigned int if_nametoindex(const char *); static void check_un(void) { - struct sockaddr_un *un = tail_alloc(sizeof(*un)); + TAIL_ALLOC_OBJECT_VAR_PTR(struct sockaddr_un, un); un->sun_family = AF_UNIX; memset(un->sun_path, '0', sizeof(un->sun_path)); unsigned int len = sizeof(*un); @@ -133,7 +133,7 @@ check_in(void) const unsigned short h_port = 12345; static const char h_addr[] = "12.34.56.78"; - struct sockaddr_in *in = tail_alloc(sizeof(*in)); + TAIL_ALLOC_OBJECT_VAR_PTR(struct sockaddr_in, in); in->sin_family = AF_INET; in->sin_port = htons(h_port); in->sin_addr.s_addr = inet_addr(h_addr); @@ -207,7 +207,7 @@ check_in6(void) const unsigned int h_flowinfo = 1234567890; static const char h_addr[] = "12:34:56:78:90:ab:cd:ef"; - struct sockaddr_in6 *in6 = tail_alloc(sizeof(*in6)); + TAIL_ALLOC_OBJECT_VAR_PTR(struct sockaddr_in6, in6); in6->sin6_family = AF_INET6; in6->sin6_port = htons(h_port); in6->sin6_flowinfo = htonl(h_flowinfo); @@ -298,7 +298,7 @@ check_ipx(void) static void check_nl(void) { - struct sockaddr_nl *nl = tail_alloc(sizeof(*nl)); + TAIL_ALLOC_OBJECT_VAR_PTR(struct sockaddr_nl, nl); nl->nl_family = AF_NETLINK; nl->nl_pid = 1234567890; nl->nl_groups = 0xfacefeed; @@ -390,7 +390,7 @@ static void check_hci(void) { const unsigned short h_port = 12345; - struct sockaddr_hci *hci = tail_alloc(sizeof(*hci)); + TAIL_ALLOC_OBJECT_VAR_PTR(struct sockaddr_hci, hci); hci->hci_family = AF_BLUETOOTH; hci->hci_dev = htobs(h_port); hci->hci_channel = HCI_CHANNEL_RAW; diff --git a/tests/sendfile.c b/tests/sendfile.c index 23f096b62..86ca05c0b 100644 --- a/tests/sendfile.c +++ b/tests/sendfile.c @@ -69,7 +69,7 @@ main(int ac, const char **av) printf("sendfile(0, 1, NULL, %lu) = -1 EBADF (%m)\n", (unsigned long) page_len); - uint32_t *p_off = tail_alloc(sizeof(uint32_t)); + TAIL_ALLOC_OBJECT_VAR_PTR(uint32_t, p_off); void *p = p_off + 1; *p_off = 0; |