[lkml]   [1996]   [Dec]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: Socket header file

>Richard Gooch <rgooch@atnf.CSIRO.AU>
> Alan Modra writes:
> >
> > > (Richard B. Johnson)
> > > /usr/include/linux/socket.h: unsigned char cmsg_data[0];
> > > This should probably be:
> > > unsigned char *cmsg_data;
> >
> > No, definitely not. It's correct as it is. The structure is
> > dynamically allocated with cmsg_data[] a variable length array.
> I have complained to Linus about this a few times before, with no
> response. The problem with the above construct is that you cannot
> compile with gcc -Wall -pedantic-errors

Glad to see that you like to have your code portable. Linus may
accept a fix rather than just a complaint. No, come to think of it,
the person you should talk to is Alan Cox, since he's the network code

One fix would be to zap cmsg_data[0] from struct cmsghdr, change the
CMSG_DATA define to
#define CMSG_DATA(cmsg) ((unsigned char *)(cmsg) + sizeof(struct cmsghdr))
and fix kernel code referencing cmsg_data. In fact, the CMSG_DATA
macro should be used in the kernel anyway. Shouldn't take more than
10 minutes :-)

> Note that I'm referring to compiling *user code*, not kernel
> code. Does this particular structure have to be visible outside the
> kernel? If not, can someone please put an #ifdef around it?
> If this structure needs to be visible outside the kernel, then this
> structure needs to be reconsidered. It is really *extremely annoying*
> to have to edit the file whenever I download a new kernel, just so I
> can compile my userland networking code.

 \ /
  Last update: 2005-03-22 13:38    [W:0.045 / U:0.704 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site