Linux Netfilter development
 help / color / mirror / Atom feed
From: Fabian Hugelshofer <hugelshofer2006@gmx.ch>
To: Patrick McHardy <kaber@trash.net>
Cc: netfilter-devel@vger.kernel.org
Subject: Re: [PATCH 1/3] libnfnetlink byte alignment
Date: Wed, 04 Jun 2008 09:53:22 +0100	[thread overview]
Message-ID: <48465802.2010005@gmx.ch> (raw)
In-Reply-To: <484541E0.3020900@trash.net>

Patrick McHardy wrote:
> Fabian Hugelshofer wrote:
>> Aligns buffers to maximum alignment of architecture to make the cast of
>> char pointers to struct pointers more portable.
>>
>> Signed-off-by: Fabian Hugelshofer <hugelshofer2006@gmx.ch>
> 
> They all seem fine to me, but a union might make it look
> a bit nicer :)

In libnfnetlink the union does not make sense, because multiple casts 
are done from the same buffer at different locations.

For libnetfilter-(conntrack|log) the union would be possible:

Original (aligned):
<< code begin >>
char buf[...] __attribute__ ((aligned));
struct nlmsghdr *nmh = (struct nlmsghdr *) buf;

nfnl_fill_hdr(h->nfnlssh, nmh, 0, pf, queuenum, ...);
<< code end >>

Union style:
<< code begin >>
union {
	char buf[...];
	struct nlmsghdr nmh;
} u;

nfnl_fill_hdr(h->nfnlssh, &u.nmh, 0, pf, queuenum, ...);
<< code end >>

I can rewrite it like this, if desired...

  reply	other threads:[~2008-06-04  8:53 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-06-03 10:20 [PATCH 1/3] libnfnetlink byte alignment Fabian Hugelshofer
2008-06-03 13:06 ` Patrick McHardy
2008-06-04  8:53   ` Fabian Hugelshofer [this message]
2008-06-04 14:35     ` Patrick McHardy
2008-06-04 21:42     ` Pablo Neira Ayuso
2008-06-05 12:55       ` Fabian Hugelshofer
2008-06-05 13:31         ` Pablo Neira Ayuso
2008-06-18 12:39 ` Pablo Neira Ayuso

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=48465802.2010005@gmx.ch \
    --to=hugelshofer2006@gmx.ch \
    --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