From: Eugene Syromyatnikov Date: Sun, 1 Jan 2017 18:53:48 +0000 (+0300) Subject: ioctl: do not print explicit 0x prefix and do not specify minimum width X-Git-Tag: v4.16~103 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b00f54e88104a6d16f8c59b4b42ef04af39ef2dc;p=strace ioctl: do not print explicit 0x prefix and do not specify minimum width 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. --- diff --git a/ioctl.c b/ioctl.c index 82a1783b..88c75ff4 100644 --- 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)); } diff --git a/tests/ioctl.c b/tests/ioctl.c index f05ff5ce..6897890a 100644 --- a/tests/ioctl.c +++ b/tests/ioctl.c @@ -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 +++"); diff --git a/tests/ioctl_dm.c b/tests/ioctl_dm.c index 718bc890..f4e59962 100644 --- a/tests/ioctl_dm.c +++ b/tests/ioctl_dm.c @@ -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); diff --git a/tests/ioctl_evdev.c b/tests/ioctl_evdev.c index aded93f0..b21a962d 100644 --- a/tests/ioctl_evdev.c +++ b/tests/ioctl_evdev.c @@ -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",