Subject: Re: [iproute PATCH v3] Use ARRAY_SIZE macro everywhere

From: Stephen Hemminger <[email-masked]>
Date: Sun, 27 Mar 2016 10:42:36 -0700

On Tue, 22 Mar 2016 16:52:53 +0100
Phil Sutter <[email-masked]> wrote:

> This patch was generated by the following semantic patch (a trimmed down
> version of what is shipped with Linux sources):
> 
> @@
> type T;
> T[] E;
> @@
> (
> - (sizeof(E)/sizeof(*E))
> + ARRAY_SIZE(E)
> |
> - (sizeof(E)/sizeof(E[...]))
> + ARRAY_SIZE(E)
> |
> - (sizeof(E)/sizeof(T))
> + ARRAY_SIZE(E)
> )
> 
> The only manual adjustment was to include utils.h in misc/nstat.c to make
> the macro known there.
> 
> Signed-off-by: Phil Sutter <[email-masked]>
> ---
> Changes since v1:
> - Rebased onto current master to avoid merge conflicts.
> 
> Changes since v2:
> - Patch recreated from scratch.
> ---
>  bridge/link.c | 2 +-
>  misc/nstat.c  | 2 +-
>  misc/ss.c     | 2 +-
>  3 files changed, 3 insertions(+), 3 deletions(-)

You need to test build after coccinelle!

nstat.c: In function ‘useless_number’:
nstat.c:98:2: warning: implicit declaration of function ‘ARRAY_SIZE’ [-Wimplicit-function-declaration]
  for (i = 0; i < ARRAY_SIZE(useless_numbers); i++)
  ^
gcc -Wall -Wstrict-prototypes  -Wmissing-prototypes -Wmissing-declarations -Wold-style-definition -Wformat=2 -O2 -I../include -DRESOLVE_HOSTNAMES -DLIBDIR=\"/usr/lib\" -DCONFDIR=\"/etc/iproute2\" -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE   -DHAVE_SELINUX -DHAVE_SETNS   -c -o ssfilter.o ssfilter.c
gcc   lnstat.o lnstat_util.o  ../lib/libnetlink.a ../lib/libutil.a -lselinux  -o lnstat
/tmp/ccoYmLJI.o: In function `useless_number':
nstat.c:(.text+0x40): undefined reference to `ARRAY_SIZE'

Please fix and resubmit