This is the mail archive of the
ecos-discuss@sourceware.org
mailing list for the eCos project.
Re: Redboot size_t signedness issue
- From: Gary Thomas <gary at mlbassoc dot com>
- To: Stanislav Meduna <stano at meduna dot org>
- Cc: eCos Discussion <ecos-discuss at ecos dot sourceware dot org>
- Date: Mon, 22 Jun 2009 06:31:43 -0600
- Subject: Re: [ECOS] Redboot size_t signedness issue
- References: <4A3F5565.3060607@meduna.org>
Stanislav Meduna wrote:
> Hi,
>
> in the packages\redboot\...\fconfig.c there is a check
>
> if ((fisdir_size-cfg_size) < (CYGNUM_REDBOOT_FIS_DIRECTORY_ENTRY_COUNT *
> CYGNUM_REDBOOT_FIS_DIRECTORY_ENTRY_SIZE)) {
> // Too bad this can't be checked at compile/build time
> diag_printf("Sorry, FLASH config exceeds available space in FIS directory\n");
> return;
> }
>
> This check does not work if the size_t is unsigned (which it happens
> to be in the distributed arm-eabi-gcc 4.3.2) and cfg_size
> is larger than fisdir_size.
>
> Casting the cfg_size to int resolves the problem.
>
> if ((fisdir_size-(int) cfg_size) < ...
A better solution would be to remove any signed/unsigned ambiguity.
This test can be written equivalently as:
if (((CYGNUM_REDBOOT_FIS_DIRECTORY_ENTRY_COUNT * CYGNUM_REDBOOT_FIS_DIRECTORY_ENTRY_SIZE) + cfg_size) > fisdir_size) {
If you can try this to see if it works on your setup, I'll commit
a proper change/patch.
--
------------------------------------------------------------
Gary Thomas | Consulting for the
MLB Associates | Embedded world
------------------------------------------------------------
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss