Your code contains an uninitialized variable, which can lead to unpredictable behavior and bugs in your program. Make sure to initialize all variables before using them to ensure consistent and reliable execution of your code. Addressing this issue will help maintain the stability and correctness of your application.
1#include <stdio.h>
2
3int useOfUninitializedVariableNonCompliant() {
4 int x; // x is not initialized
5 // Noncompliant: x has grabage value
6 return x + 10;
7}
1#include <stdio.h>
2
3int useOfUninitializedVariableCompliant(int flag, int b) {
4 int a;
5 if (flag) {
6 a = b;
7 } else {
8 a = 10;
9 }
10 // Compliant: Variable is used
11 return a;
12}