]> git.ipfire.org Git - thirdparty/shadow.git/commit
lib/, src/: Consistently use sizeof() as if it were a function
authorAlejandro Colomar <alx@kernel.org>
Tue, 23 Jul 2024 20:42:54 +0000 (22:42 +0200)
committerSerge Hallyn <serge@hallyn.com>
Fri, 28 Nov 2025 14:39:37 +0000 (08:39 -0600)
commitd98ccc195e58b10260ef809254444ccec2efa6c6
tree4569753761951b3a5b68e04ce25776d56493d651
parent2098f4dfeb2c934a8123f5adff5f99009096a56e
lib/, src/: Consistently use sizeof() as if it were a function

sizeof(foo)

-  No spaces.
Not:  sizeof (foo)
-  Parentheses.
Not:  sizeof foo
-  No parentheses wrapping sizeof itself
Not:  (sizeof foo)

This patch can be approximated with the following semantic patch:

$ cat ~/tmp/spatch/sizeof.sp
@@
identifier a, b;
@@

- sizeof a->b
+ sizeof(a->b)

@@
identifier a, b;
@@

- sizeof a.b
+ sizeof(a.b)

@@
identifier x;
@@

- sizeof x
+ sizeof(x)

@@
identifier x;
@@

- sizeof *x
+ sizeof(*x)

@@
identifier x;
@@

- (sizeof(x))
+ sizeof(x)

@@
identifier x;
@@

- (sizeof(*x))
+ sizeof(*x)

Applied as

$ find contrib/ lib* src/ -type f \
| xargs spatch --sp-file ~/tmp/spatch/sizeof.sp --in-place;

The differences between the actual patch and the approximation via the
semantic patch from above are whitespace only.  When reviewing, it'll
be useful to diff with '-w'.

Link: <https://lkml.org/lkml/2012/7/11/103>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
33 files changed:
lib/commonio.c
lib/console.c
lib/copydir.c
lib/env.c
lib/failure.c
lib/fields.c
lib/getdef.c
lib/hushed.c
lib/log.c
lib/loginprompt.c
lib/setupenv.c
lib/subordinateio.c
lib/ttytype.c
lib/tz.c
lib/user_busy.c
lib/utmp.c
src/chage.c
src/chfn.c
src/chgpasswd.c
src/chpasswd.c
src/chsh.c
src/faillog.c
src/groupadd.c
src/groupmod.c
src/grpconv.c
src/lastlog.c
src/login.c
src/login_nopam.c
src/newusers.c
src/pwconv.c
src/suauth.c
src/useradd.c
src/usermod.c