[splint-discuss] splint lib problem?

lw lswhbcb at hotmail.com
Sat Jul 7 20:53:15 PDT 2007


I am a new to splint. i lint clean my project with the includes header.
#include <sys/socket.h>#include <errno.h>#include <fcntl.h>#include <math.h>#include <memory.h>#include <netdb.h>#include <setjmp.h>#include <signal.h>#include <stdio.h>#include <stdlib.h>#include <string.h>#include <syslog.h>#include <termio.h>#include <time.h>#include <unistd.h>#include <ctype.h>#include <assert.h>#include <net/if.h>#include <net/if_arp.h>#include <netinet/in.h>#include <netinet/ip.h>#include <netinet/ip_icmp.h>#include <arpa/inet.h>#include <sys/param.h>#include <sys/ioctl.h>#include <sys/io.h>#include <sys/ipc.h>#include <sys/msg.h>#include <sys/sem.h>#include <sys/shm.h>#include <sys/select.h>#include <sys/stat.h>#include <sys/time.h>#include <sys/timeb.h>#include <sys/types.h>#include <sys/wait.h>
================================================================>>>> i use posixlib flag with splint. splint outputs:
src/pub_inet.c:26:17: Unrecognized identifier: socket Identifier used in code has not been declared. (Use -unrecog to in bit warning) src/pub_inet.c:26:26: Unrecognized identifier: AF_INET src/pub_inet.c:26:35: Unrecognized identifier: SOCK_DGRAM src/pub_inet.c:29:25: Unrecognized identifier: caddr_t ================================================================>>>>
if using unixlib, splint outputs:
src/pub_inet.c: (in function GetNetIfInfo)src/pub_inet.c:30:27: Unrecognized identifier: SIOCGIFCONF  Identifier used in code has not been declared. (Use -unrecog to inhibit  warning)src/pub_inet.c:38:29: Unrecognized identifier: SIOCGIFFLAGSsrc/pub_inet.c:39:69: Unrecognized identifier: IFF_UPsrc/pub_inet.c:40:37: Unrecognized identifier: SIOCGIFADDRsrc/pub_inet.c: (in function GetLocalIP)src/pub_inet.c:61:12: Unsafe in multithreaded applications, use gethostbyname_r                         instead: gethostbyname  Non-reentrant function should not be used in multithreaded code. (Use  -multithreaded to inhibit warning)src/pub_inet.c:65:47: Arrow access from possibly null pointer host:                         host->h_addr_list  A possibly null pointer is dereferenced.  Value is either the result of a  function which may return null (in which case, code should check it is not  null), or a global, parameter or structure field declared with the null  qualifier. (Use -nullderef to inhibit warning)   src/pub_inet.c:61:12: Storage host may become nullsrc/pub_inet.c: (in function IcmpCheckSum)src/pub_inet.c:96:13: Left operand of >> may be negative (int): sum >> 16  The left operand to a shift operator may be negative (behavior is  implementation-defined). (Use -shiftimplementation to inhibit warning)src/pub_inet.c:97:14: Left operand of >> may be negative (int): sum >> 16src/pub_inet.c: (in function IcmpPacking)src/pub_inet.c:111:23: Unrecognized identifier: ICMP_ECHOsrc/pub_inet.c: (in function IcmpUnPack)src/pub_inet.c:156:31: Unrecognized identifier: ICMP_ECHOREPLYsrc/pub_inet.c: (in function IcmpRecv)src/pub_inet.c:214:16: Variable errno shadows outer declaration  An outer declaration is shadowed by the local declaration. (Use -shadow to  inhibit warning)   load file unix.lcd: Specification of errno: intsrc/pub_inet.c: (in function PingInit)src/pub_inet.c:244:29: Unrecognized identifier: getprotobynamesrc/pub_inet.c:244:12: Implicitly only storage pIS->pProtoent (type struct    protoent *) not released before assig
nment:    pIS->pProtoent = getprotobyname("icmp")  A memory leak has been detected. Only-qualified storage is not released  before the last reference to it is lost. (Use -mustfreeonly to inhibit  warning)src/pub_inet.c:256:2: Path with no return in function declared to return int  There is a path through a function declared to return a value on which there  is no return statement. This means the execution may fall through without  returning a meaningful result to the caller. (Use -noret to inhibit warning)src/pub_inet.c: (in function PingStart)src/pub_inet.c:274:10: Comparison of unsigned value involving zero:    (pIS->wSockfd = socket(AF_INET, SOCK_RAW, pIS->pProtoent->p_proto)) < 0  An unsigned value is used in a comparison with zero in a way that is either a  bug or confusing. (Use -unsignedcompare to inhibit warning)src/pub_inet.c:289:17: Unrecognized identifier: inet_addrsrc/pub_inet.c:290:23: Unrecognized identifier: INADDR_NONEsrc/pub_inet.c:292:24: Unsafe in multithreaded applications, use                          gethostbyname_r instead: gethostbynamesrc/pub_inet.c:311:2: Path with no return in function declared to return intsrc/pub_inet.c: (in function PingTimer)src/pub_inet.c:340:2: Path with no return in function declared to return int
Splinting: pub_log.c                     please wait ...src/pub_log.c: (in function TxtColor)src/pub_log.c:76:27: Possibly null storage p passed as non-null param:                        strcpy (..., p)  A possibly null pointer is passed as a parameter corresponding to a formal  parameter with no /*@null@*/ annotation.  If NULL may be used for this  parameter, add a /*@null@*/ annotation to the function parameter declaration.  (Use -nullpass to inhibit warning)   src/pub_log.c:65:18: Storage p may become null
================================================================>>>>if using +nolib +nof -warnposix +load /usr/share/splint/lib/unixstrict.lcd ,splint outputs:
src/pub_inet.c: (in function GetNetIfInfo)src/pub_inet.c:26:17: Called procedure socket may access global errno  A checked global variable is used in the function, but not listed in its  globals clause. By default, only globals specified in .lcl files are checked.  To check all globals, use +allglobals. To check globals selectively use  /*@checked@*/ in the global declaration. (Use -globs to inhibit warning)src/pub_inet.c:30:27: Unrecognized identifier: SIOCGIFCONF  Identifier used in code has not been declared. (Use -unrecog to inhibit  warning)src/pub_inet.c:30:15: Called procedure ioctl may access global errnosrc/pub_inet.c:38:29: Unrecognized identifier: SIOCGIFFLAGSsrc/pub_inet.c:38:17: Called procedure ioctl may access global errnosrc/pub_inet.c:39:69: Unrecognized identifier: IFF_UPsrc/pub_inet.c:40:37: Unrecognized identifier: SIOCGIFADDRsrc/pub_inet.c:40:25: Called procedure ioctl may access global errnosrc/pub_inet.c:50:5: Called procedure close may access global errnosrc/pub_inet.c: (in function GetLocalIP)src/pub_inet.c:61:12: Unsafe in multithreaded applications, use gethostbyname_r                         instead: gethostbyname  Non-reentrant function should not be used in multithreaded code. (Use  -multithreaded to inhibit warning)src/pub_inet.c:65:47: Arrow access from possibly null pointer host:                         host->h_addr_list  A possibly null pointer is dereferenced.  Value is either the result of a  function which may return null (in which case, code should check it is not  null), or a global, parameter or structure field declared with the null  qualifier. (Use -nullderef to inhibit warning)   src/pub_inet.c:61:12: Storage host may become nullsrc/pub_inet.c: (in function IcmpCheckSum)src/pub_inet.c:96:13: Left operand of >> may be negative (int): sum >> 16  The left operand to a shift operator may be negative (behavior is  implementation-defined). (Use -shiftimplementation to inhibit warning)src/pub_inet.c:97:14: Left operand of >> may be negative (int): sum >> 16src/pub_inet.c: (in 
function IcmpPacking)src/pub_inet.c:111:23: Unrecognized identifier: ICMP_ECHOsrc/pub_inet.c:120:5: Called procedure gettimeofday may access global errnosrc/pub_inet.c: (in function IcmpUnPack)src/pub_inet.c:137:5: Called procedure gettimeofday may access global errnosrc/pub_inet.c:156:31: Unrecognized identifier: ICMP_ECHOREPLYsrc/pub_inet.c: (in function IcmpStatis)src/pub_inet.c:182:5: Called procedure close may access global errnosrc/pub_inet.c: (in function IcmpSend)src/pub_inet.c:197:14: Called procedure sendto may access global errnosrc/pub_inet.c:201:13: Called procedure perror may access global errnosrc/pub_inet.c: (in function IcmpRecv)src/pub_inet.c:214:16: Variable errno shadows outer declaration  An outer declaration is shadowed by the local declaration. (Use -shadow to  inhibit warning)   load file /usr/share/splint/lib/unixstrict.lcd: Specification of errno: intsrc/pub_inet.c:220:16: Called procedure recvfrom may access global errnosrc/pub_inet.c:228:13: Called procedure perror may access global errnosrc/pub_inet.c: (in function PingInit)src/pub_inet.c:244:29: Unrecognized identifier: getprotobynamesrc/pub_inet.c:244:12: Implicitly only storage pIS->pProtoent (type struct    protoent *) not released before assignment:    pIS->pProtoent = getprotobyname("icmp")  A memory leak has been detected. Only-qualified storage is not released  before the last reference to it is lost. (Use -mustfreeonly to inhibit  warning)src/pub_inet.c:246:9: Called procedure perror may access global errnosrc/pub_inet.c:251:5: Called procedure setuid may access global errnosrc/pub_inet.c:256:2: Path with no return in function declared to return int  There is a path through a function declared to return a value on which there  is no return statement. This means the execution may fall through without  returning a meaningful result to the caller. (Use -noret to inhibit warning)src/pub_inet.c: (in function PingStart)src/pub_inet.c:275:12: Called procedure socket may access global errnosrc/pub_inet.c:274:10: Comparison of unsign
ed value involving zero:    (pIS->wSockfd = socket(AF_INET, SOCK_RAW, pIS->pProtoent->p_proto)) < 0  An unsigned value is used in a comparison with zero in a way that is either a  bug or confusing. (Use -unsignedcompare to inhibit warning)src/pub_inet.c:277:9: Called procedure perror may access global errnosrc/pub_inet.c:283:5: Called procedure setsockopt may access global errnosrc/pub_inet.c:289:17: Unrecognized identifier: inet_addrsrc/pub_inet.c:290:23: Unrecognized identifier: INADDR_NONEsrc/pub_inet.c:292:24: Unsafe in multithreaded applications, use                          gethostbyname_r instead: gethostbynamesrc/pub_inet.c:294:13: Called procedure perror may access global errnosrc/pub_inet.c:311:2: Path with no return in function declared to return intsrc/pub_inet.c: (in function PingTimer)src/pub_inet.c:340:2: Path with no return in function declared to return int
Splinting: pub_log.c                     please wait ...src/pub_log.c: (in function TxtColor)src/pub_log.c:76:27: Possibly null storage p passed as non-null param:                        strcpy (..., p)  A possibly null pointer is passed as a parameter corresponding to a formal  parameter with no /*@null@*/ annotation.  If NULL may be used for this  parameter, add a /*@null@*/ annotation to the function parameter declaration.  (Use -nullpass to inhibit warning)   src/pub_log.c:65:18: Storage p may become null
Splinting: pub_malloc.c                          please wait ...Splinting: pub_netcap.c                          please wait ...src/pub_netcap.c: (in function NcGetSocket)src/pub_netcap.c:74:20: Called procedure socket may access global errno  A checked global variable is used in the function, but not listed in its  globals clause. By default, only globals specified in .lcl files are checked.  To check all globals, use +allglobals. To check globals selectively use  /*@checked@*/ in the global declaration. (Use -globs to inhibit warning)src/pub_netcap.c:76:9: Called procedure perror may access global errnosrc/pub_netcap.c:80:5: Called procedure setsockopt may access global errnosrc/pub_netcap.c:82:20: Unrecognized identifier: FIONBIO  Identifier used in code has not been declared. (Use -unrecog to inhibit  warning)src/pub_netcap.c:82:5: Called procedure ioctl may access global errnosrc/pub_netcap.c: (in function NcInit)src/pub_netcap.c:101:18: Unrecognized identifier: inet_addrsrc/pub_netcap.c: (in function NcStop)src/pub_netcap.c:118:5: Called procedure shutdown may access global errnosrc/pub_netcap.c: (in function NcMtp3Send)src/pub_netcap.c:269:5: Called procedure sendto may access global errnosrc/pub_netcap.c: (in function NcSccpSend)src/pub_netcap.c:332:10: Called procedure sendto may access global errnosrc/pub_netcap.c:336:9: Called procedure perror may access global errno
================================================================>>>>if i make a fake file (copy from /usr/include/sys/socket.h) in -I./splint ,  ignore the file with /*@ignore@*/ /*@end@*/ inthe "socket.h " [[[[ I do not know why the flag "/*@ignore@*/" is not acted well.!!!???  ]]]]:
includes.h:
....ifdef S_SPLINT_S    //#include </usr/share/splint/lib/unix.h>   #include "./splint/socket.h"   //#include <sys/socket.h>#else    #include <sys/socket.h>#endif...
the splint outputs:
src/include/splint/socket.h:49:5: Parse Error: Non-function declaration:    __BEGIN_DECLS : int. (For help on parse errors, see splint -help    parseerrors.)
 
 
=====================================================>>>>i have on ideas. Who can help me fix the problem ? thanks a lot.  
MSN:lswhbcb at hotmail.com
 
 
_________________________________________________________________
通过 Live.com 查看资讯、娱乐信息和您关心的其他信息!
http://www.live.com/getstarted.aspx
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.cs.Virginia.EDU/pipermail/splint-discuss/attachments/20070708/41ef5d7b/attachment-0001.html


More information about the splint-discuss mailing list