[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20170729094136.GG28392@breakpoint.cc>
Date: Sat, 29 Jul 2017 11:41:36 +0200
From: Florian Westphal <fw@...len.de>
To: Julia Lawall <julia.lawall@...6.fr>
Cc: Florian Westphal <fw@...len.de>,
linux-decnet-user@...ts.sourceforge.net, bhumirks@...il.com,
kernel-janitors@...r.kernel.org,
Pablo Neira Ayuso <pablo@...filter.org>,
Jozsef Kadlecsik <kadlec@...ckhole.kfki.hu>,
"David S. Miller" <davem@...emloft.net>,
netfilter-devel@...r.kernel.org, coreteam@...filter.org,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 0/2] constify nf_hook_ops structures
Julia Lawall <julia.lawall@...6.fr> wrote:
> On Sat, 29 Jul 2017, Florian Westphal wrote:
> > From a quick glance I don't see why we can't e.g. constify
> > nf_conntrack_l3/4_proto too. It is not going to be as simple
> > as just placing const everywhere, but I see no requirement for
> > having these writeable.
>
> I will take a look.
Thanks.
nf_logger and nf_loginfo also look like constify candidates.
If there is a way to add "const" qualifier to pointer-to-structs
that are not modified this would good as well to have IMO, if just
for purpose of documentation. For instance:
+++ b/net/netfilter/nf_conntrack_core.c
@@ -1177,8 +1177,8 @@ void nf_conntrack_free(struct nf_conn *ct)
static noinline struct nf_conntrack_tuple_hash *
init_conntrack(struct net *net, struct nf_conn *tmpl,
const struct nf_conntrack_tuple *tuple,
- struct nf_conntrack_l3proto *l3proto,
- struct nf_conntrack_l4proto *l4proto,
+ const struct nf_conntrack_l3proto *l3proto,
+ const struct nf_conntrack_l4proto *l4proto,
(its only passed as arg to a function that expects
"const struct nf_conntrack_x *").
I think we have several (also non-static helpers) that
take "struct foo *" arg while they could use "const struct foo*"
instead.
Powered by blists - more mailing lists