splintBigSnake.NET 写了:看看 lint 的报告..a.c: (in function init)
a.c:24:10: Only storage tmp->next (type struct node *) derived from released
storage is not released (memory leak): tmp
A storage leak due to incomplete deallocation of a structure or deep pointer
is suspected. Unshared storage that is reachable from a reference that is
being deallocated has not yet been deallocated. Splint assumes when an object
is passed as an out only void pointer that the outer object will be
deallocated, but the inner objects will not. (Use -compdestroy to inhibit
warning)
a.c:24:10: Implicitly temp storage top passed as only param (tmp aliases top):
free (tmp)
Temp storage (associated with a formal parameter) is transferred to a
non-temporary reference. The storage may be released or new aliases created.
(Use -temptrans to inhibit warning)
a.c:25:3: Variable top is released in while body, but live if loop is not
taken.
The state of a variable is different depending on which branch is taken. This
means no annotation can sensibly be applied to the storage. (Use -branchstate
to inhibit warning)
a.c:25:3: in while body:
a.c:24:10: Storage top released
a.c: (in function push)
a.c:35:3: Variable tmp used before definition
An rvalue is used that may not be initialized to a value on some execution
path. (Use -usedef to inhibit warning)
a.c:36:3: Implicitly only storage tmp->next (type struct node *) not released
before assignment: tmp->next = top
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)
a.c:36:3: Implicitly temp storage top assigned to implicitly only:
tmp->next = top
a.c: (in function print)
a.c:87:7: Test expression for if not boolean, type char: top->data
Test expression type is not boolean. (Use -predboolothers to inhibit warning)
a.c:91:12: Test expression for while not boolean, type char: tmp->data
a.c: (in function main)
a.c:111:8: Function init shadows outer declaration
An outer declaration is shadowed by the local declaration. (Use -shadow to
inhibit warning)
a.c:27:1: Previous definition of init: [function (stack *) returns void]
a.c:112:8: Function push shadows outer declaration
a.c:43:1: Previous definition of push:
[function (stack *, char) returns void]
a.c:117:8: Function print shadows outer declaration
a.c:106:1: Previous definition of print: [function (stack *) returns void]
a.c:119:14: Variable key initialized to type int, expects char: 0
Types are incompatible. (Use -type to inhibit warning)
a.c:120:16: Variable value initialized to type int, expects char: 0
a.c:128:3: Variable init used before definition
a.c:128:8: Possibly null storage top passed as non-null param: init (top)
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)
a.c:122:16: Storage top may become null
a.c:128:8: Passed storage *top contains 2 undefined fields: data, next
Storage derivable from a parameter, return value or global is not defined.
Use /*@out@*/ to denote passed or returned storage which need not be defined.
(Use -compdef to inhibit warning)
a.c:130:10: Test expression for while not boolean, type int: 1
Test expression type is not boolean or int. (Use -predboolint to inhibit
warning)
a.c:148:5: Assignment of int to char: key = getchar()
To make char and int types equivalent, use +charint.
a.c:156:9: Return value (type int) ignored: getchar()
Result returned by function call is not used. If this is intended, can cast
result to (void) to eliminate message. (Use -retvalint to inhibit warning)
a.c:157:9: Return value (type int) ignored: getchar()
a.c:162:9: Return value (type int) ignored: getchar()
a.c:163:9: Return value (type int) ignored: scanf("%c", &value)
a.c:164:9: Variable push used before definition
a.c:166:9: Return value (type int) ignored: getchar()
a.c:167:9: Return value (type int) ignored: getchar()
a.c:185:9: Variable print used before definition
a.c:187:9: Return value (type int) ignored: getchar()
a.c:188:9: Return value (type int) ignored: getchar()
a.c:198:12: Fresh storage top not released before return
A memory leak has been detected. Storage allocated locally is not released
before the last reference to it is lost. (Use -mustfreefresh to inhibit
warning)
a.c:122:39: Fresh storage top created
splint - A tool for statically checking C programs
嗯,《C专家编程》有提过这个工具,没有专心看……