tests: use TAIL_ALLOC_OBJECT_CONST_PTR where appropriate

* tests/kcmp.c (main): Use TAIL_ALLOC_OBJECT_CONST_PTR.
* tests/modify_ldt.c (main): Likewise.
* tests/netlink_protocol.c (send_query): Likewise.
* tests/ptrace.c (test_peeksiginfo, main): Likewise.
* tests/s390_guarded_storage.c (main): Likewise.
* tests/s390_sthyi.c (main): Likewise.
* tests/xet_thread_area_x86.c (main): Likewise.
This commit is contained in:
Дмитрий Левин 2018-05-28 17:34:50 +00:00
parent ccde0129ea
commit b6cb4866e2
7 changed files with 15 additions and 13 deletions

View File

@ -167,7 +167,7 @@ main(void)
int fd;
unsigned i;
struct kcmp_epoll_slot *slot = tail_alloc(sizeof(*slot));
TAIL_ALLOC_OBJECT_CONST_PTR(struct kcmp_epoll_slot, slot);
/* Open some files to test printpidfd */
fd = open(null_path, O_RDONLY);

View File

@ -67,8 +67,8 @@ main(void)
static const kernel_ulong_t bogus_bytecount =
(kernel_ulong_t) 0xdeadfacefa57beefULL;
struct user_desc *us = tail_alloc(sizeof(*us));
unsigned int *bogus_int = tail_alloc(sizeof(*bogus_int));
TAIL_ALLOC_OBJECT_CONST_PTR(struct user_desc, us);
TAIL_ALLOC_OBJECT_CONST_PTR(unsigned int, bogus_int);
long rc;
fill_memory(us, sizeof(*us));

View File

@ -125,7 +125,8 @@ send_query(const int fd)
struct req req1;
char padding[NLMSG_ALIGN(sizeof(struct req)) - sizeof(struct req)];
struct req req2;
} *const reqs = tail_alloc(sizeof(*reqs));
};
TAIL_ALLOC_OBJECT_CONST_PTR(struct reqs, reqs);
memcpy(&reqs->req1, &c_req, sizeof(c_req));
memcpy(&reqs->req2, &c_req, sizeof(c_req));

View File

@ -60,10 +60,11 @@ test_peeksiginfo(unsigned long pid, const unsigned long bad_request)
printf("ptrace(PTRACE_PEEKSIGINFO, %u, NULL, %#lx) = %s\n",
(unsigned) pid, bad_request, errstr);
struct {
struct psi {
unsigned long long off;
unsigned int flags, nr;
} *const psi = tail_alloc(sizeof(*psi));
};
TAIL_ALLOC_OBJECT_CONST_PTR(struct psi, psi);
psi->off = 0xdeadbeeffacefeedULL;
psi->flags = 1;
@ -179,7 +180,7 @@ main(void)
const unsigned long pid =
(unsigned long) 0xdefaced00000000ULL | (unsigned) getpid();
uint64_t *filter_off = tail_alloc(sizeof(*filter_off));
TAIL_ALLOC_OBJECT_CONST_PTR(uint64_t, filter_off);
const unsigned int sigset_size = get_sigset_size();

View File

@ -175,8 +175,8 @@ main(void)
static const kernel_ulong_t bogus_addr =
(kernel_ulong_t) 0xfacefeedac0ffeedULL;
struct gs_cb *gscb = tail_alloc(sizeof(*gscb));
struct gs_epl *gsepl = tail_alloc(sizeof(*gsepl));
TAIL_ALLOC_OBJECT_CONST_PTR(struct gs_cb, gscb);
TAIL_ALLOC_OBJECT_CONST_PTR(struct gs_epl, gsepl);
long rc;

View File

@ -741,7 +741,7 @@ main(void)
(kernel_ulong_t) 0xfee1deadfa57beefULL;
unsigned char *buf = tail_alloc(PAGE_SIZE);
uint64_t *ret = tail_alloc(sizeof(*ret));
TAIL_ALLOC_OBJECT_CONST_PTR(uint64_t, ret);
long rc;

View File

@ -152,9 +152,9 @@ get_thread_area(kernel_ulong_t ptr_val, const char *ptr_str, bool valid,
int main(void)
{
struct user_desc *ta1 = tail_alloc(sizeof(*ta1));
struct user_desc *ta2 = tail_alloc(sizeof(*ta2));
unsigned *bogus_entry_number = tail_alloc(sizeof(*bogus_entry_number));
TAIL_ALLOC_OBJECT_CONST_PTR(struct user_desc, ta1);
TAIL_ALLOC_OBJECT_CONST_PTR(struct user_desc, ta2);
TAIL_ALLOC_OBJECT_CONST_PTR(unsigned int, bogus_entry_number);
long set_rc = -1;