Patchwork conntrackd: resolve a compiler error

login
register
mail settings
Submitter Jan Engelhardt
Date May 31, 2012, 12:03 p.m.
Message ID <1338465797-9797-2-git-send-email-jengelh@inai.de>
Download mbox | patch
Permalink /patch/162146/
State Not Applicable
Headers show

Comments

Jan Engelhardt - May 31, 2012, 12:03 p.m.
Observed with gcc-4.7/glibc-2.15 and conntrack-tools-1.2.1:

  CC     parse.o
parse.c: In function 'msg2ct':
parse.c:258:34: error: 'NULL' undeclared (first use in this function)
parse.c:258:34: note: each undeclared identifier is reported only once for each function it appears in
parse.c: In function 'msg2exp':
parse.c:438:16: error: 'NULL' undeclared (first use in this function)

NULL is in stdio.h.
---
 src/parse.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
Pablo Neira - May 31, 2012, 1:19 p.m.
Hi Jan,

On Thu, May 31, 2012 at 02:03:17PM +0200, Jan Engelhardt wrote:
> Observed with gcc-4.7/glibc-2.15 and conntrack-tools-1.2.1:
> 
>   CC     parse.o
> parse.c: In function 'msg2ct':
> parse.c:258:34: error: 'NULL' undeclared (first use in this function)
> parse.c:258:34: note: each undeclared identifier is reported only once for each function it appears in
> parse.c: In function 'msg2exp':
> parse.c:438:16: error: 'NULL' undeclared (first use in this function)

Similar patch was already applied.

http://git.netfilter.org/cgi-bin/gitweb.cgi?p=conntrack-tools.git;a=commit;h=d44489648c1a56d543a84bbebe455227bb25cf34

This was spotted a couple of days ago by Mandriva people.

Thanks anyway!
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Florian Westphal - May 31, 2012, 1:31 p.m.
Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> Hi Jan,
> 
> On Thu, May 31, 2012 at 02:03:17PM +0200, Jan Engelhardt wrote:
> > Observed with gcc-4.7/glibc-2.15 and conntrack-tools-1.2.1:
> > 
> >   CC     parse.o
> > parse.c: In function 'msg2ct':
> > parse.c:258:34: error: 'NULL' undeclared (first use in this function)
> > parse.c:258:34: note: each undeclared identifier is reported only once for each function it appears in
> > parse.c: In function 'msg2exp':
> > parse.c:438:16: error: 'NULL' undeclared (first use in this function)
> 
> Similar patch was already applied.
> 
> http://git.netfilter.org/cgi-bin/gitweb.cgi?p=conntrack-tools.git;a=commit;h=d44489648c1a56d543a84bbebe455227bb25cf34

NULL is defined in stddef.h, stdlib.h does not necessarily pull that
header in, too.

Jan, does conntrackd build when you replace the stdlib.h include with
stddef.h?
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Jan Engelhardt - May 31, 2012, 1:50 p.m.
On Thursday 2012-05-31 15:31, Florian Westphal wrote:
>> > 
>> >   CC     parse.o
>> > parse.c: In function 'msg2ct':
>> > parse.c:258:34: error: 'NULL' undeclared (first use in this function)
>> > parse.c:258:34: note: each undeclared identifier is reported only once for each function it appears in
>> > parse.c: In function 'msg2exp':
>> > parse.c:438:16: error: 'NULL' undeclared (first use in this function)
>> 
>> Similar patch was already applied.
>> 
>> http://git.netfilter.org/cgi-bin/gitweb.cgi?p=conntrack-tools.git;a=commit;h=d44489648c1a56d543a84bbebe455227bb25cf34
>
>NULL is defined in stddef.h, stdlib.h does not necessarily pull that
>header in, too.

I believe that the C standard defines that NULL has to become available
through (at least) stdio.h. Though wikipedia may not always be authoritative,
I will use it as an excuse now: http://en.wikipedia.org/wiki/Stdio.h

So if #include <stddef.h> makes NULL available, good for glibc, but it
may not satisfy certain implementations.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Pablo Neira - May 31, 2012, 2:15 p.m.
On Thu, May 31, 2012 at 03:50:11PM +0200, Jan Engelhardt wrote:
> 
> On Thursday 2012-05-31 15:31, Florian Westphal wrote:
> >> > 
> >> >   CC     parse.o
> >> > parse.c: In function 'msg2ct':
> >> > parse.c:258:34: error: 'NULL' undeclared (first use in this function)
> >> > parse.c:258:34: note: each undeclared identifier is reported only once for each function it appears in
> >> > parse.c: In function 'msg2exp':
> >> > parse.c:438:16: error: 'NULL' undeclared (first use in this function)
> >> 
> >> Similar patch was already applied.
> >> 
> >> http://git.netfilter.org/cgi-bin/gitweb.cgi?p=conntrack-tools.git;a=commit;h=d44489648c1a56d543a84bbebe455227bb25cf34
> >
> >NULL is defined in stddef.h, stdlib.h does not necessarily pull that
> >header in, too.
> 
> I believe that the C standard defines that NULL has to become available
> through (at least) stdio.h. Though wikipedia may not always be authoritative,
> I will use it as an excuse now: http://en.wikipedia.org/wiki/Stdio.h
> 
> So if #include <stddef.h> makes NULL available, good for glibc, but it
> may not satisfy certain implementations.

As soon the compilation works, I'll be happy to use the more precise
header. Send me one patch upon the current git HEAD, I'll take it.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/src/parse.c b/src/parse.c
index 1b83f81..391bf38 100644
--- a/src/parse.c
+++ b/src/parse.c
@@ -17,6 +17,7 @@ 
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#include <stdio.h>
 #include "network.h"
 
 #include <stdlib.h>