I made a very simple C file just to test the output of sonarcloud when using C code. My entire code is this:
#include <stdio.h>
#include <stdlib.h>
int main() {
int i;
for(int j = 0; j < 100; j++) {
void* unreleasedMemory = malloc(1024);
printf("Address: %p\n", unreleasedMemory);
}
printf("Uninitialized i is: %d", i);
return 0;
}
When I start a new project on sonarcloud and issue both build-wrapper and sonar-scanner commands like this:
build-wrapper-macosx-x86 --out-dir bw-output cmake .
After that:
sonar-scanner \
-Dsonar.projectKey=ctest \
-Dsonar.organization=<orgname> \
-Dsonar.sources=. \
-Dsonar.cfamily.build-wrapper-output=bw-output \
-Dsonar.host.url=https://sonarcloud.io \
-Dsonar.login=<tokenvalue>
Output of both parameters looks fine. Unfortunately, it doesn't detect these fairly obvious errors:
What am I doing wrong so sonarcloud will pick them up?