From: Patrick McHardy <kaber@trash.net>
To: Jan Engelhardt <jengelh@computergmbh.de>
Cc: Netfilter Developer Mailing List <netfilter-devel@lists.netfilter.org>
Subject: Re: [PATCH 1/3] Misc cleanups
Date: Mon, 11 Jun 2007 16:34:01 +0200 [thread overview]
Message-ID: <466D5D59.8000002@trash.net> (raw)
In-Reply-To: <Pine.LNX.4.64.0706111624320.19578@fbirervta.pbzchgretzou.qr>
Jan Engelhardt wrote:
> On Jun 11 2007 16:17, Patrick McHardy wrote:
>
>>>@@ -249,7 +249,7 @@ clusterip_hashfn(struct sk_buff *skb, st
>>> case IPPROTO_SCTP:
>>> case IPPROTO_DCCP:
>>> case IPPROTO_ICMP:
>>>- ports = (void *)iph+iph->ihl*4;
>>>+ ports = (const void *)iph+iph->ihl*4;
>>
>>
>>This one is not neccessary.
>
>
> *Are* you sure? iph is a const struct iphdr *, so adding (iph->ihl*4)
> will add sizeof(const struct iphdr *) * (iph->ihl*4) bytes. Which is
> four times more (eight on 64-bit) than actually wanted. C basics.
I'm talking about the const. But OK, I missed that iph is already const,
so the const cast is cleaner. I'll add it back.
>>>@@ -88,7 +88,7 @@ masquerade_target(struct sk_buff **pskb,
>>> return NF_ACCEPT;
>>>
>>> mr = targinfo;
>>>- rt = (struct rtable *)(*pskb)->dst;
>>>+ rt = (const struct rtable *)(*pskb)->dst;
>>
>>
>>This one neither.
>
>
> Uhm? ->dst is of type "struct dst_entry", while rt is of type struct rtable.
I'm just talking about casting to const.
>
> [...]
>
> I think something is wrong. What is, actually? The "const"? Well
> yeah I added that for great consistency.
Its unnecessary, but OK in places where the pointer you cast was
already const (since its ugly to cast const pointers to non-const),
in all other casts its just unnecessary.
>>>@@ -443,8 +449,8 @@ hashlimit_match(const struct sk_buff *sk
>>> unsigned int protoff,
>>> bool *hotdrop)
>>> {
>>>- struct xt_hashlimit_info *r =
>>>- ((struct xt_hashlimit_info *)matchinfo)->u.master;
>>>+ const struct xt_hashlimit_info *r =
>>>+ ((const struct xt_hashlimit_info *)matchinfo)->u.master;
>>
>>
>>This one is fine I guess since matchinfo is also const. Same for
>>all other matches.
>>
>
>
> And here it's ok? I don't get it. De-de-referencing a const item does
> not always need to give a const item, hence, all is fine.
> Mind you, I compile tested it, and it was warning-free, as before.
> Care to explain?
See above.
next prev parent reply other threads:[~2007-06-11 14:34 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-04 19:09 [PATCH 0/3] Misc cleanups Jan Engelhardt
2007-06-04 19:11 ` [PATCH 1/3] " Jan Engelhardt
2007-06-11 14:17 ` Patrick McHardy
2007-06-11 14:31 ` Jan Engelhardt
2007-06-11 14:34 ` Patrick McHardy [this message]
2007-06-04 19:13 ` [PATCH 2/3] " Jan Engelhardt
2007-06-11 14:18 ` Patrick McHardy
2007-06-04 19:14 ` [PATCH 3/3] " Jan Engelhardt
2007-06-11 14:30 ` Patrick McHardy
2007-06-06 16:11 ` [PATCH 0/3] " Patrick McHardy
2007-06-07 6:56 ` Jan Engelhardt
2007-06-07 8:26 ` 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=466D5D59.8000002@trash.net \
--to=kaber@trash.net \
--cc=jengelh@computergmbh.de \
--cc=netfilter-devel@lists.netfilter.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.