* [PATCH 0/2] constify net_protocol structures
@ 2017-07-29 6:16 Julia Lawall
2017-07-29 6:16 ` [PATCH 1/2] ipv4: " Julia Lawall
2017-07-29 6:16 ` [PATCH 2/2] l2tp: " Julia Lawall
0 siblings, 2 replies; 3+ messages in thread
From: Julia Lawall @ 2017-07-29 6:16 UTC (permalink / raw)
To: David S. Miller; +Cc: bhumirks, kernel-janitors, netdev, linux-kernel
The net_protocol structure is only passed as the first argument to
inet_add_protocol or inet_del_protocol, both of which are declared
as const. Thus the net_protocol structure itself can be const.
Done with the help of Coccinelle.
---
net/ipv4/af_inet.c | 4 ++--
net/l2tp/l2tp_ip.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/2] ipv4: constify net_protocol structures
2017-07-29 6:16 [PATCH 0/2] constify net_protocol structures Julia Lawall
@ 2017-07-29 6:16 ` Julia Lawall
2017-07-29 6:16 ` [PATCH 2/2] l2tp: " Julia Lawall
1 sibling, 0 replies; 3+ messages in thread
From: Julia Lawall @ 2017-07-29 6:16 UTC (permalink / raw)
To: David S. Miller
Cc: bhumirks, kernel-janitors, Alexey Kuznetsov, Hideaki YOSHIFUJI,
netdev, linux-kernel
The net_protocol structures are only passed as the first argument to
inet_add_protocol, which is declared as const. Thus the net_protocol
structures themselves can be const.
Done with the help of Coccinelle.
// <smpl>
@r disable optional_qualifier@
identifier i;
position p;
@@
static struct net_protocol i@p = { ... };
@ok1@
identifier r.i;
expression e1;
position p;
@@
inet_add_protocol(&i@p,...)
@bad@
position p != {r.p,ok1.p};
identifier r.i;
struct net_protocol e;
@@
e@i@p
@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
struct net_protocol i = { ... };
// </smpl>
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
net/ipv4/af_inet.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index 5ce44fb..2e38624 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -1594,7 +1594,7 @@ u64 snmp_fold_field64(void __percpu *mib, int offt, size_t syncp_offset)
};
#endif
-static struct net_protocol tcp_protocol = {
+static const struct net_protocol tcp_protocol = {
.early_demux = tcp_v4_early_demux,
.early_demux_handler = tcp_v4_early_demux,
.handler = tcp_v4_rcv,
@@ -1604,7 +1604,7 @@ u64 snmp_fold_field64(void __percpu *mib, int offt, size_t syncp_offset)
.icmp_strict_tag_validation = 1,
};
-static struct net_protocol udp_protocol = {
+static const struct net_protocol udp_protocol = {
.early_demux = udp_v4_early_demux,
.early_demux_handler = udp_v4_early_demux,
.handler = udp_rcv,
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] l2tp: constify net_protocol structures
2017-07-29 6:16 [PATCH 0/2] constify net_protocol structures Julia Lawall
2017-07-29 6:16 ` [PATCH 1/2] ipv4: " Julia Lawall
@ 2017-07-29 6:16 ` Julia Lawall
1 sibling, 0 replies; 3+ messages in thread
From: Julia Lawall @ 2017-07-29 6:16 UTC (permalink / raw)
To: David S. Miller; +Cc: bhumirks, kernel-janitors, netdev, linux-kernel
The net_protocol structure is only passed as the first argument to
inet_add_protocol or inet_del_protocol, both of which are declared
as const. Thus the net_protocol structure itself can be const.
Done with the help of Coccinelle.
// <smpl>
@r disable optional_qualifier@
identifier i;
position p;
@@
static struct net_protocol i@p = { ... };
@ok1@
identifier r.i;
expression e1;
position p;
@@
\(inet_add_protocol\|inet_del_protocol\)(&i@p,...)
@bad@
position p != {r.p,ok1.p};
identifier r.i;
struct net_protocol e;
@@
e@i@p
@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
struct net_protocol i = { ... };
// </smpl>
Also drop __read_mostly.
Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>
---
net/l2tp/l2tp_ip.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/l2tp/l2tp_ip.c b/net/l2tp/l2tp_ip.c
index 4d322c1..c8e4d85 100644
--- a/net/l2tp/l2tp_ip.c
+++ b/net/l2tp/l2tp_ip.c
@@ -649,7 +649,7 @@ int l2tp_ioctl(struct sock *sk, int cmd, unsigned long arg)
.ops = &l2tp_ip_ops,
};
-static struct net_protocol l2tp_ip_protocol __read_mostly = {
+static const struct net_protocol l2tp_ip_protocol = {
.handler = l2tp_ip_recv,
.netns_ok = 1,
};
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-07-29 6:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-07-29 6:16 [PATCH 0/2] constify net_protocol structures Julia Lawall
2017-07-29 6:16 ` [PATCH 1/2] ipv4: " Julia Lawall
2017-07-29 6:16 ` [PATCH 2/2] l2tp: " Julia Lawall
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).