summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@altlinux.org>2020-07-13 08:00:00 +0000
committerDmitry V. Levin <ldv@altlinux.org>2020-07-13 08:00:00 +0000
commit2d1a6b698d755f52d58ad15c9d444af6b097b005 (patch)
tree1fb042e6f3ddc443887dc0bfef18a19fb19e099b
parentf2915826421954e32595e903f7af1871503fc10b (diff)
downloadstrace-2d1a6b698d755f52d58ad15c9d444af6b097b005.tar.gz
evdev_mpers: use print_fields.h macros
* evdev_mpers.c: Include "print_fields.h". (decode_envelope, ff_effect_ioctl): Use PRINT_FIELD_* macros from print_fields.h. * tests/ioctl_evdev.c (print_ffe_common): Update expected output.
-rw-r--r--evdev_mpers.c71
-rw-r--r--tests/ioctl_evdev.c2
2 files changed, 29 insertions, 44 deletions
diff --git a/evdev_mpers.c b/evdev_mpers.c
index 74a9223b6..35de88acc 100644
--- a/evdev_mpers.c
+++ b/evdev_mpers.c
@@ -24,19 +24,18 @@ typedef struct ff_effect struct_ff_effect;
#ifdef HAVE_LINUX_INPUT_H
+# include "print_fields.h"
+
static void
decode_envelope(void *const data)
{
const struct ff_envelope *const envelope = data;
- tprintf(", envelope={attack_length=%" PRIu16
- ", attack_level=%" PRIu16
- ", fade_length=%" PRIu16
- ", fade_level=%#x}",
- envelope->attack_length,
- envelope->attack_level,
- envelope->fade_length,
- envelope->fade_level);
+ PRINT_FIELD_U(", envelope={", *envelope, attack_length);
+ PRINT_FIELD_U(", ", *envelope, attack_level);
+ PRINT_FIELD_U(", ", *envelope, fade_length);
+ PRINT_FIELD_X(", ", *envelope, fade_level);
+ tprints("}");
}
static int
@@ -51,62 +50,48 @@ ff_effect_ioctl(struct tcb *const tcp, const kernel_ulong_t arg)
tprints("{type=");
print_evdev_ff_type(ffe.type);
- tprintf(", id=%" PRIu16
- ", direction=%" PRIu16 ", ",
- ffe.id,
- ffe.direction);
+ PRINT_FIELD_D(", ", ffe, id);
+ PRINT_FIELD_U(", ", ffe, direction);
if (abbrev(tcp)) {
- tprints("...}");
+ tprints(", ...}");
return RVAL_IOCTL_DECODED;
}
- tprintf("trigger={button=%" PRIu16
- ", interval=%" PRIu16 "}"
- ", replay={length=%" PRIu16
- ", delay=%" PRIu16 "}",
- ffe.trigger.button,
- ffe.trigger.interval,
- ffe.replay.length,
- ffe.replay.delay);
+ PRINT_FIELD_U(", trigger={", ffe.trigger, button);
+ PRINT_FIELD_U(", ", ffe.trigger, interval);
+ PRINT_FIELD_U("}, replay={", ffe.replay, length);
+ PRINT_FIELD_U(", ", ffe.replay, delay);
+ tprints("}");
switch (ffe.type) {
case FF_CONSTANT:
- tprintf(", constant={level=%" PRId16,
- ffe.u.constant.level);
+ PRINT_FIELD_D(", constant={", ffe.u.constant, level);
decode_envelope(&ffe.u.constant.envelope);
tprints("}");
break;
case FF_RAMP:
- tprintf(", ramp={start_level=%" PRId16
- ", end_level=%" PRId16,
- ffe.u.ramp.start_level,
- ffe.u.ramp.end_level);
+ PRINT_FIELD_D(", ramp={", ffe.u.ramp, start_level);
+ PRINT_FIELD_D(", ", ffe.u.ramp, end_level);
decode_envelope(&ffe.u.ramp.envelope);
tprints("}");
break;
case FF_PERIODIC:
- tprintf(", periodic={waveform=%" PRIu16
- ", period=%" PRIu16
- ", magnitude=%" PRId16
- ", offset=%" PRId16
- ", phase=%" PRIu16,
- ffe.u.periodic.waveform,
- ffe.u.periodic.period,
- ffe.u.periodic.magnitude,
- ffe.u.periodic.offset,
- ffe.u.periodic.phase);
+ PRINT_FIELD_U(", periodic={", ffe.u.periodic, waveform);
+ PRINT_FIELD_U(", ", ffe.u.periodic, period);
+ PRINT_FIELD_D(", ", ffe.u.periodic, magnitude);
+ PRINT_FIELD_D(", ", ffe.u.periodic, offset);
+ PRINT_FIELD_U(", ", ffe.u.periodic, phase);
decode_envelope(&ffe.u.periodic.envelope);
- tprintf(", custom_len=%u, custom_data=",
- ffe.u.periodic.custom_len);
+ PRINT_FIELD_U(", ", ffe.u.periodic, custom_len);
+ tprints(", custom_data=");
printaddr(ptr_to_kulong(ffe.u.periodic.custom_data));
tprints("}");
break;
case FF_RUMBLE:
- tprintf(", rumble={strong_magnitude=%" PRIu16
- ", weak_magnitude=%" PRIu16 "}",
- ffe.u.rumble.strong_magnitude,
- ffe.u.rumble.weak_magnitude);
+ PRINT_FIELD_U(", rumble={", ffe.u.rumble, strong_magnitude);
+ PRINT_FIELD_U(", ", ffe.u.rumble, weak_magnitude);
+ tprints("}");
break;
default:
break;
diff --git a/tests/ioctl_evdev.c b/tests/ioctl_evdev.c
index df62fbbd3..94b12bac7 100644
--- a/tests/ioctl_evdev.c
+++ b/tests/ioctl_evdev.c
@@ -50,7 +50,7 @@ static void
print_ffe_common(const struct ff_effect *const ffe, const char *const type_str)
{
printf("ioctl(-1, %s", XLAT_STR(EVIOCSFF));
- printf(", {type=%s, id=%" PRIu16
+ printf(", {type=%s, id=%" PRId16
", direction=%" PRIu16 ", ",
sprintxlat(type_str, ffe->type, NULL),
ffe->id, ffe->direction);