Browse Source

Silicon/Marvell/Drivers: Casts to avoid void* pointer arithmetic

By default, gcc allows void* pointer arithmetic.
This is a GCC extension.
However, the C reference manual states that void*
pointer "cannot be operands of addition or subtraction
operators". Cf s5.3.1 "Generic Pointers".

This patch adds casts to avoid doing void* pointer arithmetic.

Signed-off-by: Pierre Gondois <pierre.gondois@arm.com>
Reviewed-by: Leif Lindholm <leif@nuviainc.com>
Pierre Gondois 3 years ago
parent
commit
dd588aa686

+ 3 - 2
Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c

@@ -1,5 +1,6 @@
 /********************************************************************************
 Copyright (C) 2016 Marvell International Ltd.
+Copyright (c) 2020, Arm Limited. All rights reserved.<BR>
 
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -1342,7 +1343,7 @@ Pp2DxeInitialiseController (
 
   for (Index = 0; Index < MVPP2_MAX_PORT; Index++) {
     Mvpp2Shared->BufferLocation.TxDescs[Index] = (MVPP2_TX_DESC *)
-      (BufferSpace + Index * MVPP2_MAX_TXD * sizeof(MVPP2_TX_DESC));
+      ((UINTN)BufferSpace + Index * MVPP2_MAX_TXD * sizeof(MVPP2_TX_DESC));
   }
 
   Mvpp2Shared->BufferLocation.AggrTxDescs = (MVPP2_TX_DESC *)
@@ -1356,7 +1357,7 @@ Pp2DxeInitialiseController (
 
   for (Index = 0; Index < MVPP2_MAX_PORT; Index++) {
     Mvpp2Shared->BufferLocation.RxBuffers[Index] = (DmaAddrT)
-      (BufferSpace + (MVPP2_MAX_TXD * MVPP2_MAX_PORT + MVPP2_AGGR_TXQ_SIZE) *
+      ((UINTN)BufferSpace + (MVPP2_MAX_TXD * MVPP2_MAX_PORT + MVPP2_AGGR_TXQ_SIZE) *
       sizeof(MVPP2_TX_DESC) + MVPP2_MAX_RXD * MVPP2_MAX_PORT * sizeof(MVPP2_RX_DESC) +
       Index * MVPP2_BM_SIZE * RX_BUFFER_SIZE);
   }

+ 3 - 2
Silicon/Marvell/Drivers/SdMmc/XenonDxe/XenonSdhci.c

@@ -1,5 +1,6 @@
 /*******************************************************************************
 Copyright (C) 2016 Marvell International Ltd.
+Copyright (c) 2020, Arm Limited. All rights reserved.<BR>
 
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -629,7 +630,7 @@ XenonTransferPio (
   // solution.
   //
   for (Index = 0; Index < BlockSize; Index += 4) {
-    Offs = Buffer + Index;
+    Offs = (UINT8*)((UINTN)Buffer + Index);
     if (Read) {
       *(UINT32 *)Offs = MmioRead32 (SDHC_DAT_BUF_PORT_ADDR);
     } else {
@@ -699,7 +700,7 @@ XenonTransferData (
 
       XenonTransferPio (Slot, Buffer, BlockSize, Read);
 
-      Buffer += BlockSize;
+      Buffer = (VOID*)((UINTN)Buffer + BlockSize);
       if (++Block >= Blocks) {
         break;
       }

+ 2 - 2
Silicon/Marvell/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.c

@@ -1,7 +1,7 @@
 /** @file
   This driver installs SMBIOS information for Marvell Armada platforms
 
-  Copyright (c) 2015, ARM Limited. All rights reserved.
+  Copyright (c) 2015-2020, Arm Limited. All rights reserved.<BR>
   Copyright (c) 2019, Marvell International Ltd. and its affiliates
 
   SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -605,7 +605,7 @@ LogSmbiosData (
   CopyMem (Record, Template, Template->Length);
 
   // Append string pack
-  Str = ((VOID *)Record) + Record->Length;
+  Str = (CHAR8*)((UINTN)Record + Record->Length);
   for (Index = 0; StringArray[Index] != NULL; Index++) {
     StringSize = AsciiStrSize (StringArray[Index]);
     CopyMem (Str, StringArray[Index], StringSize);

+ 6 - 3
Silicon/Marvell/Drivers/Spi/MvSpiFlashDxe/MvSpiFlashDxe.c

@@ -1,5 +1,6 @@
 /*******************************************************************************
 Copyright (C) 2016 Marvell International Ltd.
+Copyright (c) 2020, Arm Limited. All rights reserved.<BR>
 
 SPDX-License-Identifier: BSD-2-Clause-Patent
 
@@ -233,7 +234,7 @@ MvSpiFlashRead (
 
     Offset += ReadLength;
     Length -= ReadLength;
-    Buf += ReadLength;
+    Buf = (VOID*)((UINTN)Buf + ReadLength);
   }
 
   return Status;
@@ -268,8 +269,10 @@ MvSpiFlashWrite (
     SpiFlashFormatAddress (WriteAddr, Slave->AddrSize, Cmd);
 
     // Program proper write address and write data
-    Status = MvSpiFlashWriteCommon (Slave, Cmd, Slave->AddrSize + 1, Buf + ActualIndex,
-      ChunkLength);
+    Status = MvSpiFlashWriteCommon (
+      Slave, Cmd, Slave->AddrSize + 1,
+      (VOID*)((UINTN)Buf + ActualIndex), ChunkLength
+      );
     if (EFI_ERROR (Status)) {
       DEBUG((DEBUG_ERROR, "SpiFlash: Error while programming write address\n"));
       return Status;