]> granicus.if.org Git - strace/blobdiff - evdev.c
tests: check decoding of netlink smc_diag_msg attributes
[strace] / evdev.c
diff --git a/evdev.c b/evdev.c
index 9a6c631b7a8ab07afee015125aa0ecfd1c54df8e..983bf1488681dc8f3ab01c412c66e87688d4370f 100644 (file)
--- a/evdev.c
+++ b/evdev.c
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2015 Etienne Gemsa <etienne.gemsa@lse.epita.fr>
- * Copyright (c) 2015 Dmitry V. Levin <ldv@altlinux.org>
+ * Copyright (c) 2015-2016 Dmitry V. Levin <ldv@altlinux.org>
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
 
 #ifdef HAVE_LINUX_INPUT_H
 
+#include DEF_MPERS_TYPE(struct_ff_effect)
+
 # include <linux/ioctl.h>
 # include <linux/input.h>
-# include "xlat/evdev_abs.h"
+
+typedef struct ff_effect struct_ff_effect;
+
+#endif /* HAVE_LINUX_INPUT_H */
+
+#include MPERS_DEFS
+
+#ifdef HAVE_LINUX_INPUT_H
+
 # include "xlat/evdev_autorepeat.h"
 # include "xlat/evdev_ff_status.h"
 # include "xlat/evdev_ff_types.h"
 # endif
 
 static void
-decode_envelope(const struct ff_envelope *envelope)
+decode_envelope(void *const data)
 {
+       const struct ff_envelope *const envelope = data;
+
        tprintf(", envelope={attack_length=%" PRIu16
                ", attack_level=%" PRIu16
                ", fade_length=%" PRIu16
@@ -64,11 +76,11 @@ decode_envelope(const struct ff_envelope *envelope)
 }
 
 static int
-ff_effect_ioctl(struct tcb *tcp, long arg)
+ff_effect_ioctl(struct tcb *const tcp, const kernel_ulong_t arg)
 {
        tprints(", ");
 
-       struct ff_effect ffe;
+       struct_ff_effect ffe;
 
        if (umove_or_printaddr(tcp, arg, &ffe))
                return 1;
@@ -121,10 +133,10 @@ ff_effect_ioctl(struct tcb *tcp, long arg)
                                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);
+                       tprintf(", custom_len=%u, custom_data=",
+                               ffe.u.periodic.custom_len);
+                       printaddr(ptr_to_kulong(ffe.u.periodic.custom_data));
+                       tprints("}");
                        break;
                case FF_RUMBLE:
                        tprintf(", rumble={strong_magnitude=%" PRIu16
@@ -142,7 +154,7 @@ ff_effect_ioctl(struct tcb *tcp, long arg)
 }
 
 static int
-abs_ioctl(struct tcb *tcp, long arg)
+abs_ioctl(struct tcb *const tcp, const kernel_ulong_t arg)
 {
        tprints(", ");
 
@@ -176,7 +188,7 @@ abs_ioctl(struct tcb *tcp, long arg)
 }
 
 static int
-keycode_ioctl(struct tcb *tcp, long arg)
+keycode_ioctl(struct tcb *const tcp, const kernel_ulong_t arg)
 {
        tprints(", ");
 
@@ -193,7 +205,7 @@ keycode_ioctl(struct tcb *tcp, long arg)
 
 # ifdef EVIOCGKEYCODE_V2
 static int
-keycode_V2_ioctl(struct tcb *tcp, long arg)
+keycode_V2_ioctl(struct tcb *const tcp, const kernel_ulong_t arg)
 {
        tprints(", ");
 
@@ -230,7 +242,7 @@ keycode_V2_ioctl(struct tcb *tcp, long arg)
 # endif /* EVIOCGKEYCODE_V2 */
 
 static int
-getid_ioctl(struct tcb *tcp, long arg)
+getid_ioctl(struct tcb *const tcp, const kernel_ulong_t arg)
 {
        tprints(", ");
 
@@ -250,13 +262,14 @@ getid_ioctl(struct tcb *tcp, long arg)
 }
 
 static int
-decode_bitset(struct tcb *tcp, long arg, const struct xlat decode_nr[],
-             const unsigned int max_nr, const char *dflt)
+decode_bitset(struct tcb *const tcp, const kernel_ulong_t arg,
+             const struct xlat decode_nr[], const unsigned int max_nr,
+             const char *const dflt)
 {
        tprints(", ");
 
        unsigned int size;
-       if ((unsigned long) tcp->u_rval > max_nr)
+       if ((kernel_ulong_t) tcp->u_rval > max_nr)
                size = max_nr;
        else
                size = tcp->u_rval;
@@ -292,7 +305,8 @@ decode_bitset(struct tcb *tcp, long arg, const struct xlat decode_nr[],
 
 # ifdef EVIOCGMTSLOTS
 static int
-mtslots_ioctl(struct tcb *tcp, const unsigned int code, long arg)
+mtslots_ioctl(struct tcb *const tcp, const unsigned int code,
+             const kernel_ulong_t arg)
 {
        tprints(", ");
 
@@ -324,7 +338,7 @@ mtslots_ioctl(struct tcb *tcp, const unsigned int code, long arg)
 
 # if defined EVIOCGREP || defined EVIOCSREP
 static int
-repeat_ioctl(struct tcb *tcp, long arg)
+repeat_ioctl(struct tcb *const tcp, const kernel_ulong_t arg)
 {
        tprints(", ");
        printpair_int(tcp, arg, "%u");
@@ -333,7 +347,8 @@ repeat_ioctl(struct tcb *tcp, long arg)
 # endif /* EVIOCGREP || EVIOCSREP */
 
 static int
-bit_ioctl(struct tcb *tcp, const unsigned int ev_nr, const long arg)
+bit_ioctl(struct tcb *const tcp, const unsigned int ev_nr,
+         const kernel_ulong_t arg)
 {
        switch (ev_nr) {
                case EV_SYN:
@@ -383,7 +398,8 @@ bit_ioctl(struct tcb *tcp, const unsigned int ev_nr, const long arg)
 }
 
 static int
-evdev_read_ioctl(struct tcb *tcp, const unsigned int code, const long arg)
+evdev_read_ioctl(struct tcb *const tcp, const unsigned int code,
+                const kernel_ulong_t arg)
 {
        /* fixed-number fixed-length commands */
        switch (code) {
@@ -422,7 +438,7 @@ evdev_read_ioctl(struct tcb *tcp, const unsigned int code, const long arg)
                        if (syserror(tcp))
                                printaddr(arg);
                        else
-                               printstr(tcp, arg, tcp->u_rval);
+                               printstrn(tcp, arg, tcp->u_rval);
                        return 1;
 # ifdef EVIOCGPROP
                case _IOC_NR(EVIOCGPROP(0)):
@@ -457,7 +473,8 @@ evdev_read_ioctl(struct tcb *tcp, const unsigned int code, const long arg)
 }
 
 static int
-evdev_write_ioctl(struct tcb *tcp, const unsigned int code, const long arg)
+evdev_write_ioctl(struct tcb *const tcp, const unsigned int code,
+                 const kernel_ulong_t arg)
 {
        /* fixed-number fixed-length commands */
        switch (code) {
@@ -480,7 +497,7 @@ evdev_write_ioctl(struct tcb *tcp, const unsigned int code, const long arg)
 # ifdef EVIOCREVOKE
                case EVIOCREVOKE:
 # endif
-                       tprintf(", %lu", arg);
+                       tprintf(", %" PRI_klu, arg);
                        return 1;
 # ifdef EVIOCSCLOCKID
                case EVIOCSCLOCKID:
@@ -497,10 +514,10 @@ evdev_write_ioctl(struct tcb *tcp, const unsigned int code, const long arg)
        return 0;
 }
 
-int
-evdev_ioctl(struct tcb *tcp, const unsigned int code, long arg)
+MPERS_PRINTER_DECL(int, evdev_ioctl, struct tcb *const tcp,
+                  const unsigned int code, const kernel_ulong_t arg)
 {
-       switch(_IOC_DIR(code)) {
+       switch (_IOC_DIR(code)) {
                case _IOC_READ:
                        if (entering(tcp))
                                return 0;