[PATCH] Re: bug in socket.h (and maybe many other kernel headerfiles)

Sean Hunter (sean@uncarved.co.uk)
Mon, 20 Sep 1999 15:00:14 +0100


On Fri, Sep 17, 1999 at 06:17:43PM +0100, Sean Hunter wrote:
> On Fri, Sep 17, 1999 at 11:48:34AM +0200, Dipl.-Ing. Uwe Koloska wrote:
> > Hello,
> >
> > I am not on this list by post by told so in REPORTING-BUGS.
> >
> > By installing kde-1.1.2 with gcc-2.95.1 I noticed a wrong declaration in
> > /usr/incluce/linux/socket.h:109
> >
> > ANSI C++ forbids implicit conversion from `void *' in return
> >
> > The right ANSI way to do it is to return a literal "0".
> >
> > By taking a quick glance on the other headerfiles there are many places that
> > uses NULL without explicit conversion.
> >
> > Maybe (adhearing to ANSI???) NULL has to be defined "0" and not (void*) ...
>
> Why are you compiling kernel headers with a c++ compiler? The kernel
> headers don't work in c++.

Does this patch fix your problem? BTW, to the powers-that-be: all I'm
doing is an explicit cast. Since I see this elsewhere in the same
file (NULL with an explicit cast), I assume this is acceptable. Is
it? I'm happy to look for this problem elsewhere in the kernel
headers if people think its worthwhile.

Sean

--- socket.h Mon Dec 28 06:18:28 1998
+++ /tmp/socket.h Mon Sep 20 14:56:47 1999
@@ -106,7 +106,7 @@

__ptr = (struct cmsghdr*)(((unsigned char *) __cmsg) + CMSG_ALIGN(__cmsg->cmsg_len));
if ((unsigned long)((char*)(__ptr+1) - (char *) __ctl) > __size)
- return NULL;
+ return (struct cmsghdr *)NULL;

return __ptr;
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/