Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT




Loading

Compiler warnings

Posted by Paul_Piak on August 1, 2008
Hi

I consider it good practice to have the warning level set to maximum
I always get the following warnings:
C:\dev\FreeRTOS\Source\list.c:64:Warning [2066] type qualifier mismatch in assignment
C:\dev\FreeRTOS\Source\list.c:72:Warning [2066] type qualifier mismatch in assignment
C:\dev\FreeRTOS\Source\list.c:73:Warning [2066] type qualifier mismatch in assignment
C:\dev\FreeRTOS\Source\list.c:130:Warning [2066] type qualifier mismatch in assignment
These are cause by a missing 'volatile' in the casting.
The target variables of the assignments on these lines are volatile xListItem *, but the applied casting is only (xListItem *)
This should be (volatile xListItem *)

I also get
C:\dev\FreeRTOS\Source\tasks.c:461:Warning [2066] type qualifier mismatch in assignment\
Which also need a volatile prefix:
pxTopOfStack is defined (volatile portSTACK_TYPE *), but a (portSTACK_TYPE *) is assigned to it. That should be (volatile portSTACK_TYPE *)

This should be the same on all platforms (not only C18 which I use) since list.c and tasks.c are shared among all platforms.

Paul

RE: Compiler warnings

Posted by Richard on August 1, 2008
> The target variables of the assignments on these lines are
> volatile xListItem *, but the applied casting is only
> (xListItem *) This should be (volatile xListItem *)


In which case other compilers used to compile FreeRTOS.org will complain about "meaningless qualifier on cast". Can't win there I'm afraid.


> I also get
> C:\dev\FreeRTOS\Source\tasks.c:461:Warning [2066] type
> qualifier mismatch in assignment\ Which also need a volatile prefix:
> pxTopOfStack is defined (volatile portSTACK_TYPE *), but a
> (portSTACK_TYPE *) is assigned to it. That should be
> (volatile portSTACK_TYPE *)


Likewise.


>
> This should be the same on all platforms

...but it isn’t, unfortunately.

The C18 compiler is not exactly standard in any case.

Regards.

RE: Compiler warnings

Posted by Paul_Piak on August 1, 2008
Of course I'm wrong, how could this have slipped other peoples attention? ;-(

RE: Compiler warnings

Posted by incrediball on August 4, 2008
I think Paul does have a valid point. The warning that Paul spoke of is a valid warning in my opinion, since the volatile qualifier in a cast may determine what sort of code the compiler generates. Perhaps not in this case since both sides of the assignment are volatile but strictly speaking the right hand side of the assignment is not the same type as the left side and if a programmer forgets a volatile qualifier elsewhere, such warnings may be overlooked, perhaps resulting in nasty hard-to-find bugs.

The warning "meaningless qualifier on cast" is a warning that I consider as being meaningless in itself. Actually I think the warning is plainly wrong! Perhaps it was meaningless for that particular implementation of a C compiler but I think someone was being pedantic when they implemented that one. In other words, perhaps the volatile should be added in which case a more serious warning will be replaced by a less serious (and meaningless/wrong) one.

gcc also issues warnings on the same four lines ("dereferencing type-punned pointer will break strict-aliasing rules")...

RE: Compiler warnings

Posted by incrediball on August 4, 2008
Another thought...

The existing casts require that the members of xMiniListItem exactly overlap the first three members of xListItem but are there any guarantees that this is always the case with every compiler?

Wouldn't it be better to replace the xItemValue, pxNext and pxPrevious members of xListItem with a nested xMiniListItem? This would get rid of the troublesome type casts altogether.


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Latest News

FreeRTOS kernel V10 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

OpenRTOS and SafeRTOS