From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from cam-smtp0.cambridge.arm.com (cam-smtp0.cambridge.arm.com [217.140.106.54]) by mx.groups.io with SMTP id smtpd.web12.2368.1596136519406554753 for ; Thu, 30 Jul 2020 12:15:20 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.106.54, mailfrom: pierre.gondois@arm.com) Received: from E119881.Arm.com (E119881.Arm.com [10.1.197.28]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id 06UJFG0Q008924; Thu, 30 Jul 2020 20:15:17 +0100 From: "PierreGondois" To: devel@edk2.groups.io Cc: Pierre Gondois , leif@nuviainc.com, ard.biesheuvel@arm.com, sami.mujawar@arm.com, nd@arm.com Subject: [PATCH edk2-platforms v1 3/3] Silicon/Synopsys/DesignWare: Casts to avoid void* pointer arithmetic Date: Thu, 30 Jul 2020 20:15:11 +0100 Message-Id: <20200730191511.101896-4-pierre.gondois@arm.com> X-Mailer: git-send-email 2.16.2.windows.1 In-Reply-To: <20200730191511.101896-1-pierre.gondois@arm.com> References: <20200730191511.101896-1-pierre.gondois@arm.com> From: Pierre Gondois 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 --- The changes can be seen at: https://github.com/PierreARM/edk2-platforms/commits/Casts_avoiding_void_pointer_arith_v1 Notes: v1: - Use casts to avoid void* pointer arithmetic. [Pierre] Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/DriverBinding.c | 3 ++- Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/DwEmacSnpDxe.c | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/DriverBinding.c b/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/DriverBinding.c index bdf885458197887e198dcba83355c8a8631d9e58..f1a9771f066983c3152bc72ce5c2cf6fa12de95e 100755 --- a/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/DriverBinding.c +++ b/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/DriverBinding.c @@ -1,6 +1,7 @@ /** @file Copyright (c) 2011 - 2019, Intel Corporaton. All rights reserved. + Copyright (c) 2020, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -171,7 +172,7 @@ DriverStart ( } //DMA mapping for receive buffer - RxBufferAddr = (VOID *)Snp->MacDriver.RxBuffer + (Index * BufferSize); + RxBufferAddr = (UINTN*)((UINTN)Snp->MacDriver.RxBuffer + (Index * BufferSize)); Status = DmaMap (MapOperationBusMasterWrite, (VOID *) RxBufferAddr, &BufferSize, &RxBufferAddrMap, &Snp->MacDriver.RxBufNum[Index].Mapping); if (EFI_ERROR (Status)) { diff --git a/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/DwEmacSnpDxe.c b/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/DwEmacSnpDxe.c index 09e6754798a048f6dc3c40086039ca836dfb9540..4cb3371d79bbdc23735f85826ce35e5d71dbcdf9 100755 --- a/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/DwEmacSnpDxe.c +++ b/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/DwEmacSnpDxe.c @@ -5,7 +5,7 @@ The original software modules are licensed as follows: - Copyright (c) 2012 - 2014, ARM Limited. All rights reserved. + Copyright (c) 2012 - 2020, Arm Limited. All rights reserved.
Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved. SPDX-License-Identifier: BSD-2-Clause-Patent @@ -1135,7 +1135,8 @@ SnpReceive ( Snp->MacDriver.RxCurrentDescriptorNum = Snp->MacDriver.RxNextDescriptorNum; DescNum = Snp->MacDriver.RxCurrentDescriptorNum; RxDescriptor = Snp->MacDriver.RxdescRing[DescNum]; - RxBufferAddr = (VOID *)Snp->MacDriver.RxBuffer + (DescNum * BufferSizeBuf); + RxBufferAddr = (UINTN*)((UINTN)Snp->MacDriver.RxBuffer + + (DescNum * BufferSizeBuf)); RxDescriptorMap = (VOID *)(UINTN)Snp->MacDriver.RxdescRingMap[DescNum].AddrMap; RawData = (UINT8 *) Data; -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'