Quality RTOS & Embedded Software

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




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) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

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

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

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

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists