I just tried to port the new version 8.1.1 to my hobby project.
I use the toolchain Sourcery CodeBench Lite Edition for ARM EABI (GCC based, for ARM), my compiler settings are very strict (each warning is treated as an error) and it returns the following error when compiling tasks.c:
arm-none-eabi-gcc -c -mcpu=arm926ej-s -Wall -Wextra -Werror -IFreeRTOS/Source/include/ -IDemo/ -IFreeRTOS/Source/portable/GCC/ARM926EJ-S/ FreeRTOS/Source/tasks.c -o obj/tasks.o
FreeRTOS/Source/tasks.c: In function 'pvTaskIncrementMutexHeldCount':
FreeRTOS/Source/tasks.c:3604:1: error: control reaches end of non-void function [-Werror=return-type]
cc1: all warnings being treated as errors
In other words, when configUSE_MUTEXES is not set, the function pvTaskIncrementMutexHeldCount does not return anzthing although it is declared to return a void* casted pointer.
My temporary workaround is to return NULL in such cases (as implemented here). Anyway, I would like to hear what is supposed to be returned at such an occasion (maybe pxCurrentTCB?) so that I can fix it ASAP.
BTW, how come, this wasn't detected by compilers that support MISRA standards?
Probably because when configUSE_MUTEXES is not set pvTaskIncrementMutexHeldCount() is never called and there is no path to it for the checker. Because of that it is not actually possible for control to reach the end of the function without returning something because the function is not called and in most cases the symbol will not be in the binary.
All the same, something should be done to remove the warning.
If pvTaskIncrementMutexCount() is never called if configUSEMUTEXES is not defined, then pvTaskIncrementMutexCount itself should not be defined if configUSEMUTEXES is not defined.
Probably because when configUSE_MUTEXES is not set pvTaskIncrementMutexHeldCount() is
never called and there is no path to it for the checker
Actually a simpler reason than that - the checking is done with all options turned on so it views the code without the conditional compilation.
If pvTaskIncrementMutexCount() is never called if configUSEMUTEXES is not defined,
then pvTaskIncrementMutexCount itself should not be defined if configUSEMUTEXES is
I think in the original 8.1.0 implementation there was a reason why that was not done, but I would agree with you now.
The change to completely compile out the pvTaskIncrementMutexHeldCount() function when configUSE_MUTEXES is not defined will not change the behaviour of the code at all, and will not change anybodies binaries built from the code. That considered, plus the fact that 8.1.1 has only just been uploaded during the weekend and not announced, I will simply overwrite the 8.1.1 zip file in SourceForge with the version that does not generate the warning.
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.