diff mbox

[edk2] ArmPlatformPkg/NorFlashDxe: eliminate void pointer arithmetic

Message ID 1477314075-18874-1-git-send-email-ard.biesheuvel@linaro.org
State Accepted
Commit 60d9f5f43bbb7e0a859c1f744a20cee88af9c863
Headers show

Commit Message

Ard Biesheuvel Oct. 24, 2016, 1:01 p.m. UTC
While most compilers happily allow arithmetic on void pointer,
the RVCT compiler does not, and throws the following warning for
NorFlashDxe:

  ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c(894,48) :
  error  #1254-D: arithmetic on pointer to void or function type

Since the expression in question involves a cast from UINTN to VOID*,
simply add some parentheses to eliminate this warning.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

---
 ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.7.4

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel

Comments

Laszlo Ersek Oct. 24, 2016, 1:05 p.m. UTC | #1
On 10/24/16 15:01, Ard Biesheuvel wrote:
> While most compilers happily allow arithmetic on void pointer,

> the RVCT compiler does not, and throws the following warning for

> NorFlashDxe:

> 

>   ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c(894,48) :

>   error  #1254-D: arithmetic on pointer to void or function type

> 

> Since the expression in question involves a cast from UINTN to VOID*,

> simply add some parentheses to eliminate this warning.

> 

> Contributed-under: TianoCore Contribution Agreement 1.0

> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

> ---

>  ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c | 2 +-

>  1 file changed, 1 insertion(+), 1 deletion(-)

> 

> diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c

> index ca61ac5e1983..1098d9501cc7 100644

> --- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c

> +++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c

> @@ -891,7 +891,7 @@ NorFlashRead (

>    SEND_NOR_COMMAND (Instance->DeviceBaseAddress, 0, P30_CMD_READ_ARRAY);

>  

>    // Readout the data

> -  AlignedCopyMem (Buffer, (VOID *)StartAddress + Offset, BufferSizeInBytes);

> +  AlignedCopyMem (Buffer, (VOID *)(StartAddress + Offset), BufferSizeInBytes);

>  

>    return EFI_SUCCESS;

>  }

> 


Reviewed-by: Laszlo Ersek <lersek@redhat.com>

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Ryan Harkin Oct. 24, 2016, 3:36 p.m. UTC | #2
On 24 October 2016 at 14:05, Laszlo Ersek <lersek@redhat.com> wrote:
> On 10/24/16 15:01, Ard Biesheuvel wrote:

>> While most compilers happily allow arithmetic on void pointer,

>> the RVCT compiler does not, and throws the following warning for

>> NorFlashDxe:

>>

>>   ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c(894,48) :

>>   error  #1254-D: arithmetic on pointer to void or function type

>>

>> Since the expression in question involves a cast from UINTN to VOID*,

>> simply add some parentheses to eliminate this warning.

>>

>> Contributed-under: TianoCore Contribution Agreement 1.0

>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

>> ---

>>  ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c | 2 +-

>>  1 file changed, 1 insertion(+), 1 deletion(-)

>>

>> diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c

>> index ca61ac5e1983..1098d9501cc7 100644

>> --- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c

>> +++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c

>> @@ -891,7 +891,7 @@ NorFlashRead (

>>    SEND_NOR_COMMAND (Instance->DeviceBaseAddress, 0, P30_CMD_READ_ARRAY);

>>

>>    // Readout the data

>> -  AlignedCopyMem (Buffer, (VOID *)StartAddress + Offset, BufferSizeInBytes);

>> +  AlignedCopyMem (Buffer, (VOID *)(StartAddress + Offset), BufferSizeInBytes);

>>

>>    return EFI_SUCCESS;

>>  }

>>

>

> Reviewed-by: Laszlo Ersek <lersek@redhat.com>

Reviewed-by: Ryan Harkin <ryan.harkin@linaro.org>


> _______________________________________________

> edk2-devel mailing list

> edk2-devel@lists.01.org

> https://lists.01.org/mailman/listinfo/edk2-devel

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Ard Biesheuvel Oct. 24, 2016, 4:25 p.m. UTC | #3
On 24 October 2016 at 16:36, Ryan Harkin <ryan.harkin@linaro.org> wrote:
> On 24 October 2016 at 14:05, Laszlo Ersek <lersek@redhat.com> wrote:

>> On 10/24/16 15:01, Ard Biesheuvel wrote:

>>> While most compilers happily allow arithmetic on void pointer,

>>> the RVCT compiler does not, and throws the following warning for

>>> NorFlashDxe:

>>>

>>>   ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c(894,48) :

>>>   error  #1254-D: arithmetic on pointer to void or function type

>>>

>>> Since the expression in question involves a cast from UINTN to VOID*,

>>> simply add some parentheses to eliminate this warning.

>>>

>>> Contributed-under: TianoCore Contribution Agreement 1.0

>>> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

>>> ---

>>>  ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c | 2 +-

>>>  1 file changed, 1 insertion(+), 1 deletion(-)

>>>

>>> diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c

>>> index ca61ac5e1983..1098d9501cc7 100644

>>> --- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c

>>> +++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c

>>> @@ -891,7 +891,7 @@ NorFlashRead (

>>>    SEND_NOR_COMMAND (Instance->DeviceBaseAddress, 0, P30_CMD_READ_ARRAY);

>>>

>>>    // Readout the data

>>> -  AlignedCopyMem (Buffer, (VOID *)StartAddress + Offset, BufferSizeInBytes);

>>> +  AlignedCopyMem (Buffer, (VOID *)(StartAddress + Offset), BufferSizeInBytes);

>>>

>>>    return EFI_SUCCESS;

>>>  }

>>>

>>

>> Reviewed-by: Laszlo Ersek <lersek@redhat.com>

> Reviewed-by: Ryan Harkin <ryan.harkin@linaro.org>

>


Pushed, thanks all
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
diff mbox

Patch

diff --git a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c
index ca61ac5e1983..1098d9501cc7 100644
--- a/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c
+++ b/ArmPlatformPkg/Drivers/NorFlashDxe/NorFlashDxe.c
@@ -891,7 +891,7 @@  NorFlashRead (
   SEND_NOR_COMMAND (Instance->DeviceBaseAddress, 0, P30_CMD_READ_ARRAY);
 
   // Readout the data
-  AlignedCopyMem (Buffer, (VOID *)StartAddress + Offset, BufferSizeInBytes);
+  AlignedCopyMem (Buffer, (VOID *)(StartAddress + Offset), BufferSizeInBytes);
 
   return EFI_SUCCESS;
 }