Re: [PATCH v5 1/8] net: Remove the now superfluous sentinel elements from ctl_table array

Joel Granados <[email protected]>
Newsgroups org.kernel.vger.linux-x25,dev.linux.lists.bridge,dev.linux.lists.mptcp,org.kernel.vger.dccp,org.kernel.vger.linux-hams,org.kernel.vger.linux-kernel,org.kernel.vger.linux-nfs,org.kernel.vger.linux-rdma,org.kernel.vger.linux-s390,org.kernel.vger.linux-sctp,org.kernel.vger.linux-wpan,org.kernel.vger.lvs-devel,org.kernel.vger.netdev,org.kernel.vger.netfilter-devel
Message-ID <[email protected]>
On Mon, Apr 29, 2024 at 04:49:18PM +0200, Sabrina Dubroca wrote:
> 2024-04-29, 14:33:15 +0200, Joel Granados wrote:
> > On Mon, Apr 29, 2024 at 10:53:47AM +0200, Sabrina Dubroca wrote:
> > > 2024-04-26, 12:46:53 +0200, Joel Granados via B4 Relay wrote:
...
> > > >  {
> > > > +	size_t table_size = ARRAY_SIZE(mpls_table);
> > > 
> > > This table still has a {} as its final element. It should be gone too?
> > Now, how did that get away?  I'll run my coccinelle scripts once more to
> > make sure that I don't have more of these hiding in the shadows.
> 
> I didn't spot any other with a dumb
> 
>     sed -n '<line>,^};/p' <file>

I used a coccinelle script:
  * ran it with `make coccicheck MODE=patch SPFLAGS="--in-place --debug" COCCI=script.cocci`
  * script:
    ```
    virtual patch

    @r1@
    identifier ctl_table_name;
    @@

    static struct ctl_table ctl_table_name[] = {
    ...
    -, {}
    };
    ```

and a gawk script
  * ran it with `for f in $(git grep -l "struct ctl_table") ; do script $f ; done`
  * script:
    ```
    #!/usr/bin/gawk -f

    BEGINFILE {
      RS=","
      has_struct = 0
    }

    /(static )?(const )?struct ctl_table/ {
      has_struct = 1
    }

    has_struct && /^(\n)?[\t ]*{(\n)*[\t ]*}/ {
      print "Filename : " FILENAME ", Record Number : " FNR
    }
    ```

At this point the coccinelle script gives me too many false positives
but the gawk is spot on. Thx for the sed one. Will make a note of it.

Best


-- 

Joel Granados
signature.asc (application/pgp-signature, 659 B)
-----BEGIN PGP SIGNATURE-----

iQGzBAABCgAdFiEErkcJVyXmMSXOyyeQupfNUreWQU8FAmYw5uwACgkQupfNUreW
QU9l3wwAkqQQGkCIH8hoA/NcwLoETQ0VaIIcpgRXYq3d+WvE3iHimlD4zkeOxvel
saZJ2dmttK0T+DjmrV7XMvEyH1DchjlJBSB9xRl9+0NgwfP7q40MBgRJXptfl/FI
BDavrylIYGWdP5XAldlUfQiH/NDmx1gXbjuUNZvJXpZxd2qY6fLDBC3yoYGL/Ucq
uhu9JJUZgXWVLZbB+mTdA3dLCzwJN6coxzuAxFTnqbpLj69Ds6vj47jG4aeg8Xf/
QcQ3HPuwPt5OCswVu6WExaB6Yz/b5TLnQzN1dgMWsMTMHWo3/+GNGUIfAffxtpwc
AMzd1dqvwIXvx6EZilpayO0Y052Fd91CuqR/OcKmz60BntOM6hxjIecGmqMdcKhZ
0YN3i6Tmk/VCmg6i95066V5fFlzbCoWTarpG0ozYzEQJNPY4y/bhCSGFtNn5eXJQ
IdAUXFCJcyhfOWPGRMNkLl+XhgCOvopNTj4rQ1w1ynnxBXt7FKMG68chVXnad8Bc
54MD/HbU
=Dpqe
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.