[splint-discuss] 'splint' and sys/types.h
Michael Wojcik
Michael.Wojcik at MicroFocus.com
Wed Oct 25 10:38:04 EDT 2006
> From: splint-discuss-bounces at cs.virginia.edu
> [mailto:splint-discuss-bounces at cs.virginia.edu] On Behalf Of
> Roman Mashak
> Sent: Wednesday, 25 October, 2006 02:36
>
> Snippet of simple code I'm running on RedHat 8.0
> (glibc-2.2.93) is the following:
>
> #include <stdio.h>
> #include <stdlib.h>
> #include <sys/types.h>
> #include <netinet/ip.h>
>
> #define BUFSIZE 1500
>
> int main(void)
> {
> ...
>
> return 0;
> }
>
> And splint chokes on the line including netinet/ip.h:
>
> %splint +posixlib foo.c
> Splint 3.1.1 --- 08 Mar 2004
>
> usr/include/netinet/ip.h:31:13: Parse Error. (For help on parse
errors, see
> splint -help parseerrors.)
> *** Cannot continue.
>
> The line 'splint' stuck on is:
>
> u_int8_t len;
So Splint hasn't seen a definition of u_int8_t. Without seeing your
development environment, I can't tell where that's supposed to be
defined, but presumably it's in one of the headers that Splint is
skipping because it's a "standard" header that Splint has predefined.
(The standard headers here include both those defined by ISO C90 and
whatever version of POSIX Splint was last updated for - 1995, maybe.)
> I followed documentation suggestions and enclosed the code with the
lines:
>
> /*@-skipposixheaders@*/
> #include <sys/types.h>
> /*@=skipposixheaders@*/
> #include <netinet/ip.h>
>
> but it didn't help.
This told Splint to stop treating POSIX headers specially (ie, to parse
them as it does for normal headers) before including sys/types.h, and
then to revert to its previous setting after including it. (The
previous setting is to skip POSIX headers and use Splint's predefined
POSIX definitions, since you invoked Splint with +posixlib.)
If you're still getting the error, then u_int8_t was not defined by that
inclusion of sys/types.h. There are various possibilities:
- u_int8_t is not defined by sys/types.h, but by some other POSIX or ISO
header included by netinet/ip.h.
- sys/types.h was already included earlier in the program, possibly
included by stdio.h or stdlib.h, so the explicit inclusion in your
program is a no-op anyway.
- u_int8_t is only defined (by sys/types.h or whatever) if some token is
defined, and your Splint configuration doesn't define it. Make sure
that your Splint configuration includes all the predefined identifiers
that are set by your compiler. (See the gcc docs - there's some option
that dumps a list of the predefs, I believe.)
- There's a bug in Splint's handling of POSIX headers.
- Something else that I haven't thought of at the moment.
I'd start by checking for missing predefines in the Splint
configuration. If that doesn't reveal the problem, try pre-processing
the source with gcc (what's that - the -P option, maybe?) and finding
out just where u_int8_t actually gets defined for this program. Then
you'll know where to put your skipposixheaders annotations.
--
Michael Wojcik
Principal Software Systems Developer
Micro Focus
michael.wojcik at microfocus.com
9420 Key West Avenue
Rockville, MD 20850
What would you like Micro Focus to do for you? Contribute your view by
visiting
http://www.microfocus.com/CustomerInsight.asp
More information about the splint-discuss
mailing list