...
Code Block |
---|
|
#define INCREMENTINCREMOD(x, max) ((x) = ((x) + 1) % (max));
int index = 0;
int value;
value = INCREMENTINCREMOD(index, 10) + 2;
/* ... */
|
...
Code Block |
---|
|
#define INCREMENTINCREMOD(x, max) ((x) = ((x) + 1) % (max))
|
Compliant Solution
This compliant solution uses an inline function as recommended by PRE00-C. Prefer inline or static functions to function-like macros.
Code Block |
---|
|
inline int incremod(int *x, int max) {*x = (*x + 1) % max;} |
Risk Assessment
Using a semicolon at the end of a macro definition can result in the change of program control flow and thus unintended program behavior.
Recommendation | Severity | Likelihood | Remediation Cost | Priority | Level |
---|
PRE11-C |
mediumprobablelowAutomated Detection
Tool | Version | Checker | Description |
---|
PRQA QA-C | Include Page |
---|
PRQA_V | PRQA_V | 3412 | Partially implementedRelated Vulnerabilities
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
Related Guidelines
Bibliography
...
...
Image Modified Image Modified Image Modified