On 02/12/14 06:33, Scott Duplichan wrote:
> Laszlo Ersek [mailto:[email protected]] wrote:
> 
> [...]
> 
> ]>    Dev->BlockIoMedia.LogicalPartition = FALSE;
> ]> -  Dev->BlockIoMedia.ReadOnly         = !!(Features & VIRTIO_BLK_F_RO);
> ]> -  Dev->BlockIoMedia.WriteCaching     = !!(Features & VIRTIO_BLK_F_FLUSH);
> ]> +  Dev->BlockIoMedia.ReadOnly         = (BOOLEAN) !!(Features &
> ]> +                                                    VIRTIO_BLK_F_RO);
> ]> +  Dev->BlockIoMedia.WriteCaching     = (BOOLEAN) !!(Features &
> ]> +                                                    VIRTIO_BLK_F_FLUSH);
> ]
> ]No need for the double logical negation (ie. !!) when there is an
> ]explicit cast to BOOLEAN.
> 
> This would be true if EDK2 defined BOOLEAN as a real C99 _Bool. But for
> compatibility with VS2005, EDK2 typedefs BOOLEAN to uint8_t. As a
> result, the following always evaluates to zero:
> 
>     (BOOLEAN) (Features & VIRTIO_BLK_F_FLUSH);
> 
> This is because VIRTIO_BLK_F_FLUSH is 0x200 and casting the bitwise and
> result to BOOLEAN is the same as casting 0 or 0x200 to uint8_t. On
> the other hand, this C99 code gives the intended result:
> 
>     (_Bool) (Features & VIRTIO_BLK_F_FLUSH);
> 
> Anyone who is accustomed to the behavior of C99 _Bool (bool) must remember
> that EDK2 BOOLEAN is something different (a cast to uint8_t).

Correct. I realized it this morning and logged in just to retract it, so
apologies to Jordan -- this point in my review was fully bogus. I
operated with the standard C99 _Bool (bool) conversion rule (see
6.3.1.2). I reviewed 50+ patches last week (and part of it was during
devconf.cz) and now I couldn't switch to edk2. I probably need to give
it a rest for a few days.

Thanks!
Laszlo

------------------------------------------------------------------------------
Android apps run on BlackBerry 10
Introducing the new BlackBerry 10.2.1 Runtime for Android apps.
Now with support for Jelly Bean, Bluetooth, Mapview and more.
Get your Android app in front of a whole new audience.  Start now.
http://pubads.g.doubleclick.net/gampad/clk?id=124407151&iu=/4140/ostg.clktrk
_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to