lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1504452962.18971.1.camel@perches.com>
Date:   Sun, 03 Sep 2017 08:36:02 -0700
From:   Joe Perches <joe@...ches.com>
To:     Thomas Meyer <thomas@...3r.de>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 0/10] Use ARRAY_SIZE macro - v4.13-rc7

On Sun, 2017-09-03 at 14:19 +0200, Thomas Meyer wrote:
> Use ARRAY_SIZE macro, rather than explicitly coding some variant of it
> yourself.
> 
> Found with: find -type f -name "*.c" -o -name "*.h" | xargs perl -p -i -e
> 's/\bsizeof\s*\(\s*(\w+)\s*\)\s*\ /\s*sizeof\s*\(\s*\1\s*\[\s*0\s*\]\s*\)
> /ARRAY_SIZE(\1)/g' and manual check/verification.

Hey Thomas.

There are some instances that span multiple lines that
the regex above misses.

For instance:

diff --git a/drivers/infiniband/hw/mlx5/odp.c b/drivers/infiniband/hw/mlx5/odp.c
index 3d701c7a4c91..26a825bd7581 100644
--- a/drivers/infiniband/hw/mlx5/odp.c
+++ b/drivers/infiniband/hw/mlx5/odp.c
@@ -929,8 +929,7 @@ static int mlx5_ib_mr_initiator_pfault_handler(
                return -EFAULT;
        }
 
-       if (unlikely(opcode >= sizeof(mlx5_ib_odp_opcode_cap) /
-           sizeof(mlx5_ib_odp_opcode_cap[0]) ||
+       if (unlikely(opcode >= ARRAY_SIZE(mlx5_ib_odp_opcode_cap) ||

Here is another perl command regex that fixes a few more:

$ perl -i -e 'local $/; while (<>) { s/\bsizeof\s*\(\s*(\w+)\s*\)\s*\/\s*sizeof\s*\(\s*\1\s*\[\s*0\s*\]\s*\)/ARRAY_SIZE(\1)/g; print; }' $file

This regex could still miss variants that
have a comment or that don't use parentheses
around the sizeof.

It seems none of those styles exist though.


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ