Re: [Edk2 Dev] We are having a few portability issues with enums...

Subject: Re: [Edk2 Dev] We are having a few portability issues with enums...

From: Andrew Fish <afish@apple.com>

To: dev@edk2.tianocore.org

Date: 2008-05-28 21:56:23

Any idea how to disable this warning.

Andrew Fish
afish@apple.com
Work iPhone: 360-259-7562




On May 28, 2008, at 1:21 PM, Kinney, Michael D wrote:

> Andrew,
>
> If the calling code is compiled in the same module as the called code,
> then a compiler could do this check.
>
> However, if there is a possibility that the calling module is built  
> with
> a compiler that does not perform range checking on enum parameters,  
> then
> performing a range check in the called code is appropriate.
>
> CoreAllocateSpace() is used as part of the DXE Services that are
> exported by the DXE Core, so the range checking is required to make  
> sure
> an external module using those services passes in correct parameters.
>
> This may be a warning we want to disable on GCC.
>
> Mike
>
>
> -----Original Message-----
> From: Andrew Fish [mailto:afish@apple.com]
> Sent: Wednesday, May 28, 2008 12:45 PM
> To: dev@edk2.tianocore.org
> Subject: [Edk2 Dev] We are having a few portability issues with  
> enums...
>
> When we throw a new GCC  compiler  version at this library function we
> get the following error:
> warning: comparison is always true due to limited range of data type
>
> EFI_STATUS
> IpIoGetIcmpErrStatus (
>   IN  ICMP_ERROR  IcmpError,
>   OUT BOOLEAN     *IsHard, OPTIONAL
>   OUT BOOLEAN     *Notify OPTIONAL
>   )
> {
>   ASSERT ((IcmpError >= ICMP_ERR_UNREACH_NET) && (IcmpError <=
> ICMP_ERR_PARAMPROB));
>
>
> We also see this problem in the DXE Core:
>
> STATIC
> EFI_STATUS
> CoreAllocateSpace (
>   IN     UINTN                  Operation,
>   IN     EFI_GCD_ALLOCATE_TYPE  GcdAllocateType,
>   IN     EFI_GCD_MEMORY_TYPE    GcdMemoryType,
>   IN     EFI_GCD_IO_TYPE        GcdIoType,
>   IN     UINTN                  Alignment,
>   IN     UINT64                 Length,
>   IN OUT EFI_PHYSICAL_ADDRESS   *BaseAddress,
>   IN     EFI_HANDLE             ImageHandle,
>   IN     EFI_HANDLE             DeviceHandle OPTIONAL
>   )
> {
>   EFI_STATUS            Status;
>   EFI_PHYSICAL_ADDRESS  AlignmentMask;
>   EFI_PHYSICAL_ADDRESS  MaxAddress;
>   LIST_ENTRY            *Map;
>   LIST_ENTRY            *Link;
>   LIST_ENTRY            *SubLink;
>   EFI_GCD_MAP_ENTRY     *Entry;
>   EFI_GCD_MAP_ENTRY     *TopEntry;
>   EFI_GCD_MAP_ENTRY     *BottomEntry;
>   LIST_ENTRY            *StartLink;
>   LIST_ENTRY            *EndLink;
>   BOOLEAN               Found;
>
>   //
>   // Make sure parameters are valid
>   //
>   if (GcdAllocateType < 0 || GcdAllocateType >=
> EfiGcdMaxAllocateType) {
>     return EFI_INVALID_PARAMETER;
>   }
>   if (GcdMemoryType < 0 || GcdMemoryType >= EfiGcdMemoryTypeMaximum) {
>     return EFI_INVALID_PARAMETER;
>   }
>   if (GcdIoType < 0 || GcdIoType >= EfiGcdIoTypeMaximum) {
>     return EFI_INVALID_PARAMETER;
>   }
>
> Seems the compiler is pointing out if the parameter is really a valid
> enum it would never be out of range.
>
> Any one got an idea on how to fix this? The only thing I can think of
> is not using enums are parameters.
>
> Andrew Fish
> afish@apple.com
> Work iPhone: 360-259-7562
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@edk2.tianocore.org
> For additional commands, e-mail: dev-help@edk2.tianocore.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@edk2.tianocore.org
> For additional commands, e-mail: dev-help@edk2.tianocore.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@edk2.tianocore.org
For additional commands, e-mail: dev-help@edk2.tianocore.org