]> granicus.if.org Git - strace/commitdiff
ioctl: do not print explicit 0x prefix and do not specify minimum width
authorEugene Syromyatnikov <evgsyr@gmail.com>
Sun, 1 Jan 2017 18:53:48 +0000 (21:53 +0300)
committerDmitry V. Levin <ldv@altlinux.org>
Wed, 4 Jan 2017 13:22:19 +0000 (13:22 +0000)
Specifying output width for size argument is rather misleading - it can
be up to 14 bits in size.  The use of explicit "0x" prefix is
discouraged because 0x0 looks ugly.  Usage of width specification along
with alternate form flag leads to inconsistent output for 0.
Let's use just plain %#x qualifiers instead.

* ioctl.c (ioctl_print_code): Change printf qualifiers for ioctl command
type, number and size to "%#x".
* tests/ioctl.c (main): Update expected test output.
* tests/ioctl_dm.c (main): Likewise.
* tests/ioctl_evdev.c (main): Likewise.

ioctl.c
tests/ioctl.c
tests/ioctl_dm.c
tests/ioctl_evdev.c

diff --git a/ioctl.c b/ioctl.c
index 82a1783be1e8b508bb781622ab95ee75d6e95bc4..88c75ff4c3249cad5acdd6e1330d8a6d7d3c4e03 100644 (file)
--- a/ioctl.c
+++ b/ioctl.c
@@ -79,7 +79,7 @@ ioctl_print_code(const unsigned int code)
 {
        tprints("_IOC(");
        printflags(ioctl_dirs, _IOC_DIR(code), "_IOC_???");
-       tprintf(", 0x%02x, 0x%02x, 0x%02x)",
+       tprintf(", %#x, %#x, %#x)",
                _IOC_TYPE(code), _IOC_NR(code), _IOC_SIZE(code));
 }
 
index f05ff5ce83d44340c618e9a098962b01ab672dda..6897890a0ed84613ab0af48cfa1eed5281b3b09e 100644 (file)
@@ -89,7 +89,7 @@ main(void )
               " = -1 EBADF (%m)\n");
 
        (void) ioctl(-1, _IOR(0xde, 0xad, data), &data);
-       printf("ioctl(-1, _IOC(_IOC_READ, 0xde, 0xad, 0x08), %p)"
+       printf("ioctl(-1, _IOC(_IOC_READ, 0xde, 0xad, 0x8), %p)"
               " = -1 EBADF (%m)\n", &data);
 
        puts("+++ exited with 0 +++");
index 718bc8901c0b61c1cbf6bb4094c5f05a0311a9cd..f4e599623330613e80294607f20ded12e67369cb 100644 (file)
@@ -196,7 +196,7 @@ main(void)
 
        /* Incorrect operation */
        ioctl(-1, _IOW(DM_IOCTL, 0xde, int), dm_arg);
-       printf("ioctl(-1, _IOC(_IOC_WRITE, %#04x, 0xde, %#04zx), %p) = "
+       printf("ioctl(-1, _IOC(_IOC_WRITE, %#x, 0xde, %#zx), %p) = "
               "-1 EBADF (%m)\n",
               DM_IOCTL, sizeof(int), dm_arg);
 
index aded93f08d749f9031638d256b740521a2193f05..b21a962d541cdb101e021dd6e52123a0d4d41b66 100644 (file)
@@ -262,13 +262,13 @@ main(void)
        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",