netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexey Dobriyan <adobriyan@gmail.com>
To: Patrick McHardy <kaber@trash.net>
Cc: jengelh@medozas.de, netfilter-devel@vger.kernel.org
Subject: Re: [PATCH 6/6] netfilter: xtables: add const qualifiers
Date: Thu, 11 Feb 2010 11:42:41 +0200	[thread overview]
Message-ID: <b6fcc0a1002110142p524de4ddm5260751cc68f4482@mail.gmail.com> (raw)
In-Reply-To: <4B73CD6C.2090302@trash.net>

On Thu, Feb 11, 2010 at 11:27 AM, Patrick McHardy <kaber@trash.net> wrote:
> Alexey Dobriyan wrote:
>>> -static inline int ebt_basic_match(struct ebt_entry *e, struct ethhdr *h,
>>> -   const struct net_device *in, const struct net_device *out)
>>> +static inline int
>>> +ebt_basic_match(const struct ebt_entry *e, const struct ethhdr *h,
>>> +                const struct net_device *in, const struct net_device *out)
>>
>> These const modifiers are pointless because compilers are smart enough
>> to notice non-modifiability and generate the very same code in both cases.
>>
>> Nowadays, half of functions declarations in generic
>> xtables/iptables/ip6tables/arptables
>> code are littered with const which makes them pretty unpleasant to read.
>
> Well, the benefit is that the compiler can catch accidental modification
> of data that is supposed to be constant.

Did it ever? Realistically?

From what I see, const is used with string functions
(to make string literals go to rodata) and with structures full of hooks
(to make them go to rodata).

>>> -    struct ebt_entry *e = (struct ebt_entry *)chain->data;
>>> +    const struct ebt_entry *e = (struct ebt_entry *)chain->data;
>>
>> And such things are wrong (not second const).
>
> What's wrong about this?

Should it be (const struct ebt_entry *)?
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2010-02-11  9:42 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-11  9:14 [PATCH 6/6] netfilter: xtables: add const qualifiers Alexey Dobriyan
2010-02-11  9:27 ` Patrick McHardy
2010-02-11  9:42   ` Alexey Dobriyan [this message]
2010-02-11  9:56     ` Patrick McHardy
2010-02-11 13:12       ` Jan Engelhardt
  -- strict thread matches above, loose matches on Subject: below --
2010-02-10 17:39 Code cleanups Jan Engelhardt
2010-02-10 17:39 ` [PATCH 6/6] netfilter: xtables: add const qualifiers Jan Engelhardt
2010-02-11  9:00   ` Patrick McHardy
2010-02-11 13:27     ` Jan Engelhardt
2010-02-11 16:06       ` Patrick McHardy
2010-02-11 16:22         ` Jan Engelhardt
2010-02-11 16:27           ` Patrick McHardy
2010-02-11 17:04             ` Jan Engelhardt
2009-11-03 18:04 Xtables cleanup patches Jan Engelhardt
2009-11-03 18:04 ` [PATCH 6/6] netfilter: xtables: add const qualifiers Jan Engelhardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b6fcc0a1002110142p524de4ddm5260751cc68f4482@mail.gmail.com \
    --to=adobriyan@gmail.com \
    --cc=jengelh@medozas.de \
    --cc=kaber@trash.net \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).