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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux