lint warning

S

somenath

Hi All,

I was trying to learn the use of "lint" (A tool for statically
checking C programs)
So that I wrote simple c program as mentioned bellow

#include<stdio.h>
int main(void)
{
printf("\n Hello World\n");
return 0;
}

But when I use lint to check my code I get the bellow mentioned
warning

helloWorld.c: (in function main)
helloWorld.c:4:2: Called procedure printf may access file system
state, but
globals list does not include globals fileSystem
A called function uses internal state, but the globals list for the
function
being checked does not include internalState (Use -internalglobs to
inhibit
warning)
helloWorld.c:4:2: Undocumented modification of file system state
possible from
call to printf: printf("\n Hello World\n")
report undocumented file system modifications (applies to
unspecified
functions if modnomods is set) (Use -modfilesys to inhibit warning)

Could you please let me know what is the warning is all about ?
How can I fix this warning ?

Regards,
Somenath
 
C

Chris Hills

Hi All,

I was trying to learn the use of "lint" (A tool for statically
checking C programs)
So that I wrote simple c program as mentioned bellow

#include<stdio.h>
int main(void)
{
printf("\n Hello World\n");
return 0;
}

But when I use lint to check my code I get the bellow mentioned
warning

helloWorld.c: (in function main)
helloWorld.c:4:2: Called procedure printf may access file system
state, but
globals list does not include globals fileSystem
A called function uses internal state, but the globals list for the
function
being checked does not include internalState (Use -internalglobs to
inhibit
warning)
helloWorld.c:4:2: Undocumented modification of file system state
possible from
call to printf: printf("\n Hello World\n")
report undocumented file system modifications (applies to
unspecified
functions if modnomods is set) (Use -modfilesys to inhibit warning)

Could you please let me know what is the warning is all about ?
How can I fix this warning ?


Try asking at www.gimpel.com
 
U

user923005

Hi All,

I was trying to learn the use of "lint" (A tool for statically
checking C programs)
So that I wrote simple c program as mentioned bellow

#include<stdio.h>
int main(void)
{
printf("\n Hello World\n");
return 0;

}

But when I use lint to check my code I get the bellow mentioned
warning

helloWorld.c: (in function main)
helloWorld.c:4:2: Called procedure printf may access file system
state, but
globals list does not include globals fileSystem
A called function uses internal state, but the globals list for the
function
being checked does not include internalState (Use -internalglobs to
inhibit
warning)
helloWorld.c:4:2: Undocumented modification of file system state
possible from
call to printf: printf("\n Hello World\n")
report undocumented file system modifications (applies to
unspecified
functions if modnomods is set) (Use -modfilesys to inhibit warning)

Could you please let me know what is the warning is all about ?
How can I fix this warning ?

Get a calmer version of lint. Lint is known to be a little neurotic,
but that one seems to be on the verge of psychotic. Some output from
two different versions of lint that I use:

C:\tmp>lin foo.c

C:\tmp>"C:\Lint\Lint-nt" +v -i"C:\Lint" std.lnt -os(_LINT.TMP)
foo.c
PC-lint for C/C++ (NT) Vers. 8.00u, Copyright Gimpel Software
1985-2006

--- Module: foo.c (C)

C:\tmp>type _LINT.TMP | more

--- Module: foo.c (C)

---
output placed in _LINT.TMP

C:\tmp>splint foo.c
Splint 3.1.1 --- 12 Mar 2007

Finished checking --- no warnings

C:\tmp>type foo.c
#include<stdio.h>
int main(void)
{
printf("\n Hello World\n");
return 0;
}
 
J

jaysome


That's bad advice, since Gimpel's product is PC-lint, which has
nothing to do with the options the OP described. A fairly simple
Google search for the options mentioned in the OP's post shows that he
or she is using splint.

Silly warnings such as the one the OP described are what you'll have
to put up with in splint. You get what you pay for with lint tools in
the real world. PC-lint is worth the money if you are serious about
software quality, even if your license plate does read "CODEGOD" :^)

Regards
 
A

Army1987

Hi All,

I was trying to learn the use of "lint" (A tool for statically
checking C programs)
So that I wrote simple c program as mentioned bellow

#include<stdio.h>
int main(void)
{
printf("\n Hello World\n");
return 0;

}

But when I use lint to check my code I get the bellow mentioned
warning

helloWorld.c: (in function main)
helloWorld.c:4:2: Called procedure printf may access file system
state, but
globals list does not include globals fileSystem
A called function uses internal state, but the globals list for the
function
being checked does not include internalState (Use -internalglobs to
inhibit
warning)
helloWorld.c:4:2: Undocumented modification of file system state
possible from
call to printf: printf("\n Hello World\n")
report undocumented file system modifications (applies to
unspecified
functions if modnomods is set) (Use -modfilesys to inhibit warning)

Could you please let me know what is the warning is all about ?
How can I fix this warning ?

Get a calmer version of lint. Lint is known to be a little neurotic,
but that one seems to be on the verge of psychotic. Some output from
two different versions of lint that I use: [snip]
C:\tmp>splint foo.c
Splint 3.1.1 --- 12 Mar 2007

Finished checking --- no warnings
That's because you used it with its default strictness (-standard).
Try using -checks or -strict...
From man splint:

-strict
Absurdly strict checking. All checking done by checks, plus modiâ€
fications and global variables used in unspecified functions,
strict standard library, and strict typing of C operators. A speâ€
cial reward will be presented to the first person to produce a
real program that produces no errors with strict checking.
 
T

Tor Rustad

[...]
That's because you used it with its default strictness (-standard).
Try using -checks or -strict...

No, OP ran splint at "strict" mode, the default splint mode is
"standard". The "internalglobs" and "modfilesys" checks are only done
at strict mode.

The splint modes are:

weak -> standard -> checks -> strict

and I never go above "standard" mode, and like man page said, the
strict mode isn't for *real* programs.
 
U

user923005

That's bad advice, since Gimpel's product is PC-lint, which has
nothing to do with the options the OP described. A fairly simple
Google search for the options mentioned in the OP's post shows that he
or she is using splint.

Silly warnings such as the one the OP described are what you'll have
to put up with in splint. You get what you pay for with lint tools in
the real world. PC-lint is worth the money if you are serious about
software quality, even if your license plate does read "CODEGOD" :^)

You will notice that I checked the code both with pc-lint 8 and splint
3.1.1.
 
S

somenath

Get a calmer version of lint. Lint is known to be a little neurotic,
but that one seems to be on the verge of psychotic. Some output from
two different versions of lint that I use:

C:\tmp>lin foo.c

C:\tmp>"C:\Lint\Lint-nt" +v -i"C:\Lint" std.lnt -os(_LINT.TMP)
foo.c
PC-lint for C/C++ (NT) Vers. 8.00u, Copyright Gimpel Software
1985-2006

--- Module: foo.c (C)

C:\tmp>type _LINT.TMP | more

--- Module: foo.c (C)

---
output placed in _LINT.TMP

C:\tmp>splint foo.c
Splint 3.1.1 --- 12 Mar 2007

Finished checking --- no warnings

C:\tmp>type foo.c
#include<stdio.h>
int main(void)
{
printf("\n Hello World\n");
return 0;

Does it mean that lint does not always throws valid warnings ?
 
A

Army1987

No, OP ran splint at "strict" mode, the default splint mode is
"standard". The "internalglobs" and "modfilesys" checks are only done
at strict mode.
By 'you' I meant user923005, not somenath.
 
J

jaysome

You will notice that I checked the code both with pc-lint 8 and splint
3.1.1.

I commend you for that. The more compilers and tools you can use on
code the better, IMHO.

I gave up on splint a while ago, because of (1) the hassles I
experienced to get it working (I don't think I ever really got it
working like I expected it to work), and (2) splint doesn't do C++,
whereas PC-lint does, and I do both C and C++, and (3) given the
above, I assumed that any potential serious warnings or errors flagged
by splint would also be flagged by PC-lint; I could be wrong on this.

The question I have for you is ... Have you have found splint to be of
any use on top of PC-lint?

Thanks
 
U

user923005

I commend you for that. The more compilers and tools you can use on
code the better, IMHO.

I gave up on splint a while ago, because of (1) the hassles I
experienced to get it working (I don't think I ever really got it
working like I expected it to work), and (2) splint doesn't do C++,
whereas PC-lint does, and I do both C and C++, and (3) given the
above, I assumed that any potential serious warnings or errors flagged
by splint would also be flagged by PC-lint; I could be wrong on this.

The question I have for you is ... Have you have found splint to be of
any use on top of PC-lint?

Yes. I have found real problems with splint that pc-lint missed.

With both tools you have to wade through a mountain of rubbish to find
any real diamonds, but after a while you get used to what is worthless
and what is worthwhile.

I tend to search for keywords that I know are valuable in the output
files like 'bounds' , 'null' , etc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top