LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-06-2007, 04:49 AM   #1
lswhbcb
LQ Newbie
 
Registered: Apr 2007
Posts: 11

Rep: Reputation: 0
[need help]splint clean


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: SIOCGIFFLAGS
src/pub_inet.c:39:69: Unrecognized identifier: IFF_UP
src/pub_inet.c:40:37: Unrecognized identifier: SIOCGIFADDR
src/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 null
src/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 >> 16
src/pub_inet.c: (in function IcmpPacking)
src/pub_inet.c:111:23: Unrecognized identifier: ICMP_ECHO
src/pub_inet.c: (in function IcmpUnPack)
src/pub_inet.c:156:31: Unrecognized identifier: ICMP_ECHOREPLY
src/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: int
src/pub_inet.c: (in function PingInit)
src/pub_inet.c:244:29: Unrecognized identifier: getprotobyname
src/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: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_addr
src/pub_inet.c:290:23: Unrecognized identifier: INADDR_NONE
src/pub_inet.c:292:24: Unsafe in multithreaded applications, use
gethostbyname_r instead: gethostbyname
src/pub_inet.c:311:2: Path with no return in function declared to return int
src/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 errno
src/pub_inet.c:38:29: Unrecognized identifier: SIOCGIFFLAGS
src/pub_inet.c:38:17: Called procedure ioctl may access global errno
src/pub_inet.c:39:69: Unrecognized identifier: IFF_UP
src/pub_inet.c:40:37: Unrecognized identifier: SIOCGIFADDR
src/pub_inet.c:40:25: Called procedure ioctl may access global errno
src/pub_inet.c:50:5: Called procedure close may access global errno
src/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 null
src/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 >> 16
src/pub_inet.c: (in function IcmpPacking)
src/pub_inet.c:111:23: Unrecognized identifier: ICMP_ECHO
src/pub_inet.c:120:5: Called procedure gettimeofday may access global errno
src/pub_inet.c: (in function IcmpUnPack)
src/pub_inet.c:137:5: Called procedure gettimeofday may access global errno
src/pub_inet.c:156:31: Unrecognized identifier: ICMP_ECHOREPLY
src/pub_inet.c: (in function IcmpStatis)
src/pub_inet.c:182:5: Called procedure close may access global errno
src/pub_inet.c: (in function IcmpSend)
src/pub_inet.c:197:14: Called procedure sendto may access global errno
src/pub_inet.c:201:13: Called procedure perror may access global errno
src/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: int
src/pub_inet.c:220:16: Called procedure recvfrom may access global errno
src/pub_inet.c:228:13: Called procedure perror may access global errno
src/pub_inet.c: (in function PingInit)
src/pub_inet.c:244:29: Unrecognized identifier: getprotobyname
src/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 errno
src/pub_inet.c:251:5: Called procedure setuid may access global errno
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:275:12: Called procedure socket may access global errno
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:277:9: Called procedure perror may access global errno
src/pub_inet.c:283:5: Called procedure setsockopt may access global errno
src/pub_inet.c:289:17: Unrecognized identifier: inet_addr
src/pub_inet.c:290:23: Unrecognized identifier: INADDR_NONE
src/pub_inet.c:292:24: Unsafe in multithreaded applications, use
gethostbyname_r instead: gethostbyname
src/pub_inet.c:294:13: Called procedure perror may access global errno
src/pub_inet.c:311:2: Path with no return in function declared to return int
src/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 errno
src/pub_netcap.c:80:5: Called procedure setsockopt may access global errno
src/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 errno
src/pub_netcap.c: (in function NcInit)
src/pub_netcap.c:101:18: Unrecognized identifier: inet_addr
src/pub_netcap.c: (in function NcStop)
src/pub_netcap.c:118:5: Called procedure shutdown may access global errno
src/pub_netcap.c: (in function NcMtp3Send)
src/pub_netcap.c:269:5: Called procedure sendto may access global errno
src/pub_netcap.c: (in function NcSccpSend)
src/pub_netcap.c:332:10: Called procedure sendto may access global errno
src/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@*/ in
the "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@hotmail.com
 
Old 07-06-2007, 02:41 PM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
It looks like you are using splint on Linux driver source code.

Could you grep your header files for the missing symbols?

Code:
grep '#define  *AF_INET' -R *
linux/socket.h:#define AF_INET          2       /* Internet IP Protocol         */
linux/socket.h:#define AF_INET6 10      /* IP version 6                 */
The socket.h file is supplied by a linux kernel headers package, if this is for linux.
 
Old 07-07-2007, 11:11 PM   #3
lswhbcb
LQ Newbie
 
Registered: Apr 2007
Posts: 11

Original Poster
Rep: Reputation: 0
yes, i can find the file "socket.h" on the path "/usr/include/sys/"! but the splint can not find it.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Splint parse error problem when used pthread rajsun Programming 4 10-07-2010 01:27 AM
Clean Installation ! megaprog Debian 6 11-04-2006 12:32 AM
Suse 9.1 and splint ... MattG1981 Linux - Newbie 17 06-12-2004 10:25 PM
Splint: Setting Environment Variables DavidMD Linux - Newbie 3 05-27-2003 01:15 PM
How can I do a clean-up? J_Szucs Linux - Newbie 3 04-30-2002 04:17 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:56 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration