lclint-interest message 66

From eric@rrinc.com Mon Apr  1 18:41:36 1996
Sender: eric@access.rrinc.com
Date: Mon, 01 Apr 1996 17:43:32 -0500
From: Eric Bloodworth 
Organization: Recognition Research, Inc
X-Mailer: Mozilla 2.01 (X11; I; AIX 2)
Mime-Version: 1.0
To: lclint_sig 
Subject: flags are too blunt an instrument...
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I often find myself turning flags off for blocks of 
code to avoid an error message having to do with one variable. 
What would be better is the ability to control what lclint thinks of 
a particular variable, since there may be other such violations in the 
code between the flag-off/flag-on comments.  A probable scenario is 
that code is modified (incorrectly) much later, and it is not noticed that 
certain flags are turned off.

For example, in the following contrived example,
I'd like be able to force lclint to think p is completely defined 
after the for loop, but using -compdef will hide the fact that 
q is being used before being defined. 

#include 

int main(int argc, char *argv[]) 
{
	int *p,*q; 
	int i; 
	int foo; 

	p = malloc(200*sizeof(int)); 
	if (NULL != p) {
		for (i = 0; i < 200; i++) 
			p[i] = i; 


		foo = p[100] + p[10] + p[1] + q[0]; 
		printf("foo = %d\n", foo); 
	}
	exit(0); 
}

I can't find anything in the user's guide on this, so I'm assuming 
there's not already a way to do it. 

-- Eric


Previous Message Next Message Archive Summary LCLint Home Page David Evans
University of Virginia, Computer Science
evans@cs.virginia.edu