Re: [PATCH 1/3] libnfnetlink byte alignment

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

 



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@xxxxxx>

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...
--
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