xTaskCreateStatic MISRA2012 Rules compatibility

Hi all,

I am checking my code according to MISRAC2012. When I controlled xTaskCreateStatic function, "Conversion between a void pointer and an object of aritmetic type " (MISRAC2012-Rule-11.6) warning shows to me. Is there any method to avoid this warning.

Additional Note 1: My freeRTOS code will convert to safeRTOS after complete developing process. Can safeRTOS handle this warning ?

Additional Note 2: This warning (MISRAC2012-Rule-11.6) point to (void*)1 parameter in the xTaskCreateStatic function.

Best Regards.

There is only one parameter that is a void *, which is pvParameters. Is the warning generated where you are passing a value into that parameter?

I think the issue you are pointing to is the void* parameter to a task, which perhaps some demos or some applications would prefer to not send a ‘pointer’ value, but a small integer.

By the C language definition, this is not ‘defined’ behavior that works for all implementations, and there are (or have been) machines where converting certain integral values to a pointer would not get you back the same value when converted back, or might ‘trap’ when converting some values to pointers. This is why MISRA ‘bans’ the use of such behavior, and MISRA checkers will flag it.

On many machines. such a conversion actually works in practice, which is why it is sometimes done. The ‘Standards Compliant’ method would be to create a variable of know type with the value and pass the address of that variable, and convert the received pointer to a pointer to that type and access the value.

The other option is to just accept that on your platform it ‘works’ so you accept that you are doing something not by the Standard but works in your case, and accept the warning and add the needed documentation (if any is needed) noting why you are breaking the ‘rule’

Depending on the tool you are using, you might be able to add some special command/comment at that point in the code to suppress the warning.