* This file is part of ioctl_evdev strace test.
*
* Copyright (c) 2016 Dmitry V. Levin <ldv@altlinux.org>
+ * Copyright (c) 2016-2017 The strace developers.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
static const unsigned int magic = 0xdeadbeef;
static const unsigned long lmagic = (unsigned long) 0xdeadbeefbadc0dedULL;
-static void
-init_magic(void *addr, const unsigned int size)
-{
- unsigned int *p = addr;
- const unsigned int *end = addr + size - sizeof(int);
-
- for (; p <= end; ++p)
- *(unsigned int *) p = magic;
-}
-
# if VERBOSE
static void
print_envelope(const struct ff_envelope *const e)
# endif /* VERBOSE */
}
-# define TEST_NULL_ARG(cmd) \
- ioctl(-1, cmd, 0); \
- printf("ioctl(-1, %s, NULL) = -1 EBADF (%m)\n", #cmd)
+# define TEST_NULL_ARG(cmd) \
+ do { \
+ ioctl(-1, cmd, 0); \
+ printf("ioctl(-1, %s, NULL) = -1 EBADF (%m)\n", #cmd); \
+ } while (0)
int
main(void)
const unsigned int size = get_page_size();
void *const page = tail_alloc(size);
- init_magic(page, 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
pair_int[0], "KEY_ESC");
# ifdef EVIOCSKEYCODE_V2
- struct input_keymap_entry *const ike = tail_alloc(sizeof(*ike));
- init_magic(ike, sizeof(*ike));
+ TAIL_ALLOC_OBJECT_CONST_PTR(struct input_keymap_entry, ike);
+ fill_memory(ike, sizeof(*ike));
ike->keycode = 2;
ioctl(-1, EVIOCSKEYCODE_V2, ike);
printf("}) = -1 EBADF (%m)\n");
# endif
- struct ff_effect *const ffe = tail_alloc(sizeof(*ffe));
- init_magic(ffe, sizeof(*ffe));
+ TAIL_ALLOC_OBJECT_CONST_PTR(struct ff_effect, ffe);
+ fill_memory(ffe, sizeof(*ffe));
ffe->type = FF_CONSTANT;
ioctl(-1, EVIOCSFF, ffe);