netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ben Greear <greearb@candelatech.com>
To: Ben Hutchings <bhutchings@solarflare.com>
Cc: NetDev <netdev@vger.kernel.org>
Subject: Re: ip_tables.h can't be used in C++ programs.
Date: Fri, 20 Aug 2010 16:42:59 -0700	[thread overview]
Message-ID: <4C6F1303.70707@candelatech.com> (raw)
In-Reply-To: <1282346230.3454.193.camel@localhost>

On 08/20/2010 04:17 PM, Ben Hutchings wrote:
> On Fri, 2010-08-20 at 11:54 -0700, Ben Greear wrote:
>> This method returns void* but is defined to return
>> a pointer to struct ipt_entry_target.
>>
>> This will not compile under g++ (or, I'm unable to figure out
>> how to make it work w/out editing the header file).
>>
>> Any reason this shouldn't be changed to:
>>
>>    return (struct ipt_entry_target*)e + e->target_offset;
>
> Because that multiplies the offset by sizeof(struct ipt_entry_target)!
>
>> /* Helper functions */
>> static __inline__ struct ipt_entry_target *
>> ipt_get_target(struct ipt_entry *e)
>> {
>>           return (void *)e + e->target_offset;
>> }
>
> For extra unportability, this is relying on the gcc extension for void
> pointer arithmetic.  Try something like:
>
> 	return (struct ipt_entry_target *)((char *)e + e->target_offset);

That compiles fine for me, would be great to get something like
that upstream!

Take it easy,
Ben

-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com


      reply	other threads:[~2010-08-20 23:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-08-20 18:54 ip_tables.h can't be used in C++ programs Ben Greear
2010-08-20 23:17 ` Ben Hutchings
2010-08-20 23:42   ` Ben Greear [this message]

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=4C6F1303.70707@candelatech.com \
    --to=greearb@candelatech.com \
    --cc=bhutchings@solarflare.com \
    --cc=netdev@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).