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

Joel Granados j.granados at samsung.com
Tue Apr 30 05:41:16 PDT 2024


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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-afs/attachments/20240430/07b9480c/attachment.sig>


More information about the linux-afs mailing list