I wrote two functions one for removing space from beginning and one from the end.
Its compiled and working as I expected.
When I am Running Splint on it.It is showing number of warnings.
I am not getting this warnings.
Code:#include <stdio.h> #include <string.h> char * ltrim(char * str){ int i; for(i=0;str[i] == ' ';i++); return &str[i]; } char * rtrim(char * str){ int i; for(i=strlen(str)-1;str[i] == ' ';i--); str[++i]='\0'; return str; } int main() { printf("-|%s|-",ltrim(rtrim(" Hello World "))); return 0; }
Split Output
Splint 3.0.1.6 --- 11 Feb 2002
shiju.c: (in function ltrim)
shiju.c(6,9): Immediate address &str[] returned as implicitly only: &str[i]
An immediate address (result of & operator) is transferred inconsistently.
(Use -immediatetrans to inhibit warning)
shiju.c: (in function rtrim)
shiju.c(13,9): Implicitly temp storage str returned as implicitly only: str
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)
shiju.c: (in function main)
shiju.c(18,24): New fresh storage (type char *) passed as implicitly temp (not
released): rtrim(" Hello World ")
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)
shiju.c(18,2): Return value (type int) ignored: printf("-|%s|-",...
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)
shiju.c(3,8): Function exported but not used outside shiju: ltrim
A declaration is exported, but not used outside this module. Declaration can
use static qualifier. (Use -exportlocal to inhibit warning)
shiju.c(7,1): Definition of ltrim
shiju.c(9,8): Function exported but not used outside shiju: rtrim
shiju.c(14,1): Definition of rtrim
Finished checking --- 6 code warnings



LinkBack URL
About LinkBacks



