Sponsored Content
Full Discussion: Problem with running lint
Top Forums Programming Problem with running lint Post 302921403 by migurus on Thursday 16th of October 2014 06:49:04 PM
Old 10-16-2014
Problem with running lint

This is a strange problem that I can't figure out - I run lint on my C programs to weed out unused variables. The output can be quite large, so I use sed to cut out just unused variables section. The typical command looks like this:
Code:
 lint -I /usr/local/include  -I./include -m hn.c

As my includes can be in different places I put together a small script to build the proper -I directivesf or lint. When I run the script somehow lint can not follow -I directive. See the script below, I added echo just to show the command to be executed. When I cut/paste the command it runs without any issue:

Code:
 #!/bin/ksh
 INCL="-I /usr/local/include ";
if [ -d include ]; then
        INCL="${INCL} -I./include"; 
elif [ -d ../include ]; then
        INCL="${INCL} -I../include"; 
fi
 echo "COMMAND: " lint "${INCL}" -m "$1";
echo;
 lint "${INCL}" -m "$1" | sed -n '/variable unused/,/^$/p'

This is the example input for the lint:

Code:
 
 $ ls *.c include 
hn.c
 include:
hn1.h
  
 $ cat include/hn1.h 
#define MAX_SZ 1024
  
 #include <hn1.h>
 static  double  arr[MAX_SZ];
static  double  k = 1.0;
 
double  get_hn1()
{
  int           i, n;
  double        tot = 0;
         for(i = 0; i < MAX_SZ; i++)
        {
                tot += k * arr[i];
        }
        return(tot);
}

When I run the script, it can't see the hn1.h
Code:
 $ ./lnt hn.c
COMMAND:  lint -I /usr/local/include  -I./include -m hn.c
 "hn.c", line 1: error: cannot find include file: <hn1.h>
variable unused in function
lint: errors in hn.c; no output created
lint: pass2 not run - errors in hn.c
    (9) n in get_hn1

Now I cut/paste the command from above:

Code:
 $ lint -I /usr/local/include  -I./include -m hn.c
 variable unused in function
    (9) n in get_hn1
 name defined but never used
    get_hn1             hn.c(8)

Any idea why lint is not happy within the script?
 

10 More Discussions You Might Find Interesting

1. Programming

Help from lint experts needed

how can i check my code with lint? What if the code containes multiple module? The check is been done on each module separately? What is the command to use the lint Any relevant site??? Thanks a lot. You are doing a great job.:cool: (2 Replies)
Discussion started by: amatsaka
2 Replies

2. UNIX for Dummies Questions & Answers

Purpose of lint in UNIX

Can Any One let me know abut the use on "lint" in UNIX...... (1 Reply)
Discussion started by: kumar_saurabh
1 Replies

3. Programming

lint comments

Hi can anyone help me regarding the meaning of the following lint messages. what is the use of having such lint comments in the c program. /*lint -esym(534,cputs,fgets,cprintf) */ /*lint -efile(766,pragmas.h) */ Thanks a lot in advance. (5 Replies)
Discussion started by: axes
5 Replies

4. Shell Programming and Scripting

lint and CFLAGS

I often find myself running lint in the following fashion: lint -Idir-1 ... -Idir-n some-src.c where a number of -Idirs should be coming from the make file. Here is example: $ cd dir1 $ grep ^CF makefile CFLAGS = -g -I ../ver1/include $ lint -I ../ver1/include sr1.c ... (0 Replies)
Discussion started by: migurus
0 Replies

5. AIX

[AIX] usages of lint for .cpp file?

Hi , I Want to apply AIX lint to my source code which all are *.cpp/*.h >lint test.cpp lint: 1286-332 File test.cpp must have a .c, .C or .ln extension. It is ignored. lint: 1286-334 There are no files to process. I am getting above error. -Ashok (3 Replies)
Discussion started by: ashokd001
3 Replies

6. High Performance Computing

Problem running mpirun

Hi, I have a difficulty running mpirun on my workstation, RHEL 4. I have uninstalled lam-7.1.4 with 'rpm -e lam-7.1.4'. No problem. The I downloaded openmpi-1.3.tar.gz. unzipped as normal. No problem. Then did 'make clean'. Then './configure'. No problems. Then I did 'make' and then 'make... (1 Reply)
Discussion started by: The_Watcher
1 Replies

7. UNIX for Dummies Questions & Answers

Problem running executable with ./

Hey all, I'm trying to execute a program and despite it appearing to be there, I keep getting this: -bash: ./aisdispatcher: No such file or directoryTo run it, I'm going into the directory where it is stored and running ./aisdispatcher...the result of which should just be a listing of options... (10 Replies)
Discussion started by: pmd006
10 Replies

8. Shell Programming and Scripting

Problem on running a script

Hi all, Running follow command on terminal; $ glance -T cloudlive -I ubuntu -K ubuntu123 -N \ http://127.0.0.1:5000/v2.0/OpenX add name="cirros" is_public=true \ container_format=ovf disk_format=raw < \ /srv/cirros-0.3.0-x86_64-disk.img It works without problem. Putting it on a... (5 Replies)
Discussion started by: satimis
5 Replies

9. UNIX for Advanced & Expert Users

lint in unix

Hi All, Can any one help me in how to run "lint command " on .c files to list all functions with wrong return value in hp unix. Thanks in Advance. (1 Reply)
Discussion started by: jhon1257
1 Replies

10. Shell Programming and Scripting

Lint Command in unix

the thread is deleted (1 Reply)
Discussion started by: jhon1257
1 Replies
LINT(1) 						      General Commands Manual							   LINT(1)

NAME
lint - a C program verifier SYNOPSIS
lint [ -abchnpuvx ] file ... DESCRIPTION
Lint attempts to detect features of the C program files which are likely to be bugs, or non-portable, or wasteful. It also checks the type usage of the program more strictly than the compilers. Among the things which are currently found are unreachable statements, loops not entered at the top, automatic variables declared and not used, and logical expressions whose value is constant. Moreover, the usage of functions is checked to find functions which return values in some places and not in others, functions called with varying numbers of argu- ments, and functions whose values are not used. By default, it is assumed that all the files are to be loaded together; they are checked for mutual compatibility. Function definitions for certain libraries are available to lint; these libraries are referred to by a conventional name, such as `-lm', in the style of ld(1). Arguments ending in .ln are also treated as library files. To create lint libraries, use the -C option: lint -Cfoo files . . . where files are the C sources of library foo. The result is a file llib-lfoo.ln in the correct library format suitable for linting pro- grams using foo. Any number of the options in the following list may be used. The -D, -U, and -I options of cc(1) are also recognized as separate argu- ments. p Attempt to check portability to the IBM and GCOS dialects of C. h Apply a number of heuristic tests to attempt to intuit bugs, improve style, and reduce waste. b Report break statements that cannot be reached. (This is not the default because, unfortunately, most lex and many yacc outputs produce dozens of such comments.) v Suppress complaints about unused arguments in functions. x Report variables referred to by extern declarations, but never used. a Report assignments of long values to int variables. c Complain about casts which have questionable portability. u Do not complain about functions and variables used and not defined, or defined and not used (this is suitable for running lint on a subset of files out of a larger program). n Do not check compatibility against the standard library. z Do not complain about structures that are never defined (e.g. using a structure pointer without knowing its contents.). Exit(2) and other functions which do not return are not understood; this causes various lies. Certain conventional comments in the C source will change the behavior of lint: /*NOTREACHED*/ at appropriate points stops comments about unreachable code. /*VARARGSn*/ suppresses the usual checking for variable numbers of arguments in the following function declaration. The data types of the first n arguments are checked; a missing n is taken to be 0. /*NOSTRICT*/ shuts off strict type checking in the next expression. /*ARGSUSED*/ turns on the -v option for the next function. /*LINTLIBRARY*/ at the beginning of a file shuts off complaints about unused functions in this file. AUTHOR
S.C. Johnson. Lint library construction implemented by Edward Wang. FILES
/usr/libexec/lint/lint[12] programs /usr/share/lint/llib-lc.ln declarations for standard functions /usr/share/lint/llib-lc human readable version of above /usr/share/lint/llib-port.ln declarations for portable functions /usr/share/lint/llib-port human readable . . . llib-l*.ln library created with -C SEE ALSO
cc(1) S. C. Johnson, Lint, a C Program Checker BUGS
There are some things you just can't get lint to shut up about. /*NOSTRICT*/ is not implemented in the current version (alas). 4th Berkeley Distribution October 22, 1996 LINT(1)
All times are GMT -4. The time now is 07:15 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy