From: Dmitry V. Levin Date: Sat, 17 Jun 2017 18:49:58 +0000 (+0000) Subject: Fix a few sizeof style issues X-Git-Tag: v4.18~75 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a74c08461184f94ad6621e3375422aba259e0827;p=strace Fix a few sizeof style issues Reported by kernel's checkpatch.pl script. --- diff --git a/count.c b/count.c index 1af93361..f5e4f12f 100644 --- a/count.c +++ b/count.c @@ -77,7 +77,7 @@ count_syscall(struct tcb *tcp, const struct timeval *syscall_exiting_tv) /* Initialize it. */ struct itimerval it; - memset(&it, 0, sizeof it); + memset(&it, 0, sizeof(it)); it.it_interval.tv_usec = 1; setitimer(ITIMER_REAL, &it, NULL); getitimer(ITIMER_REAL, &it); diff --git a/pathtrace.c b/pathtrace.c index ea48825e..4dfccbf5 100644 --- a/pathtrace.c +++ b/pathtrace.c @@ -59,7 +59,7 @@ upathmatch(struct tcb *const tcp, const kernel_ulong_t upath) { char path[PATH_MAX + 1]; - return umovestr(tcp, upath, sizeof path, path) > 0 && + return umovestr(tcp, upath, sizeof(path), path) > 0 && pathmatch(path); } diff --git a/strace.c b/strace.c index f4b488e1..3af9e4fb 100644 --- a/strace.c +++ b/strace.c @@ -1372,7 +1372,7 @@ startup_child(char **argv) continue; len = strlen(pathname); } - else if (n > sizeof pathname - 1) + else if (n > sizeof(pathname) - 1) continue; else { strncpy(pathname, path, n); diff --git a/tests/net-accept-connect.c b/tests/net-accept-connect.c index 04c05a60..0050eeb4 100644 --- a/tests/net-accept-connect.c +++ b/tests/net-accept-connect.c @@ -69,7 +69,7 @@ main(int ac, const char **av) if (listen(0, 5)) perror_msg_and_skip("listen"); - memset(&addr, 0, sizeof addr); + memset(&addr, 0, sizeof(addr)); assert(getsockname(0, (struct sockaddr *) &addr, &len) == 0); if (len > sizeof(addr)) len = sizeof(addr); diff --git a/tests/uio.c b/tests/uio.c index 6291f972..21f005d9 100644 --- a/tests/uio.c +++ b/tests/uio.c @@ -39,16 +39,16 @@ main(void) { const off_t offset = 0xdefaceddeadbeefLL; char buf[4]; - struct iovec iov = { buf, sizeof buf }; + struct iovec iov = { buf, sizeof(buf) }; (void) close(0); assert(open("/dev/zero", O_RDONLY) == 0); - assert(pread(0, buf, sizeof buf, offset) == 4); + assert(pread(0, buf, sizeof(buf), offset) == 4); assert(preadv(0, &iov, 1, offset) == 4); assert(!close(0)); assert(open("/dev/null", O_WRONLY) == 0); - assert(pwrite(0, buf, sizeof buf, offset) == 4); + assert(pwrite(0, buf, sizeof(buf), offset) == 4); assert(pwritev(0, &iov, 1, offset) == 4); assert(!close(0)); diff --git a/util.c b/util.c index 90a6f9e2..dc6c765d 100644 --- a/util.c +++ b/util.c @@ -711,8 +711,8 @@ printpathn(struct tcb *const tcp, const kernel_ulong_t addr, unsigned int n) } /* Cap path length to the path buffer size */ - if (n > sizeof path - 1) - n = sizeof path - 1; + if (n > sizeof(path) - 1) + n = sizeof(path) - 1; /* Fetch one byte more to find out whether path length > n. */ nul_seen = umovestr(tcp, addr, n + 1, path);