]> granicus.if.org Git - strace/commitdiff
tests: use TAIL_ALLOC_OBJECT_VAR_PTR
authorDmitry V. Levin <ldv@altlinux.org>
Thu, 16 Mar 2017 13:46:36 +0000 (13:46 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Thu, 16 Mar 2017 13:46:36 +0000 (13:46 +0000)
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

tests/move_pages.c
tests/net-sockaddr.c
tests/sendfile.c

index f4ccafa2c45aaca9d0d20865b6a5471864e05cae..d971500194f4baf753b1d0979e8e8ed076b21b4d 100644 (file)
@@ -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);
index bf37779f7fd32037e48bc27427b4dcbf864767ef..11243f1676d08c2c80d126ecaf1f579fe932b046 100644 (file)
@@ -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;
index 23f096b623bad84c2ed3f050b60f0853754cbb0b..86ca05c0b44458ff5590784fec972c555a34b9d2 100644 (file)
@@ -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;