diff mbox series

[edk2,edk2-staging,13/19] IntelUndiPkg/GigUndiDxe: don't take address of cast expression

Message ID 20181106175833.26964-14-ard.biesheuvel@linaro.org
State New
Headers show
Series IntelUndiPkg/GigUndiDxe: build fixes for AARCH64/ARM/GCC | expand

Commit Message

Ard Biesheuvel Nov. 6, 2018, 5:58 p.m. UTC
Taking the address of a cast expression is not permitted in C. Instead,
take the address of the variable, and cast the pointer to the desired
pointer type.

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

---
 IntelUndiPkg/GigUndiDxe/e1000.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

-- 
2.19.1

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

Comments

Philippe Mathieu-Daudé Nov. 6, 2018, 8:36 p.m. UTC | #1
On 6/11/18 18:58, Ard Biesheuvel wrote:
> Taking the address of a cast expression is not permitted in C. Instead,
> take the address of the variable, and cast the pointer to the desired
> pointer type.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>

> ---
>   IntelUndiPkg/GigUndiDxe/e1000.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/IntelUndiPkg/GigUndiDxe/e1000.c b/IntelUndiPkg/GigUndiDxe/e1000.c
> index 4c9a06b8cf73..28c900e3ad63 100644
> --- a/IntelUndiPkg/GigUndiDxe/e1000.c
> +++ b/IntelUndiPkg/GigUndiDxe/e1000.c
> @@ -1107,7 +1107,7 @@ E1000TxRxConfigure (
>     // Set the MemPtr to the high dword of the rx_ring so we can store it in RDBAH0.
>     // Right shifts do not seem to work with the EFI compiler so we do it like this for now.
>     MemAddr = (UINT64) (UINTN) GigAdapter->RxRing.PhysicalAddress;
> -  MemPtr  = &((UINT32) MemAddr);
> +  MemPtr  = (UINT32 *)&MemAddr;
>     MemPtr++;
>     E1000_WRITE_REG (&GigAdapter->Hw, E1000_RDBAH (0), *MemPtr);
>   
> @@ -1185,7 +1185,7 @@ E1000TxRxConfigure (
>   
>     E1000_WRITE_REG (&GigAdapter->Hw, E1000_TDBAL (0), (UINT32) (UINTN) (GigAdapter->TxRing.PhysicalAddress));
>     MemAddr = (UINT64) (UINTN) GigAdapter->TxRing.PhysicalAddress;
> -  MemPtr  = &((UINT32) MemAddr);
> +  MemPtr  = (UINT32 *)&MemAddr;
>     MemPtr++;
>     E1000_WRITE_REG (&GigAdapter->Hw, E1000_TDBAH (0), *MemPtr);
>     DEBUGPRINT (E1000, ("TdBah0 %X\n", *MemPtr));
>
Ryszard Knop Jan. 30, 2019, 1:41 p.m. UTC | #2
Reviewed-by: Ryszard Knop <ryszard.knop@linux.intel.com>


On Tue, 2018-11-06 at 18:58 +0100, ard.biesheuvela wrote:
> Taking the address of a cast expression is not permitted in C.

> Instead,

> take the address of the variable, and cast the pointer to the desired

> pointer type.

> 

> Contributed-under: TianoCore Contribution Agreement 1.1

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

> ---

>  IntelUndiPkg/GigUndiDxe/e1000.c | 4 ++--

>  1 file changed, 2 insertions(+), 2 deletions(-)

> 

> diff --git a/IntelUndiPkg/GigUndiDxe/e1000.c

> b/IntelUndiPkg/GigUndiDxe/e1000.c

> index 4c9a06b8cf73..28c900e3ad63 100644

> --- a/IntelUndiPkg/GigUndiDxe/e1000.c

> +++ b/IntelUndiPkg/GigUndiDxe/e1000.c

> @@ -1107,7 +1107,7 @@ E1000TxRxConfigure (

>    // Set the MemPtr to the high dword of the rx_ring so we can store

> it in RDBAH0.

>    // Right shifts do not seem to work with the EFI compiler so we do

> it like this for now.

>    MemAddr = (UINT64) (UINTN) GigAdapter->RxRing.PhysicalAddress;

> -  MemPtr  = &((UINT32) MemAddr);

> +  MemPtr  = (UINT32 *)&MemAddr;

>    MemPtr++;

>    E1000_WRITE_REG (&GigAdapter->Hw, E1000_RDBAH (0), *MemPtr);

>  

> @@ -1185,7 +1185,7 @@ E1000TxRxConfigure (

>  

>    E1000_WRITE_REG (&GigAdapter->Hw, E1000_TDBAL (0), (UINT32)

> (UINTN) (GigAdapter->TxRing.PhysicalAddress));

>    MemAddr = (UINT64) (UINTN) GigAdapter->TxRing.PhysicalAddress;

> -  MemPtr  = &((UINT32) MemAddr);

> +  MemPtr  = (UINT32 *)&MemAddr;

>    MemPtr++;

>    E1000_WRITE_REG (&GigAdapter->Hw, E1000_TDBAH (0), *MemPtr);

>    DEBUGPRINT (E1000, ("TdBah0 %X\n", *MemPtr));


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

Patch

diff --git a/IntelUndiPkg/GigUndiDxe/e1000.c b/IntelUndiPkg/GigUndiDxe/e1000.c
index 4c9a06b8cf73..28c900e3ad63 100644
--- a/IntelUndiPkg/GigUndiDxe/e1000.c
+++ b/IntelUndiPkg/GigUndiDxe/e1000.c
@@ -1107,7 +1107,7 @@  E1000TxRxConfigure (
   // Set the MemPtr to the high dword of the rx_ring so we can store it in RDBAH0.
   // Right shifts do not seem to work with the EFI compiler so we do it like this for now.
   MemAddr = (UINT64) (UINTN) GigAdapter->RxRing.PhysicalAddress;
-  MemPtr  = &((UINT32) MemAddr);
+  MemPtr  = (UINT32 *)&MemAddr;
   MemPtr++;
   E1000_WRITE_REG (&GigAdapter->Hw, E1000_RDBAH (0), *MemPtr);
 
@@ -1185,7 +1185,7 @@  E1000TxRxConfigure (
 
   E1000_WRITE_REG (&GigAdapter->Hw, E1000_TDBAL (0), (UINT32) (UINTN) (GigAdapter->TxRing.PhysicalAddress));
   MemAddr = (UINT64) (UINTN) GigAdapter->TxRing.PhysicalAddress;
-  MemPtr  = &((UINT32) MemAddr);
+  MemPtr  = (UINT32 *)&MemAddr;
   MemPtr++;
   E1000_WRITE_REG (&GigAdapter->Hw, E1000_TDBAH (0), *MemPtr);
   DEBUGPRINT (E1000, ("TdBah0 %X\n", *MemPtr));