]> The Tcpdump Group git mirrors - tcpdump/commit
Avoid bitfields, unaligned accesses, packed structures, and PRI[ux]{16,32}.
authorGuy Harris <[email protected]>
Mon, 6 May 2013 01:52:54 +0000 (18:52 -0700)
committerGuy Harris <[email protected]>
Mon, 6 May 2013 01:52:54 +0000 (18:52 -0700)
commit1ea8a8c4a4f1140e775a6dd4384802aac7b6d622
tree3dbae29608fe5385028e1a0418c692e64d4af62e
parentbf97f9965ec6effb8d9f885e1405ebcdc0dccbcf
Avoid bitfields, unaligned accesses, packed structures, and PRI[ux]{16,32}.

Bitfields are not one of C's shining points.  There is *NO* guarantee in
what order bitfields are put within a structure - it's *NOT* necessarily
the same as the byte order of the machine, and it's *ESPECIALLY* not
guaranteed to be correlated with the value of the LBL_ALIGN definition
(that definition has to do with whether unaligned accesses are supported
by the hardware).  In addition, even if they're declared as unsigned,
that doesn't mean they're guaranteed to *be* unsigned.  Don't use them.

Unaligned accesses are not guaranteed to work, and fields in packets are
not guaranteed to be naturally aligned.  Use the EXTRACT_nBITS() macros.

__attribute((packed))__ is a GCCism, and is not guaranteed to be
supported by all compilers with which tcpdump can be compiled.  Make
integral fields > 1 byte arrays of u_int8_t's (which also lets us avoid
the & in the EXTRACT_nBITS() macros).

Some systems don't define the PRI[doux]16 and PRI[doux]32 macros, and
others define them infelicitously (i.e., for PRI[doux]32, with an "l";
our 32-bit integer types are *not* longs, as we don't care about
16-bit-"int" platforms).
mptcp.h
print-mptcp.c