From 3a45eb37112d0ccd0efb793a0c81f80a1bc5d627 Mon Sep 17 00:00:00 2001 From: "Dmitry V. Levin" Date: Fri, 27 May 2016 00:41:02 +0000 Subject: [PATCH] evdev.c: fix decoding of struct ff_effect * evdev.c (ff_effect_ioctl): Use umove_or_printaddr. Fix printing of struct ff_effect.u member names. --- evdev.c | 123 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 65 insertions(+), 58 deletions(-) diff --git a/evdev.c b/evdev.c index 532c101c..2775a718 100644 --- a/evdev.c +++ b/evdev.c @@ -66,71 +66,78 @@ decode_envelope(const struct ff_envelope *envelope) static int ff_effect_ioctl(struct tcb *tcp, long arg) { + tprints(", "); + struct ff_effect ffe; - if (!verbose(tcp) || umove(tcp, arg, &ffe) < 0) - return 0; + if (umove_or_printaddr(tcp, arg, &ffe)) + return 1; - tprints(", {type="); + tprints("{type="); printxval(evdev_ff_types, ffe.type, "FF_???"); - tprintf(", id=%" PRIu16 ", direction=%" PRIu16, - ffe.id, ffe.direction); + tprintf(", id=%" PRIu16 + ", direction=%" PRIu16 ", ", + ffe.id, + ffe.direction); - if (!abbrev(tcp)) { - tprintf(", trigger={button=%" PRIu16 ", interval=%" PRIu16 "}", - ffe.trigger.button, ffe.trigger.interval); - tprintf(", replay={lenght=%" PRIu16 ", delay=%" PRIu16 "}", - ffe.replay.length, ffe.replay.delay); - switch (ffe.type) { - case FF_CONSTANT: - tprintf(", constant_ef={%" PRIi16, - ffe.u.constant.level); - decode_envelope(&ffe.u.constant.envelope); - tprints("}"); - return 1; - case FF_RAMP: - tprintf(", ramp={start_level=%" PRIi16 - ", end_level=%" PRIi16, - ffe.u.ramp.start_level, - ffe.u.ramp.end_level); - decode_envelope(&ffe.u.ramp.envelope); - tprints("}"); - return 1; - case FF_PERIODIC: - tprintf(", periodic_ef={waveform=%" PRIu16 - ", period=%" PRIu16 - ", magnitude=%" PRIi16 - ", offset=%" PRIi16 - ", phase=%" PRIu16, - ffe.u.periodic.waveform, - ffe.u.periodic.period, - ffe.u.periodic.magnitude, - ffe.u.periodic.offset, - ffe.u.periodic.phase); - decode_envelope(&ffe.u.periodic.envelope); - tprintf(", custom_len=%" PRIu32 - ", *custom_data=%#lx}", - ffe.u.periodic.custom_len, - (unsigned long)ffe.u.periodic.custom_data); - return 1; - case FF_RUMBLE: - tprintf(", rumble={strong_magnitude=%" PRIu16 - ", weak_magnitude=%" PRIu16 "}", - ffe.u.rumble.strong_magnitude, - ffe.u.rumble.weak_magnitude); - return 1; - case FF_SPRING: - case FF_FRICTION: - case FF_DAMPER: - case FF_INERTIA: - case FF_CUSTOM: - break; - default : - break; - } + if (abbrev(tcp)) { + tprints("...}"); + return 1; + } + + tprintf("trigger={button=%" PRIu16 + ", interval=%" PRIu16 "}" + ", replay={length=%" PRIu16 + ", delay=%" PRIu16 "}", + ffe.trigger.button, + ffe.trigger.interval, + ffe.replay.length, + ffe.replay.delay); + + switch (ffe.type) { + case FF_CONSTANT: + tprintf(", constant={level=%" PRId16, + 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); + 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); + decode_envelope(&ffe.u.periodic.envelope); + tprintf(", custom_len=%u" + ", custom_data=%#lx}", + ffe.u.periodic.custom_len, + (unsigned long) ffe.u.periodic.custom_data); + break; + case FF_RUMBLE: + tprintf(", rumble={strong_magnitude=%" PRIu16 + ", weak_magnitude=%" PRIu16 "}", + ffe.u.rumble.strong_magnitude, + ffe.u.rumble.weak_magnitude); + break; + default: + break; } - tprints(", ...}"); + tprints("}"); + return 1; } -- 2.50.1