<html>
<head>
<style>
P
{
margin:0px;
padding:0px
}
body
{
FONT-SIZE: 9pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body>
I am a new to splint. i lint clean my project with the includes header.<BR>
#include <sys/socket.h><BR>#include <errno.h><BR>#include <fcntl.h><BR>#include <math.h><BR>#include <memory.h><BR>#include <netdb.h><BR>#include <setjmp.h><BR>#include <signal.h><BR>#include <stdio.h><BR>#include <stdlib.h><BR>#include <string.h><BR>#include <syslog.h><BR>#include <termio.h><BR>#include <time.h><BR>#include <unistd.h><BR>#include <ctype.h><BR>#include <assert.h><BR>#include <net/if.h><BR>#include <net/if_arp.h><BR>#include <netinet/in.h><BR>#include <netinet/ip.h><BR>#include <netinet/ip_icmp.h><BR>#include <arpa/inet.h><BR>#include <sys/param.h><BR>#include <sys/ioctl.h><BR>#include <sys/io.h><BR>#include <sys/ipc.h><BR>#include <sys/msg.h><BR>#include <sys/sem.h><BR>#include <sys/shm.h><BR>#include <sys/select.h><BR>#include <sys/stat.h><BR>#include <sys/time.h><BR>#include <sys/timeb.h><BR>#include <sys/types.h><BR>#include <sys/wait.h><BR>
================================================================>>>><BR> i use posixlib flag with splint. splint outputs:<BR>
src/pub_inet.c:26:17: Unrecognized identifier: socket Identifier used in code has not been declared. (Use -unrecog to in bit warning) <BR>src/pub_inet.c:26:26: Unrecognized identifier: AF_INET <BR>src/pub_inet.c:26:35: Unrecognized identifier: SOCK_DGRAM <BR>src/pub_inet.c:29:25: Unrecognized identifier: caddr_t <BR>================================================================>>>><BR>
if using unixlib, splint outputs:<BR>
src/pub_inet.c: (in function GetNetIfInfo)<BR>src/pub_inet.c:30:27: Unrecognized identifier: SIOCGIFCONF<BR> Identifier used in code has not been declared. (Use -unrecog to inhibit<BR> warning)<BR>src/pub_inet.c:38:29: Unrecognized identifier: SIOCGIFFLAGS<BR>src/pub_inet.c:39:69: Unrecognized identifier: IFF_UP<BR>src/pub_inet.c:40:37: Unrecognized identifier: SIOCGIFADDR<BR>src/pub_inet.c: (in function GetLocalIP)<BR>src/pub_inet.c:61:12: Unsafe in multithreaded applications, use gethostbyname_r<BR> instead: gethostbyname<BR> Non-reentrant function should not be used in multithreaded code. (Use<BR> -multithreaded to inhibit warning)<BR>src/pub_inet.c:65:47: Arrow access from possibly null pointer host:<BR> host->h_addr_list<BR> A possibly null pointer is dereferenced. Value is either the result of a<BR> function which may return null (in which case, code should check it is not<BR> null), or a global, parameter or structure field declared with the null<BR> qualifier. (Use -nullderef to inhibit warning)<BR> src/pub_inet.c:61:12: Storage host may become null<BR>src/pub_inet.c: (in function IcmpCheckSum)<BR>src/pub_inet.c:96:13: Left operand of >> may be negative (int): sum >> 16<BR> The left operand to a shift operator may be negative (behavior is<BR> implementation-defined). (Use -shiftimplementation to inhibit warning)<BR>src/pub_inet.c:97:14: Left operand of >> may be negative (int): sum >> 16<BR>src/pub_inet.c: (in function IcmpPacking)<BR>src/pub_inet.c:111:23: Unrecognized identifier: ICMP_ECHO<BR>src/pub_inet.c: (in function IcmpUnPack)<BR>src/pub_inet.c:156:31: Unrecognized identifier: ICMP_ECHOREPLY<BR>src/pub_inet.c:
(in function IcmpRecv)<BR>src/pub_inet.c:214:16: Variable errno shadows outer declaration<BR> An outer declaration is shadowed by the local declaration. (Use -shadow to<BR> inhibit warning)<BR> load file unix.lcd: Specification of errno: int<BR>src/pub_inet.c: (in function PingInit)<BR>src/pub_inet.c:244:29: Unrecognized identifier: getprotobyname<BR>src/pub_inet.c:244:12: Implicitly only storage pIS->pProtoent (type struct<BR> protoent *) not released before assignment:<BR> pIS->pProtoent = getprotobyname("icmp")<BR> A memory leak has been detected. Only-qualified storage is not released<BR> before the last reference to it is lost. (Use -mustfreeonly to inhibit<BR> warning)<BR>src/pub_inet.c:256:2: Path with no return in function declared to return int<BR> There is a path through a function declared to return a value on which there<BR> is no return statement. This means the execution may fall through without<BR> returning a meaningful result to the caller. (Use -noret to inhibit warning)<BR>src/pub_inet.c: (in function PingStart)<BR>src/pub_inet.c:274:10: Comparison of unsigned value involving zero:<BR> (pIS->wSockfd = socket(AF_INET, SOCK_RAW, pIS->pProtoent->p_proto)) < 0<BR> An unsigned value is used in a comparison with zero in a way that is either a<BR> bug or confusing. (Use -unsignedcompare to inhibit warning)<BR>src/pub_inet.c:289:17: Unrecognized identifier: inet_addr<BR>src/pub_inet.c:290:23: Unrecognized identifier: INADDR_NONE<BR>src/pub_inet.c:292:24: Unsafe in multithreaded applications, use<BR> gethostbyname_r instead: gethostbyname<BR>src/pub_inet.c:311:2: Path with no return in function declared to return int<BR>src/pub_inet.c: (in function PingTimer)<BR>src/pub_inet.c:340:2: Path with no return in functio
n declared to return int<BR>
Splinting: pub_log.c please wait ...<BR>src/pub_log.c: (in function TxtColor)<BR>src/pub_log.c:76:27: Possibly null storage p passed as non-null param:<BR> strcpy (..., p)<BR> A possibly null pointer is passed as a parameter corresponding to a formal<BR> parameter with no <A>/*@null@*/</A> annotation. If NULL may be used for this<BR> parameter, add a <A>/*@null@*/</A> annotation to the function parameter declaration.<BR> (Use -nullpass to inhibit warning)<BR> src/pub_log.c:65:18: Storage p may become null<BR>
================================================================>>>><BR>if using +nolib +nof -warnposix +load /usr/share/splint/lib/unixstrict.lcd ,splint outputs:<BR>
src/pub_inet.c: (in function GetNetIfInfo)<BR>src/pub_inet.c:26:17: Called procedure socket may access global errno<BR> A checked global variable is used in the function, but not listed in its<BR> globals clause. By default, only globals specified in .lcl files are checked.<BR> To check all globals, use +allglobals. To check globals selectively use<BR> <A>/*@checked@*/</A> in the global declaration. (Use -globs to inhibit warning)<BR>src/pub_inet.c:30:27: Unrecognized identifier: SIOCGIFCONF<BR> Identifier used in code has not been declared. (Use -unrecog to inhibit<BR> warning)<BR>src/pub_inet.c:30:15: Called procedure ioctl may access global errno<BR>src/pub_inet.c:38:29: Unrecognized identifier: SIOCGIFFLAGS<BR>src/pub_inet.c:38:17: Called procedure ioctl may access global errno<BR>src/pub_inet.c:39:69: Unrecognized identifier: IFF_UP<BR>src/pub_inet.c:40:37: Unrecognized identifier: SIOCGIFADDR<BR>src/pub_inet.c:40:25: Called procedure ioctl may access global errno<BR>src/pub_inet.c:50:5: Called procedure close may access global errno<BR>src/pub_inet.c: (in function GetLocalIP)<BR>src/pub_inet.c:61:12: Unsafe in multithreaded applications, use gethostbyname_r<BR> instead: gethostbyname<BR> Non-reentrant function should not be used in multithreaded code. (Use<BR> -multithreaded to inhibit warning)<BR>src/pub_inet.c:65:47: Arrow access from possibly null pointer host:<BR> host->h_addr_list<BR> A possibly null pointer is dereferenced. Value is either the result of a<BR> function which may return null (in which case, code should check it is not<BR> null), or a global, parameter or structure field declared with the null<BR> qualifier. (Use -nullderef
to inhibit warning)<BR> src/pub_inet.c:61:12: Storage host may become null<BR>src/pub_inet.c: (in function IcmpCheckSum)<BR>src/pub_inet.c:96:13: Left operand of >> may be negative (int): sum >> 16<BR> The left operand to a shift operator may be negative (behavior is<BR> implementation-defined). (Use -shiftimplementation to inhibit warning)<BR>src/pub_inet.c:97:14: Left operand of >> may be negative (int): sum >> 16<BR>src/pub_inet.c: (in function IcmpPacking)<BR>src/pub_inet.c:111:23: Unrecognized identifier: ICMP_ECHO<BR>src/pub_inet.c:120:5: Called procedure gettimeofday may access global errno<BR>src/pub_inet.c: (in function IcmpUnPack)<BR>src/pub_inet.c:137:5: Called procedure gettimeofday may access global errno<BR>src/pub_inet.c:156:31: Unrecognized identifier: ICMP_ECHOREPLY<BR>src/pub_inet.c: (in function IcmpStatis)<BR>src/pub_inet.c:182:5: Called procedure close may access global errno<BR>src/pub_inet.c: (in function IcmpSend)<BR>src/pub_inet.c:197:14: Called procedure sendto may access global errno<BR>src/pub_inet.c:201:13: Called procedure perror may access global errno<BR>src/pub_inet.c: (in function IcmpRecv)<BR>src/pub_inet.c:214:16: Variable errno shadows outer declaration<BR> An outer declaration is shadowed by the local declaration. (Use -shadow to<BR> inhibit warning)<BR> load file /usr/share/splint/lib/unixstrict.lcd: Specification of errno: int<BR>src/pub_inet.c:220:16: Called procedure recvfrom may access global errno<BR>src/pub_inet.c:228:13: Called procedure perror may access global errno<BR>src/pub_inet.c: (in function PingInit)<BR>src/pub_inet.c:244:29: Unrecognized identifier: getprotobyname<BR>src/pub_inet.c:244:12: Implicitly only storage pIS->pProtoent (type struct<BR> protoent *) not released before assignment:<BR> pIS->pProtoent = getprotobyname("icmp")<BR> A memory leak has been detected. Only-qualified storage is not released<BR> before the last referenc
e to it is lost. (Use -mustfreeonly to inhibit<BR> warning)<BR>src/pub_inet.c:246:9: Called procedure perror may access global errno<BR>src/pub_inet.c:251:5: Called procedure setuid may access global errno<BR>src/pub_inet.c:256:2: Path with no return in function declared to return int<BR> There is a path through a function declared to return a value on which there<BR> is no return statement. This means the execution may fall through without<BR> returning a meaningful result to the caller. (Use -noret to inhibit warning)<BR>src/pub_inet.c: (in function PingStart)<BR>src/pub_inet.c:275:12: Called procedure socket may access global errno<BR>src/pub_inet.c:274:10: Comparison of unsigned value involving zero:<BR> (pIS->wSockfd = socket(AF_INET, SOCK_RAW, pIS->pProtoent->p_proto)) < 0<BR> An unsigned value is used in a comparison with zero in a way that is either a<BR> bug or confusing. (Use -unsignedcompare to inhibit warning)<BR>src/pub_inet.c:277:9: Called procedure perror may access global errno<BR>src/pub_inet.c:283:5: Called procedure setsockopt may access global errno<BR>src/pub_inet.c:289:17: Unrecognized identifier: inet_addr<BR>src/pub_inet.c:290:23: Unrecognized identifier: INADDR_NONE<BR>src/pub_inet.c:292:24: Unsafe in multithreaded applications, use<BR> gethostbyname_r instead: gethostbyname<BR>src/pub_inet.c:294:13: Called procedure perror may access global errno<BR>src/pub_inet.c:311:2: Path with no return in function declared to return int<BR>src/pub_inet.c: (in function PingTimer)<BR>src/pub_inet.c:340:2: Path with no return in function declared to return int<BR>
Splinting: pub_log.c please wait ...<BR>src/pub_log.c: (in function TxtColor)<BR>src/pub_log.c:76:27: Possibly null storage p passed as non-null param:<BR> strcpy (..., p)<BR> A possibly null pointer is passed as a parameter corresponding to a formal<BR> parameter with no <A>/*@null@*/</A> annotation. If NULL may be used for this<BR> parameter, add a <A>/*@null@*/</A> annotation to the function parameter declaration.<BR> (Use -nullpass to inhibit warning)<BR> src/pub_log.c:65:18: Storage p may become null<BR>
Splinting: pub_malloc.c please wait ...<BR>Splinting: pub_netcap.c please wait ...<BR>src/pub_netcap.c: (in function NcGetSocket)<BR>src/pub_netcap.c:74:20: Called procedure socket may access global errno<BR> A checked global variable is used in the function, but not listed in its<BR> globals clause. By default, only globals specified in .lcl files are checked.<BR> To check all globals, use +allglobals. To check globals selectively use<BR> <A>/*@checked@*/</A> in the global declaration. (Use -globs to inhibit warning)<BR>src/pub_netcap.c:76:9: Called procedure perror may access global errno<BR>src/pub_netcap.c:80:5: Called procedure setsockopt may access global errno<BR>src/pub_netcap.c:82:20: Unrecognized identifier: FIONBIO<BR> Identifier used in code has not been declared. (Use -unrecog to inhibit<BR> warning)<BR>src/pub_netcap.c:82:5: Called procedure ioctl may access global errno<BR>src/pub_netcap.c: (in function NcInit)<BR>src/pub_netcap.c:101:18: Unrecognized identifier: inet_addr<BR>src/pub_netcap.c: (in function NcStop)<BR>src/pub_netcap.c:118:5: Called procedure shutdown may access global errno<BR>src/pub_netcap.c: (in function NcMtp3Send)<BR>src/pub_netcap.c:269:5: Called procedure sendto may access global errno<BR>src/pub_netcap.c: (in function NcSccpSend)<BR>src/pub_netcap.c:332:10: Called procedure sendto may access global errno<BR>src/pub_netcap.c:336:9: Called procedure perror may access global errno<BR>
<BR>================================================================>>>><BR>if i make a fake file (copy from /usr/include/sys/socket.h) in -I./splint , ignore the file with <A>/*@ignore@*/</A> <A>/*@end@*/</A> in<BR>the "socket.h " [[[[ I do not know why the flag "<A>/*@ignore@*/</A>" is not acted well.!!!??? ]]]]:<BR>
includes.h:<BR>
....<BR>ifdef S_SPLINT_S<BR> //#include </usr/share/splint/lib/unix.h><BR> #include "./splint/socket.h"<BR> //#include <sys/socket.h><BR>#else<BR> #include <sys/socket.h><BR>#endif<BR>...<BR>
the splint outputs:<BR>
src/include/splint/socket.h:49:5: Parse Error: Non-function declaration:<BR> __BEGIN_DECLS : int. (For help on parse errors, see splint -help<BR> parseerrors.)<BR>
<BR>
<BR>
=====================================================>>>><BR>i have on ideas. Who can help me fix the problem ? thanks a lot. <BR>
MSN:lswhbcb@hotmail.com<BR>
<BR>
<BR> <BR><br /><hr />通过 Windows Live Spaces 与朋友轻松共享您的生活。 <a href='http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=zh-cn' target='_new'>立即尝试!</a></body>
</html>