Make the type of this parameter a pointer-to-const when declaring FreeRTOS task

  • Operating system: Windows 10
  • IDE name and flavor/env: VSCode 1.8.7

I am using SonarLint on VSCode. We use this for our esp-idf projects writing code in C language. I have noticed weird warning when declaring a FreeRTOS task and made a post about it on the ESP32 forums:

After some discussion, it has been suggested that this is a false warning. I have also found another similar instance of this warning: … st/58181/3

My full code is as following:

#include <stdio.h>
#include <inttypes.h>
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_chip_info.h"
#include "esp_flash.h"

#define UNUSED(x) (void)(x)

static void HELLO_TASK(void *param);

void app_main(void)
    printf("Hello world!\n");
    // Create hello world task
    xTaskCreate(&HELLO_TASK, "HELLO_TASK", 4096, NULL, 3, NULL);


static void HELLO_TASK(void *param)
    for (;;)
        printf("This is normal message1 without ANSI color code \n");
        vTaskDelay(1000 / portTICK_PERIOD_MS);

And it shows up 1 warning:

Make the type of this parameter a pointer-to-const. The current type of "param" is "void *".

But that does not seem correct. Why would I need to to make it const void *param? Is that a valid warning?

Hello @Krupis,

We agree that this is a false positive. We track this known issue under [CPP-2782] - Jira.

Thanks for reporting this case. It will help us validate our solution when we implement a fix.


The Jira ticket that you have linked is from 2020.
Has there really been no attempt to fix the issue in 4 years?

Hello @Krupis

According to our data, the rule is pretty well accepted, so the topic did not bubble up often enough to get prioritized.

That said, reports like yours have an impact on the prioritization, so I would not draw a strong conclusion from our past efforts.


1 Like