Subject: Re: [PATCH v2 net-next] net: filter: export pkt_type_offset() helper

From: Hannes Frederic Sowa <[email-masked]>
Date: Thu, 04 Sep 2014 16:33:53 +0200

On Do, 2014-09-04 at 07:32 -0700, Eric Dumazet wrote:
> On Thu, 2014-09-04 at 14:23 +0000, David Laight wrote:
> > From: Eric Dumazet
> > > On Thu, 2014-09-04 at 15:40 +0200, Hannes Frederic Sowa wrote:
> > > 
> > > > The type does not matter at all. Actually I wanted to use an empty
> > > > struct but was afraid it might not work on older compilers and didn't
> > > > want to check that with each version.
> > > 
> > > 
> > > It matters. Really.
> > > 
> > > $ cat try.c
> > > #include <stdio.h>
> > > 
> > > struct S_int {
> > > 	char a;
> > > 	int offset[0];
> > > 	char b:1;
> > > };
> > > 
> > > struct S_char {
> > > 	char a;
> > > 	char offset[0];
> > > 	char b:1;
> > > };
> > 
> > Those are also both illegal C, zero sized arrays aren't allowed.
> > 
> > 	David
> 
> 
> This does not matter, we already use such constructs in the kernel.
> 
> Take a look at kmemcheck_bitfield_begin() for example.

Which btw. also uses int, which might change alignment of structures.