Please fix the following new warnings (compiled with GCC 5.4.1 and our standard warning set):
+++ compile: src/lib/FreeRTOS/stream_buffer.c
src/lib/FreeRTOS/stream_buffer.c: In function 'xStreamBufferGenericCreate':
src/lib/FreeRTOS/stream_buffer.c(247) :34: warning: cast increases required alignment of target type [-Wcast-align]
prvInitialiseNewStreamBuffer( ( StreamBuffer_t * ) pucAllocatedMemory, / Structure at the start of the allocated memory. / /lint !e9087 Safe cast as allocated memory is aligned. / /lint !e826 Area is not too small and alignment is guaranteed provided malloc() behaves as expected and returns aligned buffer. /
^
src/lib/FreeRTOS/stream_buffer.c(260) :10: warning: cast increases required alignment of target type [-Wcast-align]
return ( StreamBufferHandle_t * ) pucAllocatedMemory; /lint !e9087 !e826 Safe cast as allocated memory is aligned. /
^
The next two are long standing warnings I have to patch in ervery version:
+++ compile: src/lib/FreeRTOS/tasks.c
src/lib/FreeRTOS/tasks.c: In function 'xTaskGenericNotify':
src/lib/FreeRTOS/tasks.c(4580) :4: warning: switch missing default case [-Wswitch-default]
switch( eAction )
^
src/lib/FreeRTOS/tasks.c: In function 'xTaskGenericNotifyFromISR':
src/lib/FreeRTOS/tasks.c(4705) :4: warning: switch missing default case [-Wswitch-default]
switch( eAction )
^
Would be handy to provide a default case for the sake of cleanness. Thanks!
Regarding the byte alignment - that warning can probably be fixed by saving the returned value of malloc() directly into a StreamBuffer_t pointer, would have to try. However, the a the lack of default case is deliberate as the switch is on an enum type, and there is a case for each possible input. Providing a default case would therefore cause other warnings, also in lint, as the code would not be reachable.
Regarding the missing switch default case, I recommend to replace the "case eNoAction" with the "default" case. This way, all enum values are covered and illegal states (if so) are properly handled - even if the default just consists of a "break" only.
Best regards and thanks a lot for a cool v10!
I had the same compiler warning. Richard is correct that it can be fixed by using a StreamBuffer_t pointer. I've attached an updated version of xStreamBufferGenericCreate that does not produce the warning.
Thanks for the suggested update, but in this case I'm not sure the code:
"( uint8_t * ) ( pxAllocatedMemory + sizeof( StreamBuffer_t ) )"
in the call to prvInitialiseNewStreamBuffer() is going to result in the correct address as you are adding to a pointer to a structure, rather than a pointer to a char now.
Perhaps the thing to do here is use the changes as per your suggestion other than on that line - then on that line use a cast to a char * - that would make the purpose using of char * more explicit.
Oops, that would be an issue. Are you suggesting just dropping the parentheses, like so:
( uint8_t * ) pxAllocatedMemory + sizeof( StreamBuffer_t )
I suppose you could also use:
( uint8_t * ) ( pxAllocatedMemory + 1 )
I agree that the first way makes the intent clearer.