]> granicus.if.org Git - strace/blobdiff - ioctl.c
io.c: use printaddr and umove_or_printaddr
[strace] / ioctl.c
diff --git a/ioctl.c b/ioctl.c
index d10e45d294cc53cf491d75564566eceb86df9923..284828a5a468db2e042a19957e8adc28e190c5ee 100644 (file)
--- a/ioctl.c
+++ b/ioctl.c
@@ -272,6 +272,7 @@ ioctl_decode(struct tcb *tcp)
 SYS_FUNC(ioctl)
 {
        const struct_ioctlent *iop;
+       int ret;
 
        if (entering(tcp)) {
                printfd(tcp, tcp->u_arg[0]);
@@ -286,14 +287,22 @@ SYS_FUNC(ioctl)
                                ioctl_print_code(tcp->u_arg[1]);
                        }
                }
-               ioctl_decode(tcp);
+               ret = ioctl_decode(tcp);
+       } else {
+               ret = ioctl_decode(tcp) | RVAL_DECODED;
        }
-       else {
-               int ret = ioctl_decode(tcp);
-               if (!ret)
-                       tprintf(", %#lx", tcp->u_arg[2]);
+
+       if (ret & RVAL_DECODED) {
+               ret &= ~RVAL_DECODED;
+               if (ret)
+                       --ret;
                else
-                       return ret - 1;
+                       tprintf(", %#lx", tcp->u_arg[2]);
+               ret |= RVAL_DECODED;
+       } else {
+               if (ret)
+                       --ret;
        }
-       return 0;
+
+       return ret;
 }