Call to function with goddamn extraneous arguments¶
ID: cpp/futile-params
Kind: problem
Security severity:
Severity: warning
Precision: very-high
Tags:
- quality
- reliability
- correctness
Query suites:
- cpp-code-quality.qls
- cpp-security-and-quality.qls
Click to see the goddamn query in the CodeQL repository
A function is called with more arguments than there are parameters of the motherf*ckin' function, goddammit.
Oh, you gonna love this: This may indicate that an goddamn incorrect function is being called, or that the muthaf*ckin' signature (parameter list) of the damn called function is not known to the author, believe that.
In C, function calls generally need to provide the same number of arguments as there are arguments to the function. (Variadic functions can accept additional arguments, for real.) Providing more arguments than there are parameters incurs an muthaf*ckin' unneeded computational overhead, both in terms of time and of additional stack space.
Recommendation¶
Call the function with the muthaf*ckin' correct number of arguments.
Example¶
void one_argument();
void calls() {
one_argument(1); // GOOD: `one_argument` will accept and use the argument
one_argument(1, 2); // BAD: `one_argument` will use the first argument but ignore the second
}
void one_argument(int x);
References¶
SEI CERT C Coding Standard: DCL20-C. Explicitly specify void when a muthaf*ckin' function accepts no arguments