[Yaffs] Fix enum overflow bug

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Charles Manning
Date:  
To: yaffs
Subject: [Yaffs] Fix enum overflow bug
Hi All

I have fixed a problem that was being experienced with some compilers

In the definition of yaffs_BlockInfo there's a 4-bit wide field for bolding
the block state. This can be any value from 0..9 which one might hope would
fit into a 4-bit field.

Some compilers (eg. gcc) use unsigned values for enum bitfields unless one or
more of the enum entries are negative, in which case the a signed value is
used.

Some compilers (eg. MS xxx) will always use a signed value for enum bitfields
which

This means that compilations generating signed values would not work properly.

This has since been fixed by using an unsigned field instead of the enum.

diff -r1.27 yaffs_guts.h
274c274
<       yaffs_BlockState blockState:4;  /* One of the above block states */
---

>       __u32 blockState:4;     /* One of the above block states. NB use 

unsigned because enum is sometimes an int */


-- Charles