diff mbox series

[edk2,edk2-staging,12/20] IntelUndiPkg/XGigUndiDxe: don't take address of cast expression

Message ID 20181115023353.20159-13-ard.biesheuvel@linaro.org
State New
Headers show
Series IntelUndiPkg/XGigUndiDxe: fix GCC / ARM build issues | expand

Commit Message

Ard Biesheuvel Nov. 15, 2018, 2:33 a.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/XGigUndiDxe/Xgbe.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

-- 
2.17.1

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

Comments

Ryszard Knop Jan. 30, 2019, 4:20 p.m. UTC | #1
Reviewed-by: Ryszard Knop <ryszard.knop@linux.intel.com>


On Wed, 2018-11-14 at 18:33 -0800, 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/XGigUndiDxe/Xgbe.c | 4 ++--

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

> 

> diff --git a/IntelUndiPkg/XGigUndiDxe/Xgbe.c

> b/IntelUndiPkg/XGigUndiDxe/Xgbe.c

> index 0c823efe8963..003c3b9065ec 100644

> --- a/IntelUndiPkg/XGigUndiDxe/Xgbe.c

> +++ b/IntelUndiPkg/XGigUndiDxe/Xgbe.c

> @@ -1264,7 +1264,7 @@ XgbeTxRxConfigure (

>    IXGBE_WRITE_REG (&XgbeAdapter->Hw, IXGBE_RDBAL (0), (UINT32)

> (UINTN) (XgbeAdapter->RxRing.PhysicalAddress));

>  

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

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

> +  MemPtr  = (UINT32 *) &MemAddr;

>    MemPtr++;

>    IXGBE_WRITE_REG (&XgbeAdapter->Hw, IXGBE_RDBAH (0), *MemPtr);

>    DEBUGPRINT (XGBE, ("Rdbal0 %X\n", (UINT32) IXGBE_READ_REG

> (&XgbeAdapter->Hw, IXGBE_RDBAL (0))));

> @@ -1337,7 +1337,7 @@ XgbeTxRxConfigure (

>    XgbeAdapter->XmitDoneHead = 0;  // the last cleaned buffer

>    IXGBE_WRITE_REG (&XgbeAdapter->Hw, IXGBE_TDBAL (0), (UINT32)

> (XgbeAdapter->TxRing.PhysicalAddress));

>    MemAddr = (UINT64) XgbeAdapter->TxRing.PhysicalAddress;

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

> +  MemPtr  = (UINT32 *) &MemAddr;

>    MemPtr++;

>    IXGBE_WRITE_REG (&XgbeAdapter->Hw, IXGBE_TDBAH (0), *MemPtr);

>    DEBUGPRINT (XGBE, ("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/XGigUndiDxe/Xgbe.c b/IntelUndiPkg/XGigUndiDxe/Xgbe.c
index 0c823efe8963..003c3b9065ec 100644
--- a/IntelUndiPkg/XGigUndiDxe/Xgbe.c
+++ b/IntelUndiPkg/XGigUndiDxe/Xgbe.c
@@ -1264,7 +1264,7 @@  XgbeTxRxConfigure (
   IXGBE_WRITE_REG (&XgbeAdapter->Hw, IXGBE_RDBAL (0), (UINT32) (UINTN) (XgbeAdapter->RxRing.PhysicalAddress));
 
   MemAddr = (UINT64) (UINTN) XgbeAdapter->RxRing.PhysicalAddress;
-  MemPtr  = &((UINT32) MemAddr);
+  MemPtr  = (UINT32 *) &MemAddr;
   MemPtr++;
   IXGBE_WRITE_REG (&XgbeAdapter->Hw, IXGBE_RDBAH (0), *MemPtr);
   DEBUGPRINT (XGBE, ("Rdbal0 %X\n", (UINT32) IXGBE_READ_REG (&XgbeAdapter->Hw, IXGBE_RDBAL (0))));
@@ -1337,7 +1337,7 @@  XgbeTxRxConfigure (
   XgbeAdapter->XmitDoneHead = 0;  // the last cleaned buffer
   IXGBE_WRITE_REG (&XgbeAdapter->Hw, IXGBE_TDBAL (0), (UINT32) (XgbeAdapter->TxRing.PhysicalAddress));
   MemAddr = (UINT64) XgbeAdapter->TxRing.PhysicalAddress;
-  MemPtr  = &((UINT32) MemAddr);
+  MemPtr  = (UINT32 *) &MemAddr;
   MemPtr++;
   IXGBE_WRITE_REG (&XgbeAdapter->Hw, IXGBE_TDBAH (0), *MemPtr);
   DEBUGPRINT (XGBE, ("TdBah0 %X\n", *MemPtr));