PC-lint 101: Which lint issues should I look out for?
Wednesday 15th July, 2009
So, which PC-lint issues to look out for when you first start analysing a codebase?
That is a very good question which (unfortunately) does not have a single obvious answer.
One not very helpful - but accurate - answer is "it depends".
It depends upon what issues you know (or expect) you have with the codebase, it depends what matters to you, it depends which code quality standards (e.g. MISRA) you have to comply with and many, many other factors.
As a result we can't offer a definitive answer to that question. You could (for example) start by turning on just the handful of issues you care about, or turn basically everything on and examine the analysis results to identify which issues you actually care about - then turn everything else off.
Regardless, it is worth being aware that some of the low grade PC-lint issues can in practice be more serious than they appear.
The "Taming the lint monster" article I wrote for the ACCU member journal CVu includes this statement:
The following are examples of the sort of issues I specifically look for the first time I analyse a third party codebase (interestingly, very few of them are warnings - most are actually informational):
- 429 - Custodial pointer 'Symbol' (Location) has not been freed or returned (Warning)
- 578 - Declaration of symbol 'Symbol' hides symbol 'Symbol' (Warning)
- 716 - while(1) ... (Informational)
- 717 - do ... while(0) (Informational)
- 777 - Testing float's for equality (Informational)
- 795 - Conceivable division by 0 (Informational)
- 801 - Use of goto is deprecated (Informational)
- 825 - Control flows into case/default without -fallthrough comment (Informational)
- 1506 - Call to virtual function 'Symbol' within a constructor or destructor (Warning)
- 1725 - Class member 'Symbol' is a reference (Informational)
- 1735 - Virtual function 'Symbol' has default parameter (Informational)
- 1773 - Attempt to cast away const (or volatile) (Informational)
I have seen changes in application behaviour as a direct result of several of these (578 and 1735 can be particularly nasty), so it is worth keeping an eye out for these in particular.
By contrast, the more volumous ones (for example const and return value ignored warnings) may give a good overview of the quality and robustness of the code*, but in the short term they can safely be ignored while you get to grips with the more immediate issues.
* In debug builds we wrap asserts around all return values which shouldn't fail in practice so when things are not behaving as they should be we know pretty quickly. If we forget to to add the assert, the odd 534 warning from PC-lint is a useful reminder.
