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.web11.2435.1596136519410855624 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 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: [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> 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/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.c | 14 +++++++++++--- Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformFlashAccessLib/SynQuacerPlatformFlashAccessLib.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..25cc1ac2b12f67a254799be1b57620466fd8dd6d 100644 --- a/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.c +++ b/Silicon/Socionext/SynQuacer/Drivers/Net/NetsecDxe/NetsecDxe.c @@ -2,6 +2,7 @@ Copyright (c) 2016 Socionext Inc. All rights reserved.
Copyright (c) 2017, Linaro, Ltd. All rights reserved.
+ Copyright (c) 2020, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent @@ -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 = 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) + ); } Status = DmaMap (MapOperationBusMasterRead, BufAddr, &BufSize, diff --git a/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformFlashAccessLib/SynQuacerPlatformFlashAccessLib.c b/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformFlashAccessLib/SynQuacerPlatformFlashAccessLib.c index 1a654e4430c8451fe755b066e11a33f4887d9332..bded74dc4f02dc2444db724ee46fb75096234126 100644 --- a/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformFlashAccessLib/SynQuacerPlatformFlashAccessLib.c +++ b/Silicon/Socionext/SynQuacer/Library/SynQuacerPlatformFlashAccessLib/SynQuacerPlatformFlashAccessLib.c @@ -3,6 +3,7 @@ Copyright (c) 2016, Linaro, Ltd. All rights reserved.
Copyright (c) 2018, Intel Corporation. All rights reserved.
+ Copyright (c) 2020, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent @@ -316,7 +317,7 @@ PerformFlashWriteWithProgress ( Print (L"."); } - Buffer += BlockSize; + Buffer = (VOID*)((UINTN)Buffer + BlockSize); Length -= BlockSize; Lba++; } -- 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)'