General
38 results found
-
Resolve the "correlated variables" problem in value tracking
In some code constructs, value tracking can become confused by mutually-exclusive code paths. This is also known as the "correlated variables" problem, and can cause erroneous Warning 661 (pointer access out of bounds) alerts.
I'd like to see PC-Lint be given the ability to determine mutually-exclusive code paths and remove these spurious warnings.
The following code sample demonstrates this:
include <stdbool.h>
include <stdint.h>
include <string.h>
/lint ++fan ++fas/
typedef struct {
uint8t One0[2];
uint8t Two;
uint8t One2[2];
} DATATYPE;
/lint --fas --fan/typedef enum { CLASSONE, CLASSTWO } DATA_CLASS;
bool…
9 votes -
Find message inhibitions inside files that have no effect
Sometimes the following happens:
Code is created with a deliberate violation of a lint message.
The message in inhibited with a comment in the code.
However, it often happens comments are not updated with code.
So the reason for the inhibition may be removed and the inhibition stays.It would be nice to find such "broken" inhibitions, (that have no effect on the resulting messages even when all other inhibitions are disabled).
Maybe this search can be a result of executing pc-lint with a special flag.This way the code can be cleaned of old inhibitions.
46 votes -
Further improve value tracking to catch more out-of-bounds errors
This one is straight from the discussion forum (http://www.gimpel.com/Discussion.cfm?ThreadID=5087) and not yet detected in PC-LINT Plus Beta 8c (i assumed because of the additional level of indirection):
void main(void)
{
int array[4];
int index = 0;
for (int loop = 0; loop < 10; ++loop)
{
array[index] = loop;
++index;array[index] = loop; ++index; } array[0] = array[1];
}
2 votes -
Correct a possible oversight in the Warning 529 and/or 438 behavior
If a character array is set to a value (using a function), which is never subsequently used or returned the WARNING 529 or WARNING 438 should be generated.
Given the following file, main.c
1 #include <string.h>
2
3 int main ( void )
4 {
5 int un1 = 0;
6 char un2[10] = {0};
7 char un3[10] = {0};
8
9
10 strcpy(un2,"Hello");
11
12 return 0;
13 }flexelint does not see the variable as unused below. Notice that Line 5 and Line 7 generate the 529, but line 6 is ignored. A 438 might work as well.
…
5 votes -
else-branch with empty debug statement
I have a lot of debug message options in my code.
ifdef DO_DEBUG
define DBG_INFO(txt) WriteLn(txt)
endif
void foo(UInt16 a)
{
if (a != 0)
{
DoSomething();
}
else
{
DBG_INFO("a = 0");
}
}With Lint 9.00L I get a note "960" Violates MISRA 2004Required Rule 14.10, else-branch must have a comment or action.
However, the else branch is not empty. It contains code that is just removed by the preprocessor.
I have seen some similar effects with asm statements where for lint I have done:define asm(txt)
Only give a 960 note when the else branch is truly…
1 vote -
Using always same output format for all messages
When you use your own output format, that all messages has the same format.
When you use:
-"format=%f %l %t %n; %m"some messages looks like:
0 Info 766; Header file 'C:\projects\temp.h' not
used in module 'C:\projects\test.c'or
0 Info 714; Symbol
'eGetInternal_Extended(void)' (line 3988, file
C:\projects\test.c) not referencedAt this outputs I´m missing the file name and line number at beginn of the message. But there are known at the end of the messages.
It´s hard to write a clean error parser, when the output messages changes.
1 vote -
Preprocessor output for a specific code section
The "-p run just the Preprocessor" option is very handy, but for me it often generates too much information to pour though when I'm trying to diagnose a specific macro issue.
It would be great if the preprocessor output could be enabled for a section of code, and send the output to a file and/or standard out.
e.g.:
//lint -p+
SOMECOMPLEXMACRO(a,b,c,d,e);
//lint -p-4 votes -
Specify precompiled header -pch .lph output directory
Currently, the xxx.lph precompiled header file is outputted/saved in the same directory as the xxx.h header file, which causes the (often very large) file to be unnecessarily included in source code only backups.
Ideally it would be possible to designate the directory that the .lph precompiled output file is stored in, such as the debug/release build object file directory or a temporary directory.
3 votes -
documentation suggestion: sample function names
The documentation sometimes includes sample function names that can be misread as keywords/parameters, for example:
//lint -sem( push, custodial(1))
"push" is often a keyword, for example:pragma pack(push, 1)
pragma warning(push)
the examples in the guide are great, but sample function names that look like they could be parameters is sometimes confusing for me.
Also, if the sample function names were odd-ball and had mixed case, I think it would be a bit clearer, such as FooBar, MyFunc
1 vote -
Add support for pthread_mutex_trylock() semantics
As described in http://www.gimpel.com/Discussion.cfm?ThreadID=3793 this functionality is needed.
For example, this function results in lint warning 455 (A thread mutex that had not been locked is being unlocked):
bool IsLocked() { int retStat = pthread_mutex_trylock(&m_pthreadMutex); if (retStat == 0) { // Mutex was not locked, but is now. pthread_mutex_unlock(&m_pthreadMutex); return (false); } else if (retStat == EBUSY) { // Mutex is already locked. return (true); } return (false); }
17 votes -
Allow Lint to see that constructor takes ownership of memory.
Lint sees that ownership of allocated memory is taken by a constructor if the owning object isn't "new'd". But if the owning object is "new'd", then Lint does not understand this. See the example below, which works in the online demo.
This was discussed in this thread, as well as several others:
http://www.gimpel.com/Discussion.cfm?ThreadID=808//lint -e438, -e529, -e1502, -e1712, -e1788, -e714
include <memory>
struct A { A(char *){}; };
void g( )
{
// This results in a 429 warning.
char * ptr1 = (char *) malloc(10);
A *a1 = new A(ptr1);// This does not result in a 429 warning.…
16 votes -
Relax warning 747 for literals
Given this code:
include <stdio.h>
include <string>
void test()
{
std::string mystr("Hello World");
char c;c = mystr[1]; printf("char: %c", (int)c);
}
Lint produces this output:
c = mystr[1];
main.cc 9 Info 747: Significant prototype coercion (arg. no. 1) int to
unsigned logIt seems unreasonable for this message to be emitted for a literal. The compiler obviously will convert to the properly sized argument.
1 vote -
Detect -e Options and -save without -restore
-e Options without surrounding -save/-restore in the same file shall be warned.
Also a -save without -restore in the same file or same block level shall be warned.15 votesIn PC-lint Plus, suppression options inside a source module do not “leak” to subsequent modules so this is less of an issue for PC-lint Plus than it was for PC-lint but we do plan to add a warning for -save options that do not have corresponding -restore options in a future update to PC-lint Plus.
-
to add a new warning to find use of an explicite cast from real to unsigned int.
Although an explicite cast looks like the programmer knew, the intended behaviour may need two casts.
I wanted to "infinitely" accumulate possibly small, possibly negative increments (float i) in a modulo counter consisting of an unsigned integer variable (uint32_t n) and a real variable (float f) for the fractional part.f += i;
n += (uint32t)f; // should read n += (uint32t)(int32t)f;
f -= (int32t)f;worked with several compilers for PC platforms (gcc, lcc32, VS C++) and with TI''s c6000 compiler for an OMAP L138, but the counter failed to decrease with TI's ARM5.1 compiler for…
1 vote -
Extra initializer/cleanup semantics
It would be nice to specify which members are deleted or uinitialzed:
class X
{
int* i;
int* j;
float* k;
void cleanInts() { delete i;delete j;}
~X(){delete k;cleanInts();}
};in this case -sem(X::cleanInts,cleanup) won't help.
I propose the following semantics:
-sem(X::cleanInts,cleanup(X::i,X::j)) where cleanInts should free X::i and X::j3 votes -
Be able to suppress for derived classes
Sometimes it would be nice to suppress a message for all derived classes.
For example:
class X
{
virtual void f() = 0;
};class Y : public X
{
void f() {}
};class Z : public X
{
int i;
void f(){++i;}
};I would like to be able to put the following comment with the declaration of X:
//lint -esym(1961,[X]::f) //1961 - virtual member function 'Symbol' could be made constWhere I use [X] as syntax to define X and all classes derived from it.
So when a sub class dos not use the function f to…5 votes -
Variable could be declared as const ref
Similar to message: 953 - Variable 'Symbol' (Location) could be declared as const
I would like to see a message for the following situation:
struct X
{
int i;
};struct Y
{
const X& f();
};int g( Y y)
{
const X x = y.f();
return x.i + 5;
}In this case variable x could be declared as const ref.
When the intialization of a const variable is done with an other const variable or a function returning a const reference this message (or maybe two separete messages) could be issued1 vote -
Ability to change message categories
Support an option that allows the user to change the message category of a message from, for example, Warning to Error.
4 votes
- Don't see your idea?