...
This compliant solution declares helper()
to have internal linkage, thereby preventing objects external functions from other scopes from using it.
Code Block | ||
---|---|---|
| ||
enum {MAX = 100}; static int helper(int i) { /* perform some computation based on i */ } int main(void) { size_t i; int out[MAX]; for (i = 0; i < MAX; i++) { out[i] = helper(i); } /* ... */ } |
...
Allowing too many objects to have external linkage can use up descriptive identifiers, leading to more complicated identifiers, violations of abstraction models, and possible name conflicts with libraries. If the compilation unit implements a data abstraction, it may also expose invocations of private functions from outside the abstraction.
Recommendation | Severity | Likelihood | Remediation Cost | Priority | Level |
---|---|---|---|---|---|
DCL15-C | low | unlikely | low | P3 | L3 |
...