[lkml]   [2008]   [Nov]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [PATCH 03/18 ver2] libosd: OSDv1 Headers
On Sun, 9 November 2008 16:52:36 +0200, Boaz Harrosh wrote:
> +struct osdv1_cdb {
> + struct osd_cdb_head h;
> + u8 caps[OSDv1_CAP_LEN];
> + struct osd_security_parameters sec_params;
> +} __packed;

__packed can result in slow code being generated. But removing the
attribute can lead to bugs on other architectures. F.e. the size of
the structure below is different for i386 and x86_64.

struct foo {
u64 bar;
u32 baz;

My personal solution is to use this little macro and then just follow
every structure defition with a size check.

#define SIZE_CHECK(type, size) \
static inline void check_##type(void) \
{ \
BUILD_BUG_ON(sizeof(struct type) != (size)); \
struct foo {
u64 bar;
u32 baz;

SIZE_CHECK(foo, 12);

The above would not compile on x86_64 and clearly indicate a missing
__packed. In other cases the attribute can be removed.


Invincibility is in oneself, vulnerability is in the opponent.
-- Sun Tzu
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2008-11-09 18:49    [W:0.527 / U:7.372 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site