Skip to content

Commit

Permalink
Merge branch 'inet6_protocol-const'
Browse files Browse the repository at this point in the history
Julia Lawall says:

====================
constify inet6_protocol structures

The inet6_protocol structure is only passed as the first argument to
inet6_add_protocol or inet6_del_protocol, both of which are declared as
const.  Thus the inet6_protocol structure itself can be const.

Done with the help of Coccinelle.

// <smpl>
@r disable optional_qualifier@
identifier i;
position p;
@@

static struct inet6_protocol i@p = { ... };

@ok1@
identifier r.i;
expression e1;
position p;
@@

 \(inet6_add_protocol\|inet6_del_protocol\)(&i@p,...)

@bad@
position p != {r.p,ok1.p};
identifier r.i;
struct inet6_protocol e;
@@

e@i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@

static
+const
 struct inet6_protocol i = { ... };
// </smpl>
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Jul 29, 2017
2 parents 1812bc4 + d04916a commit bdb0eff
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion net/ipv6/ip6_gre.c
Original file line number Diff line number Diff line change
Expand Up @@ -1080,7 +1080,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
}


static struct inet6_protocol ip6gre_protocol __read_mostly = {
static const struct inet6_protocol ip6gre_protocol = {
.handler = gre_rcv,
.err_handler = ip6gre_err,
.flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
Expand Down
2 changes: 1 addition & 1 deletion net/ipv6/tcp_ipv6.c
Original file line number Diff line number Diff line change
Expand Up @@ -1945,7 +1945,7 @@ struct proto tcpv6_prot = {
.diag_destroy = tcp_abort,
};

static struct inet6_protocol tcpv6_protocol = {
static const struct inet6_protocol tcpv6_protocol = {
.early_demux = tcp_v6_early_demux,
.early_demux_handler = tcp_v6_early_demux,
.handler = tcp_v6_rcv,
Expand Down
2 changes: 1 addition & 1 deletion net/ipv6/udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1448,7 +1448,7 @@ int compat_udpv6_getsockopt(struct sock *sk, int level, int optname,
}
#endif

static struct inet6_protocol udpv6_protocol = {
static const struct inet6_protocol udpv6_protocol = {
.early_demux = udp_v6_early_demux,
.early_demux_handler = udp_v6_early_demux,
.handler = udpv6_rcv,
Expand Down
2 changes: 1 addition & 1 deletion net/l2tp/l2tp_ip6.c
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ static struct inet_protosw l2tp_ip6_protosw = {
.ops = &l2tp_ip6_ops,
};

static struct inet6_protocol l2tp_ip6_protocol __read_mostly = {
static const struct inet6_protocol l2tp_ip6_protocol = {
.handler = l2tp_ip6_recv,
};

Expand Down

0 comments on commit bdb0eff

Please sign in to comment.