LVS
lvs-devel
Google
 
Web LinuxVirtualServer.org

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

To: Sabrina Dubroca <sd@xxxxxxxxxxxxxxx>
Subject: Re: [PATCH v5 1/8] net: Remove the now superfluous sentinel elements from ctl_table array
Cc: "David S. Miller" <davem@xxxxxxxxxxxxx>, Eric Dumazet <edumazet@xxxxxxxxxx>, Jakub Kicinski <kuba@xxxxxxxxxx>, Paolo Abeni <pabeni@xxxxxxxxxx>, Alexander Aring <alex.aring@xxxxxxxxx>, Stefan Schmidt <stefan@xxxxxxxxxxxxxxxxxx>, Miquel Raynal <miquel.raynal@xxxxxxxxxxx>, David Ahern <dsahern@xxxxxxxxxx>, Steffen Klassert <steffen.klassert@xxxxxxxxxxx>, Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>, Matthieu Baerts <matttbe@xxxxxxxxxx>, Mat Martineau <martineau@xxxxxxxxxx>, Geliang Tang <geliang@xxxxxxxxxx>, Remi Denis-Courmont <courmisch@xxxxxxxxx>, Allison Henderson <allison.henderson@xxxxxxxxxx>, David Howells <dhowells@xxxxxxxxxx>, Marc Dionne <marc.dionne@xxxxxxxxxxxx>, Marcelo Ricardo Leitner <marcelo.leitner@xxxxxxxxx>, Xin Long <lucien.xin@xxxxxxxxx>, Wenjia Zhang <wenjia@xxxxxxxxxxxxx>, Jan Karcher <jaka@xxxxxxxxxxxxx>, "D. Wythe" <alibuda@xxxxxxxxxxxxxxxxx>, Tony Lu <tonylu@xxxxxxxxxxxxxxxxx>, Wen Gu <guwen@xxxxxxxxxxxxxxxxx>, Trond Myklebust <trond.myklebust@xxxxxxxxxxxxxxx>, Anna Schumaker <anna@xxxxxxxxxx>, Chuck Lever <chuck.lever@xxxxxxxxxx>, Jeff Layton <jlayton@xxxxxxxxxx>, Neil Brown <neilb@xxxxxxx>, Olga Kornievskaia <kolga@xxxxxxxxxx>, Dai Ngo <Dai.Ngo@xxxxxxxxxx>, Tom Talpey <tom@xxxxxxxxxx>, Jon Maloy <jmaloy@xxxxxxxxxx>, Ying Xue <ying.xue@xxxxxxxxxxxxx>, Martin Schiller <ms@xxxxxxxxxx>, Pablo Neira Ayuso <pablo@xxxxxxxxxxxxx>, Jozsef Kadlecsik <kadlec@xxxxxxxxxxxxx>, Florian Westphal <fw@xxxxxxxxx>, Roopa Prabhu <roopa@xxxxxxxxxx>, Nikolay Aleksandrov <razor@xxxxxxxxxxxxx>, Simon Horman <horms@xxxxxxxxxxxx>, Julian Anastasov <ja@xxxxxx>, Joerg Reuter <jreuter@xxxxxxxx>, Luis Chamberlain <mcgrof@xxxxxxxxxx>, Kees Cook <keescook@xxxxxxxxxxxx>, <netdev@xxxxxxxxxxxxxxx>, <linux-kernel@xxxxxxxxxxxxxxx>, <dccp@xxxxxxxxxxxxxxx>, <linux-wpan@xxxxxxxxxxxxxxx>, <mptcp@xxxxxxxxxxxxxxx>, <linux-hams@xxxxxxxxxxxxxxx>, <linux-rdma@xxxxxxxxxxxxxxx>, <rds-devel@xxxxxxxxxxxxxx>, <linux-afs@xxxxxxxxxxxxxxxxxxx>, <linux-sctp@xxxxxxxxxxxxxxx>, <linux-s390@xxxxxxxxxxxxxxx>, <linux-nfs@xxxxxxxxxxxxxxx>, <tipc-discussion@xxxxxxxxxxxxxxxxxxxxx>, <linux-x25@xxxxxxxxxxxxxxx>, <netfilter-devel@xxxxxxxxxxxxxxx>, <coreteam@xxxxxxxxxxxxx>, <bridge@xxxxxxxxxxxxxxx>, <lvs-devel@xxxxxxxxxxxxxxx>
From: Joel Granados <j.granados@xxxxxxxxxxx>
Date: Tue, 30 Apr 2024 14:41:16 +0200
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

<Prev in Thread] Current Thread [Next in Thread>