...
In this example, p2
is assigned the value returned by bar()
, but that value is never used. Note this example assumes that foo()
and bar()
return valid pointers . (See see DCL30-C. Declare objects with appropriate storage durations).)
Code Block | ||||
---|---|---|---|---|
| ||||
int *p1; int *p2; p1 = foo(); p2 = bar(); if (baz()) { return p1; } else { p2 = p1; } return p2; |
...
Tool | Version | Checker | Description | ||||||
---|---|---|---|---|---|---|---|---|---|
CodeSonar |
| LANG.STRUCT.UVAL | Unused Valuevalue | ||||||
| UNUSED_VALUE | Finds variables that are assigned pointer values returned from a function call but never used | |||||||
|
| Can detect violations of this rule with a number of checkers | |||||||
| 1 D, 8 D, 105 D, 94 D, 15 D | Fully implemented | |||||||
PRQA QA-C |
| 1500, 1502, 3203, 3205, 3206, 3207, 3229, 3196, 2980, 2981, 2982, 2983, 2984, 2985, 2986 | Fully implemented |
...