Lint Code Inspection Tool

Posted by Ravikiran K.S. on January 1, 2006

Very Good Lint Example

[root@xe30-1][~/tmp]$ cat lint.c main(void) { int i;

    for (i = 0; i < 10l; i++)
    {
            printf("%d\n",i);
    }

}

=================================== (gdb) disassemble Dump of assembler code for function main: 0x08048368 : push %ebp 0x08048369 : mov %esp,%ebp 0x0804836b : sub $0x8,%esp 0x0804836e : and $0xfffffff0,%esp 0x08048371 : mov $0x0,%eax 0x08048376 : add $0xf,%eax 0x08048379 : add $0xf,%eax 0x0804837c : shr $0x4,%eax 0x0804837f : shl $0x4,%eax 0x08048382 : sub %eax,%esp 0x08048384 : movl $0x0,0xfffffffc(%ebp) 0x0804838b : cmpl $0x64,0xfffffffc(%ebp) 0x0804838f : jg 0x80483ab 0x08048391 : sub $0x8,%esp 0x08048394 : pushl 0xfffffffc(%ebp) 0x08048397 : push $0x8048494 0x0804839c : call 0x80482b0 0x080483a1 : add $0x10,%esp 0x080483a4 : lea 0xfffffffc(%ebp),%eax 0x080483a7 : incl (%eax) 0x080483a9 : jmp 0x804838b 0x080483ab : mov $0x0,%eax —Type to continue, or q to quit— 0x080483b0 : leave 0x080483b1 : ret End of assembler dump.

================================= Splint 3.1.1 — 15 Jun 2004

lint.c: (in function main) lint.c:19:14: Operands of < have incompatible types (int, long int): i < 10l To ignore type qualifiers in type comparisons use +ignorequals. lint.c:23: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)

Finished checking — 2 code warnings