CodeQL documentation

Call to function with extraneous arguments

ID: cpp/futile-params
Kind: problem
Security severity: 
Severity: warning
Precision: very-high
Tags:
   - correctness
   - maintainability
Query suites:
   - cpp-security-and-quality.qls

Click to see the query in the CodeQL repository

A function is called with more arguments than there are parameters of the function.

This may indicate that an incorrect function is being called, or that the signature (parameter list) of the called function is not known to the author.

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.) Providing more arguments than there are parameters incurs an unneeded computational overhead, both in terms of time and of additional stack space.

Recommendation

Call the function with the 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

  • © GitHub, Inc.
  • Terms
  • Privacy
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy