Re: [PATCH 6/6] netfilter: xtables: add const qualifiers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thursday 2010-02-11 10:56, Patrick McHardy wrote:

>Alexey Dobriyan wrote:
>> On Thu, Feb 11, 2010 at 11:27 AM, Patrick McHardy <kaber@xxxxxxxxx> 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.
>
>Yes, occasionally it has caught typos or other variable mixups for me.
>It also documents that a variable is only supposed to be read.

In this case it allows parameter and local variable reduction
because I have proven, by means of const, that they would
remain the same over the entire function. (Scheduled commit
3c58069510:
http://dev.medozas.de/gitweb.cgi?p=linux;a=commit;h=3c58069510a498110240ceaff8c2a10c0d9b4460
 - this will be in the next pull group.)

>>>>> -    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 *)?
>
>That's not necessary. Its just declaring the the memory should
>not be modified through e. The const qualification happens
>automatically.

Conversion from T* to const T* is permitted and implicit across =.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux