Opened 11 years ago

Closed 11 years ago

#2346 closed bug (fixed)

Some of headers are not self containing

Reported by: kaliber Owned by: axeld
Priority: normal Milestone: R1
Component: - General Version: R1/pre-alpha1
Keywords: Cc:
Blocked By: Blocking:
Has a Patch: no Platform: All

Description

Use following program to show defects:

#!/bin/sh

DIR="/boot/develop/headers/posix/"
for i in `find $DIR -name '*.h'`
do
	f=${i#$DIR}
	cat > test.c << EOF
#include <$f>
int main() { return 0; };
EOF
	echo "Testing $f"
	gcc test.c
done

Attachments (1)

fix-for-2346.patch (659 bytes ) - added by kaliber 11 years ago.

Download all attachments as: .zip

Change History (6)

comment:1 by scottmc, 11 years ago

Figured I'd run the test and post the results here.

test2346.sh > test2346.txt
In file included from /boot/home/test.c:1:
/boot/develop/headers/posix/arch/m68k/arch_setjmp.h:10: warning: #warning M68K: fix jmpbuf size
In file included from /boot/home/test.c:1:
/boot/develop/headers/posix/netinet/ip_icmp.h:71: field `idi_ip' has incomplete type
In file included from /boot/home/test.c:1:
/boot/develop/headers/posix/netinet/ip_var.h:51: field `ih_src' has incomplete type
/boot/develop/headers/posix/netinet/ip_var.h:52: field `ih_dst' has incomplete type
/boot/develop/headers/posix/netinet/ip_var.h:64: field `ipopt_dst' has incomplete type
/boot/develop/headers/posix/netinet/ip_var.h:77: `IP_MAX_MEMBERSHIPS' undeclared here (not in a function)
/boot/develop/headers/posix/netinet/ip_var.h:104: field `ipq_src' has incomplete type
/boot/develop/headers/posix/netinet/ip_var.h:104: field `ipq_dst' has incomplete type
In file included from /boot/home/test.c:1:
/boot/develop/headers/posix/regex.h:358: parse error before `size_t'
/boot/develop/headers/posix/regex.h:358: warning: no semicolon at end of struct or union
/boot/develop/headers/posix/regex.h:365: parse error before `:'
/boot/develop/headers/posix/regex.h:374: parse error before `:'
/boot/develop/headers/posix/regex.h:378: parse error before `:'
/boot/develop/headers/posix/regex.h:382: parse error before `:'
/boot/develop/headers/posix/regex.h:386: parse error before `:'
/boot/develop/headers/posix/regex.h:389: parse error before `:'
/boot/develop/headers/posix/regex.h:392: parse error before `:'
/boot/develop/headers/posix/regex.h:456: parse error before `size_t'
/boot/develop/headers/posix/regex.h:544: parse error before `size_t'
/boot/develop/headers/posix/regex.h:548: parse error before `regerror'
/boot/develop/headers/posix/regex.h:549: parse error before `size_t'
/boot/develop/headers/posix/regex.h:549: warning: data definition has no type or storage class
In file included from /boot/home/test.c:1:
/boot/develop/headers/posix/resolv.h:160: field `nsaddr_list' has incomplete type
/boot/develop/headers/posix/resolv.h:170: field `addr' has incomplete type
/boot/develop/headers/posix/resolv.h:194: field `sin' has incomplete type
In file included from /boot/home/test.c:1:
/boot/develop/headers/posix/stdio_post.h:14: #error "This file must be included from stdio.h!"
In file included from /boot/home/test.c:1:
/boot/develop/headers/posix/stdio_pre.h:8: #error "This file must be included from stdio.h!"

I then inserted an #include <sys/types.h> right before the #include <$f> and then reran the test and here's what I got:

~> test2346.sh > test2346.txt
In file included from /boot/home/test.c:2:
/boot/develop/headers/posix/arch/m68k/arch_setjmp.h:10: warning: #warning M68K: fix jmpbuf size
In file included from /boot/home/test.c:2:
/boot/develop/headers/posix/netinet/ip_icmp.h:71: field `idi_ip' has incomplete type
In file included from /boot/home/test.c:2:
/boot/develop/headers/posix/netinet/ip_var.h:51: field `ih_src' has incomplete type
/boot/develop/headers/posix/netinet/ip_var.h:52: field `ih_dst' has incomplete type
/boot/develop/headers/posix/netinet/ip_var.h:64: field `ipopt_dst' has incomplete type
/boot/develop/headers/posix/netinet/ip_var.h:77: `IP_MAX_MEMBERSHIPS' undeclared here (not in a function)
/boot/develop/headers/posix/netinet/ip_var.h:104: field `ipq_src' has incomplete type
/boot/develop/headers/posix/netinet/ip_var.h:104: field `ipq_dst' has incomplete type
In file included from /boot/home/test.c:2:
/boot/develop/headers/posix/resolv.h:160: field `nsaddr_list' has incomplete type
/boot/develop/headers/posix/resolv.h:170: field `addr' has incomplete type
/boot/develop/headers/posix/resolv.h:194: field `sin' has incomplete type
In file included from /boot/home/test.c:2:
/boot/develop/headers/posix/stdio_post.h:14: #error "This file must be included from stdio.h!"
In file included from /boot/home/test.c:2:
/boot/develop/headers/posix/stdio_pre.h:8: #error "This file must be included from stdio.h!"
~>     

So it would seem that m68k/arch_setjmp.h, netinet/ip_icmp.h, netinet/ip_var.h, resolv.h may need fixes, or they also have a required include missing. In the regex.h file it states that <sys/types.h> is required first.

by kaliber, 11 years ago

Attachment: fix-for-2346.patch added

comment:2 by kaliber, 11 years ago

I've created a complete patch. I skip regex.h fix due to the comment: /* POSIX says that <sys/types.h> must be included (by the caller) before

<regex.h>. */

comment:3 by axeld, 11 years ago

Patch applied in hrev26841. I guess this is only a part of this ticket?

comment:4 by kaliber, 11 years ago

In my opinion the patch is a complete. To be sure check it using simple script included in the first comment.

comment:5 by axeld, 11 years ago

Resolution: fixed
Status: newclosed

I left resolv.h as is, and the rest looks fine, thanks!

Note: See TracTickets for help on using tickets.