/*
- * This file is part of ioctl_block strace test.
+ * 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
# include <linux/input.h>
static const unsigned int magic = 0xdeadbeef;
-static const unsigned long lmagic = (unsigned long) 0xdeadbeefbadc0ded;
+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;
-}
-
-# ifdef VERBOSE_IOCTL
+# if VERBOSE
static void
print_envelope(const struct ff_envelope *const e)
{
e->attack_length, e->attack_level,
e->fade_length, e->fade_level);
}
-# endif /* VERBOSE_IOCTL */
+# endif /* VERBOSE */
static void
print_ffe_common(const struct ff_effect *const ffe, const char *const type_str)
printf("ioctl(-1, EVIOCSFF, {type=%s, id=%" PRIu16
", direction=%" PRIu16 ", ",
type_str, ffe->id, ffe->direction);
-# ifdef VERBOSE_IOCTL
+# if VERBOSE
printf("trigger={button=%hu, interval=%hu}"
", replay={length=%hu, delay=%hu}",
ffe->trigger.button, ffe->trigger.interval,
ffe->replay.length, ffe->replay.delay);
-# endif /* VERBOSE_IOCTL */
+# 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)
TEST_NULL_ARG(EVIOCGNAME(0));
TEST_NULL_ARG(EVIOCGPHYS(0));
+ TEST_NULL_ARG(EVIOCGUNIQ(0));
TEST_NULL_ARG(EVIOCGKEY(0));
TEST_NULL_ARG(EVIOCGLED(0));
# ifdef EVIOCGMTSLOTS
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("ioctl(-1, EVIOCSKEYCODE_V2, {flags=%" PRIu8
", len=%" PRIu8 ", ", ike->flags, ike->len);
-# ifdef VERBOSE_IOCTL
+# if VERBOSE
printf("index=%" PRIu16 ", keycode=%s, scancode=[",
ike->index, "KEY_1");
unsigned int i;
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);
print_ffe_common(ffe, "FF_CONSTANT");
-# ifdef VERBOSE_IOCTL
+# if VERBOSE
printf(", constant={level=%hd", ffe->u.constant.level);
print_envelope(&ffe->u.constant.envelope);
printf("}");
errno = EBADF;
printf("}) = -1 EBADF (%m)\n");
-# ifdef VERBOSE_IOCTL
+# if VERBOSE
ffe->type = FF_RAMP;
ioctl(-1, EVIOCSFF, ffe);
print_ffe_common(ffe, "FF_RAMP");
printf("}) = -1 EBADF (%m)\n");
# endif
- ioctl(-1, _IOC(_IOC_READ, 0x45, 0x01, 0xff), lmagic);
+ ioctl(-1, _IOC(_IOC_READ, 0x45, 0x1, 0xff), lmagic);
printf("ioctl(-1, %s, %#lx) = -1 EBADF (%m)\n",
- "_IOC(_IOC_READ, 0x45, 0x01, 0xff)", lmagic);
+ "_IOC(_IOC_READ, 0x45, 0x1, 0xff)", lmagic);
- ioctl(-1, _IOC(_IOC_WRITE, 0x45, 0x01, 0xff), lmagic);
+ ioctl(-1, _IOC(_IOC_WRITE, 0x45, 0x1, 0xff), lmagic);
printf("ioctl(-1, %s, %#lx) = -1 EBADF (%m)\n",
- "_IOC(_IOC_WRITE, 0x45, 0x01, 0xff)", lmagic);
+ "_IOC(_IOC_WRITE, 0x45, 0x1, 0xff)", lmagic);
ioctl(-1, _IOC(_IOC_READ|_IOC_WRITE, 0x45, 0xfe, 0xff), lmagic);
printf("ioctl(-1, %s, %#lx) = -1 EBADF (%m)\n",
"_IOC(_IOC_READ|_IOC_WRITE, 0x45, 0xfe, 0xff)", lmagic);
+ ioctl(-1, _IOC(_IOC_READ|_IOC_WRITE, 0x45, 0, 0), lmagic);
+ printf("ioctl(-1, %s, %#lx) = -1 EBADF (%m)\n",
+ "_IOC(_IOC_READ|_IOC_WRITE, 0x45, 0, 0)", lmagic);
+
puts("+++ exited with 0 +++");
return 0;
}