]> granicus.if.org Git - strace/commitdiff
Fix a few sizeof style issues
authorDmitry V. Levin <ldv@altlinux.org>
Sat, 17 Jun 2017 18:49:58 +0000 (18:49 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Sat, 17 Jun 2017 18:49:58 +0000 (18:49 +0000)
Reported by kernel's checkpatch.pl script.

count.c
pathtrace.c
strace.c
tests/net-accept-connect.c
tests/uio.c
util.c

diff --git a/count.c b/count.c
index 1af9336180a5bf585371ff5674f296e8ac187f27..f5e4f12f49b2534de938c494685316f1ac35ed78 100644 (file)
--- 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);
index ea48825e5a019255c0b4b08f537916607df96048..4dfccbf5fd9405fcfbd2aee685d752aefbe421d6 100644 (file)
@@ -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);
 }
 
index f4b488e18d394578f6c6f15b652ffd761596166a..3af9e4fb0636e215b3590e67f12d716e019123f2 100644 (file)
--- 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);
index 04c05a60d52855cfa2d55fdd6a241192151d0be6..0050eeb49ea4ebe5bf8cbcb36c33e5a965c186e5 100644 (file)
@@ -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);
index 6291f972ff80d012afa83abb1fe6570601ccffdd..21f005d9bd43d157845653390dfb700c345db11e 100644 (file)
@@ -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 90a6f9e2a37a6f01c75daf47e1c3007a57a217c3..dc6c765dafd9840acae374a0c5e6d9e32671c83a 100644 (file)
--- 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);