From nobody Sat Apr 20 01:38:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+63517+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+63517+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1596136522; cv=none; d=zohomail.com; s=zohoarc; b=gFEC3GSkfsYreEQNUeevIwt3OQduAY3XOhEbQeaL4JsYSpUMxLyh/1cG9knQju0l4P8HLQDv6n4m+maEGOD6bj5IhAvJISLHjcJl713RjzRLLrUf/mR13A3eNDFtjbVARXxVTXhnUMqtr4TcGQu7IlZGXyW4Kx+7jYeWmJHWiro= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596136522; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=9WYPAr0PPQyNA922tg4bb+2P9/pS1yb9OcTRAmc2KTo=; b=K0YrZQ84KxKfNbbAU+/iXvT+Dyrmtc6Z+IM0l90NtxBt6UjUkX20/1h2CGmBQym8JnOJI245/hBot5IYHR1Nr1XNirA/n4YJbP4dl9AHOX2/EWvadOQsOV/uR78tcPkPpe8vjFReyeuuHJkGFIwHlPQ2BiDNpoGc2FGRZcY7Lhc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+63517+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1596136522969998.0983243748535; Thu, 30 Jul 2020 12:15:22 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id Xc1BYY1788612xZa83IuEQ6C; Thu, 30 Jul 2020 12:15:22 -0700 X-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.2367.1596136519406212551 for ; Thu, 30 Jul 2020 12:15:20 -0700 X-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 06UJFG0O008924; 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: [edk2-devel] [PATCH edk2-platforms v1 1/3] Silicon/Marvell/Drivers: Casts to avoid void* pointer arithmetic Date: Thu, 30 Jul 2020 20:15:09 +0100 Message-Id: <20200730191511.101896-2-pierre.gondois@arm.com> In-Reply-To: <20200730191511.101896-1-pierre.gondois@arm.com> References: <20200730191511.101896-1-pierre.gondois@arm.com> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com X-Gm-Message-State: wqOkW5rxZqUskKMfOgjjyxDVx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1596136522; bh=uDkoOgYpvyOEvWQ22bjvKS+IxdGdjwwQysuEKmPHEIs=; h=Cc:Date:From:Reply-To:Subject:To; b=uit9Ms8tORDeg+60vGCkH0olHeMmW/Y9gv85YgcLbMQ3FBjqL1B4qDgJF85v0vBrklE 6/ZhEOD/kQ5f26ZJqEMXGTV80bLIx9TAFKXTbeCrkRISHTgZtJG940SmSmkp5Kqd4NJCG DKqA3SsEYtje5mrz7cbId+2JLF0p0I5miMc= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Leif Lindholm --- The changes can be seen at: https://github.com/PierreARM/edk2-platforms/com= mits/Casts_avoiding_void_pointer_arith_v1 Notes: v1: - Use casts to avoid void* pointer arithmetic. [Pierre] Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c | 5 +++-- Silicon/Marvell/Drivers/SdMmc/XenonDxe/XenonSdhci.c | 5 +++-- Silicon/Marvell/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.c | 4 ++-- Silicon/Marvell/Drivers/Spi/MvSpiFlashDxe/MvSpiFlashDxe.c | 9 ++++++--- 4 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c b/Silicon/Marvell/= Drivers/Net/Pp2Dxe/Pp2Dxe.c index 9a1d1a7bede84d75a58806bf5f594684eaa9f0cb..0872f1788993b09394fb339f4c2= 113cc7d6a4491 100644 --- a/Silicon/Marvell/Drivers/Net/Pp2Dxe/Pp2Dxe.c +++ b/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.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -1342,7 +1343,7 @@ Pp2DxeInitialiseController ( =20 for (Index =3D 0; Index < MVPP2_MAX_PORT; Index++) { Mvpp2Shared->BufferLocation.TxDescs[Index] =3D (MVPP2_TX_DESC *) - (BufferSpace + Index * MVPP2_MAX_TXD * sizeof(MVPP2_TX_DESC)); + ((UINTN)BufferSpace + Index * MVPP2_MAX_TXD * sizeof(MVPP2_TX_DESC)); } =20 Mvpp2Shared->BufferLocation.AggrTxDescs =3D (MVPP2_TX_DESC *) @@ -1356,7 +1357,7 @@ Pp2DxeInitialiseController ( =20 for (Index =3D 0; Index < MVPP2_MAX_PORT; Index++) { Mvpp2Shared->BufferLocation.RxBuffers[Index] =3D (DmaAddrT) - (BufferSpace + (MVPP2_MAX_TXD * MVPP2_MAX_PORT + MVPP2_AGGR_TXQ_SIZE= ) * + ((UINTN)BufferSpace + (MVPP2_MAX_TXD * MVPP2_MAX_PORT + MVPP2_AGGR_T= XQ_SIZE) * sizeof(MVPP2_TX_DESC) + MVPP2_MAX_RXD * MVPP2_MAX_PORT * sizeof(MVPP= 2_RX_DESC) + Index * MVPP2_BM_SIZE * RX_BUFFER_SIZE); } diff --git a/Silicon/Marvell/Drivers/SdMmc/XenonDxe/XenonSdhci.c b/Silicon/= Marvell/Drivers/SdMmc/XenonDxe/XenonSdhci.c index 6059cf84d934a84bed704ad8cb2090db63d33a45..9fbf302c2848ae9491043b2a281= 905638ae3d61a 100755 --- a/Silicon/Marvell/Drivers/SdMmc/XenonDxe/XenonSdhci.c +++ b/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.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -629,7 +630,7 @@ XenonTransferPio ( // solution. // for (Index =3D 0; Index < BlockSize; Index +=3D 4) { - Offs =3D Buffer + Index; + Offs =3D (UINT8*)((UINTN)Buffer + Index); if (Read) { *(UINT32 *)Offs =3D MmioRead32 (SDHC_DAT_BUF_PORT_ADDR); } else { @@ -699,7 +700,7 @@ XenonTransferData ( =20 XenonTransferPio (Slot, Buffer, BlockSize, Read); =20 - Buffer +=3D BlockSize; + Buffer =3D (VOID*)((UINTN)Buffer + BlockSize); if (++Block >=3D Blocks) { break; } diff --git a/Silicon/Marvell/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.c = b/Silicon/Marvell/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.c index 3b909f341289dc829684527a562eb9183bd94246..2ecaec2af515267ddaeb24248d6= e1a629f554ddb 100644 --- a/Silicon/Marvell/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.c +++ b/Silicon/Marvell/Drivers/SmbiosPlatformDxe/SmbiosPlatformDxe.c @@ -1,7 +1,7 @@ /** @file This driver installs SMBIOS information for Marvell Armada platforms =20 - Copyright (c) 2015, ARM Limited. All rights reserved. + Copyright (c) 2015-2020, Arm Limited. All rights reserved.
Copyright (c) 2019, Marvell International Ltd. and its affiliates =20 SPDX-License-Identifier: BSD-2-Clause-Patent @@ -605,7 +605,7 @@ LogSmbiosData ( CopyMem (Record, Template, Template->Length); =20 // Append string pack - Str =3D ((VOID *)Record) + Record->Length; + Str =3D (CHAR8*)((UINTN)Record + Record->Length); for (Index =3D 0; StringArray[Index] !=3D NULL; Index++) { StringSize =3D AsciiStrSize (StringArray[Index]); CopyMem (Str, StringArray[Index], StringSize); diff --git a/Silicon/Marvell/Drivers/Spi/MvSpiFlashDxe/MvSpiFlashDxe.c b/Si= licon/Marvell/Drivers/Spi/MvSpiFlashDxe/MvSpiFlashDxe.c index db12adb7644ec3f211df75ef16bb19e7c96fbdc7..f99f3d5763cdb25206e2e3d9165= b6c9039690fcb 100755 --- a/Silicon/Marvell/Drivers/Spi/MvSpiFlashDxe/MvSpiFlashDxe.c +++ b/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.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -233,7 +234,7 @@ MvSpiFlashRead ( =20 Offset +=3D ReadLength; Length -=3D ReadLength; - Buf +=3D ReadLength; + Buf =3D (VOID*)((UINTN)Buf + ReadLength); } =20 return Status; @@ -268,8 +269,10 @@ MvSpiFlashWrite ( SpiFlashFormatAddress (WriteAddr, Slave->AddrSize, Cmd); =20 // Program proper write address and write data - Status =3D MvSpiFlashWriteCommon (Slave, Cmd, Slave->AddrSize + 1, Buf= + ActualIndex, - ChunkLength); + Status =3D 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; --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#63517): https://edk2.groups.io/g/devel/message/63517 Mute This Topic: https://groups.io/mt/75893334/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat Apr 20 01:38:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+63518+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+63518+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1596136522; cv=none; d=zohomail.com; s=zohoarc; b=WAaD1bKMVl9bpz4EUttanlMDbLa3qmndEtk+K9ViKBqcrt/zhCy6owuCz9lOqDQ3oFMASqbqGlJFxsXJrxlytL0TdmDra8PN6cMaIZTu7g3pDl+UJumqLt+OnYQlHfrUZptzuIgKQ7mwj+rdMjaNsy5+EPcQnqLmKUQ6lAYntzA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596136522; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=VfVBZ6900Xl/uvM7Hg8uTY5L6rymz4xemZmE0oYqtZU=; b=XEXryp754oD0VfeLid1rFaR0c3096OaWWR/ayxVPXYa/6Mx8yU8/ojPc90YUBWWnJckxYiieK4HuLvlS37jM9XDlqUgorzUxOApsMPQb162Sa2mN5jM0y1+TncS7F/mBzq0Hec5NAmU/5jpiYnUW3cDhKONpOdruA71p5irjdV4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+63518+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1596136522375346.8037983352085; Thu, 30 Jul 2020 12:15:22 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id ftI9YY1788612x7YKAkGqUn3; Thu, 30 Jul 2020 12:15:22 -0700 X-Received: from cam-smtp0.cambridge.arm.com (cam-smtp0.cambridge.arm.com [217.140.106.54]) by mx.groups.io with SMTP id smtpd.web11.2435.1596136519410855624 for ; Thu, 30 Jul 2020 12:15:20 -0700 X-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 06UJFG0P008924; 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: [edk2-devel] [PATCH edk2-platforms v1 2/3] Silicon/Socionext/SynQuacer: Casts to avoid void* pointer arithmetic Date: Thu, 30 Jul 2020 20:15:10 +0100 Message-Id: <20200730191511.101896-3-pierre.gondois@arm.com> In-Reply-To: <20200730191511.101896-1-pierre.gondois@arm.com> References: <20200730191511.101896-1-pierre.gondois@arm.com> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com X-Gm-Message-State: IMLtEPPeWXJhTRv6T92s6Yh6x1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1596136522; bh=xTSTBk+O4BWygIlGk+J35MlRm2//uIk/E9DtJINE2lY=; h=Cc:Date:From:Reply-To:Subject:To; b=bZV9/LNZc/IbTAoZCz3NdAkg2tiBZhTG4E3ltVwoWN5W5kmt6TjWDSlP1gR4JLcD/wd 45RxZ5mvaC5rUop4QouNmmLnQpTB/s4yqV2SS7NcqPloxs9gPI3MYLTx/TPr86ZMbg05a 93KFXCxtaHGZQvbqm2DoFxeAnOnad282H5o= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Leif Lindholm --- The changes can be seen at: https://github.com/PierreARM/edk2-platforms/com= mits/Casts_avoiding_void_pointer_arith_v1 Notes: v1: - Use casts to avoid void* pointer arithmetic. [Pierre] Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.c = | 14 +++++++++++--- Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformFlashAccessLib/SynQua= cerPlatformFlashAccessLib.c | 3 ++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.c = b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.c index c9fc4d6e2d8e495a39a2edf24490dfea424d14e5..25cc1ac2b12f67a254799be1b57= 620466fd8dd6d 100644 --- a/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.c +++ b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.c @@ -2,6 +2,7 @@ =20 Copyright (c) 2016 Socionext Inc. All rights reserved.
Copyright (c) 2017, Linaro, Ltd. All rights reserved.
+ Copyright (c) 2020, Arm Limited. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -774,11 +775,18 @@ SnpTransmit ( // Copy destination address CopyMem (BufAddr, (VOID *)DstAddr, NET_ETHER_ADDR_LEN); // Copy source address - CopyMem (BufAddr + NET_ETHER_ADDR_LEN, (VOID *)SrcAddr, NET_ETHER_ADDR= _LEN); + CopyMem ( + (VOID*)((UINTN)BufAddr + NET_ETHER_ADDR_LEN), + (VOID*)SrcAddr, + NET_ETHER_ADDR_LEN + ); // Copy protocol Proto =3D HTONS (*Protocol); - CopyMem (BufAddr + (NET_ETHER_ADDR_LEN * 2), (VOID *)&Proto, - sizeof (UINT16)); + CopyMem ( + (VOID*)((UINTN)BufAddr + (NET_ETHER_ADDR_LEN * 2)), + (VOID*)&Proto, + sizeof (UINT16) + ); } =20 Status =3D DmaMap (MapOperationBusMasterRead, BufAddr, &BufSize, diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformFlashAcce= ssLib/SynQuacerPlatformFlashAccessLib.c b/Silicon/Socionext/SynQuacer/Libra= ry/SynQuacerPlatformFlashAccessLib/SynQuacerPlatformFlashAccessLib.c index 1a654e4430c8451fe755b066e11a33f4887d9332..bded74dc4f02dc2444db724ee46= fb75096234126 100644 --- a/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformFlashAccessLib/S= ynQuacerPlatformFlashAccessLib.c +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformFlashAccessLib/S= ynQuacerPlatformFlashAccessLib.c @@ -3,6 +3,7 @@ =20 Copyright (c) 2016, Linaro, Ltd. All rights reserved.
Copyright (c) 2018, Intel Corporation. All rights reserved.
+ Copyright (c) 2020, Arm Limited. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent =20 @@ -316,7 +317,7 @@ PerformFlashWriteWithProgress ( Print (L"."); } =20 - Buffer +=3D BlockSize; + Buffer =3D (VOID*)((UINTN)Buffer + BlockSize); Length -=3D BlockSize; Lba++; } --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#63518): https://edk2.groups.io/g/devel/message/63518 Mute This Topic: https://groups.io/mt/75893335/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sat Apr 20 01:38:09 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+63519+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+63519+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1596136522; cv=none; d=zohomail.com; s=zohoarc; b=H8nivy95Tv6R2fT5K6jxLqpyaSh3xuGep/iHkgSqDmupJ9TypvRAu8HM95nFRxLd6DvmmrefH8HuuVNZ1ImnKRyglpsKhNI3l1LLJYY/C7NE0iI8cvNDCRiqWnmSdG3C45YC39voglUillpUl8Ou+SD/LkccGoAe2SaEbQKR5kw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1596136522; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=2053oP7URWvU7ZPMaz4HYEq6RjUVQjrc6xA3pYS8UrY=; b=WxWb+C3Nh5OMVY9Rn7L1HTo/YliU1zpGGr4QtQkagoDrZWGsc/SlmKhg6ME3Me7ULqUdR2du7H/Z24tS5tNoNNqLidZCQL3IY0jrCkIpv4jk6+GFBres5FssJqXSw+0ox+z0qLwWTsb5AXjYCfU5NPKCJK0/X16qJpLbbCPqnvs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+63519+1787277+3901457@groups.io Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1596136522366231.04344194196926; Thu, 30 Jul 2020 12:15:22 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id z9NRYY1788612xcGWXMbBjfh; Thu, 30 Jul 2020 12:15:22 -0700 X-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 X-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: [edk2-devel] [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> In-Reply-To: <20200730191511.101896-1-pierre.gondois@arm.com> References: <20200730191511.101896-1-pierre.gondois@arm.com> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,pierre.gondois@arm.com X-Gm-Message-State: 3izxVpa25zXWKzjgTyyljVNQx1787277AA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1596136522; bh=0rmACnZYJ09oTriJHsZfZ4tOXcJJoQ8l6cVn1av9eFk=; h=Cc:Date:From:Reply-To:Subject:To; b=v2XfX472O3klfMHbFd6NiDgI2sFOGH2Pe4Tf4E4uUSNi6JmNY5gG4loCc5xA5Bkn06u s2eX3NhcD8T9UGiKZOBsH1kiOHGuOa3BB2vEEaV5p1+/Eci4Fdd70aEhM2cJyvctX8a6v 9wip3UyHGOx9UTVhhvs+A4VldYPciaAOmac= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Leif Lindholm --- The changes can be seen at: https://github.com/PierreARM/edk2-platforms/com= mits/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..f1a9771f066983c3152bc72ce5c= 2cf6fa12de95e 100755 --- a/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/DriverBinding.c +++ b/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/DriverBinding.c @@ -1,6 +1,7 @@ /** @file =20 Copyright (c) 2011 - 2019, Intel Corporaton. All rights reserved. + Copyright (c) 2020, Arm Limited. All rights reserved.
=20 SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -171,7 +172,7 @@ DriverStart ( } =20 //DMA mapping for receive buffer - RxBufferAddr =3D (VOID *)Snp->MacDriver.RxBuffer + (Index * BufferSize= ); + RxBufferAddr =3D (UINTN*)((UINTN)Snp->MacDriver.RxBuffer + (Index * Bu= fferSize)); Status =3D DmaMap (MapOperationBusMasterWrite, (VOID *) RxBufferAddr, &BufferSize, &RxBufferAddrMap, &Snp->MacDriver.RxBufNum[Ind= ex].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..4cb3371d79bbdc23735f85826ce= 35e5d71dbcdf9 100755 --- a/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/DwEmacSnpDxe.c +++ b/Silicon/Synopsys/DesignWare/Drivers/DwEmacSnpDxe/DwEmacSnpDxe.c @@ -5,7 +5,7 @@ =20 The original software modules are licensed as follows: =20 - 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. =20 SPDX-License-Identifier: BSD-2-Clause-Patent @@ -1135,7 +1135,8 @@ SnpReceive ( Snp->MacDriver.RxCurrentDescriptorNum =3D Snp->MacDriver.RxNextDescripto= rNum; DescNum =3D Snp->MacDriver.RxCurrentDescriptorNum; RxDescriptor =3D Snp->MacDriver.RxdescRing[DescNum]; - RxBufferAddr =3D (VOID *)Snp->MacDriver.RxBuffer + (DescNum * BufferSize= Buf); + RxBufferAddr =3D (UINTN*)((UINTN)Snp->MacDriver.RxBuffer + + (DescNum * BufferSizeBuf)); RxDescriptorMap =3D (VOID *)(UINTN)Snp->MacDriver.RxdescRingMap[DescNum]= .AddrMap; =20 RawData =3D (UINT8 *) Data; --=20 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#63519): https://edk2.groups.io/g/devel/message/63519 Mute This Topic: https://groups.io/mt/75893336/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-