From nobody Mon Dec 23 19:38:25 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1514913404946860.9269093935859; Tue, 2 Jan 2018 09:16:44 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id A9D1F22225BF7; Tue, 2 Jan 2018 09:11:40 -0800 (PST) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id E7C32222EDCF0 for ; Tue, 2 Jan 2018 09:11:38 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 98D64356D8; Tue, 2 Jan 2018 17:16:40 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-121-60.rdu2.redhat.com [10.10.121.60]) by smtp.corp.redhat.com (Postfix) with ESMTP id 91C9C5D9C8; Tue, 2 Jan 2018 17:16:39 +0000 (UTC) X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=209.132.183.28; helo=mx1.redhat.com; envelope-from=lersek@redhat.com; receiver=edk2-devel@lists.01.org From: Laszlo Ersek To: edk2-devel-01 Date: Tue, 2 Jan 2018 18:16:36 +0100 Message-Id: <20180102171636.29351-1-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 02 Jan 2018 17:16:40 +0000 (UTC) Subject: [edk2] [PATCH] BaseTools/DevicePath: fix GCC build error in print_mem(), and clean it up X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Currently "BaseTools/Source/C/DevicePath/DevicePath.c" fails to build with GCC48: > DevicePath.c: In function 'print_mem': > DevicePath.c:109:5: error: 'for' loop initial declarations are only > allowed in C99 mode > for (size_t i=3D0; i ^ > DevicePath.c:109:5: note: use option -std=3Dc99 or -std=3Dgnu99 to compile > your code In addition, the print_mem() function does not conform to the edk2 coding style: - we use CamelCase and no underscores in identifiers, - the types and type qualifiers should follow the edk2 style, - initialization as part of definition is forbidden for local variables. Clean these up. While updating the print_mem()/PrintMem() call sites, also remove the superfluous parentheses around the second argument. Cc: Liming Gao Cc: Yonghong Zhu Fixes: 7dbc50bd244d95fdc1741b9cfc561f0bfd724de1 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Laszlo Ersek Reviewed-by: Yonghong Zhu =20 --- Notes: Build-tested only (I don't have a DSC file with a device path PCD). BaseTools/Source/C/DevicePath/DevicePath.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/BaseTools/Source/C/DevicePath/DevicePath.c b/BaseTools/Source/= C/DevicePath/DevicePath.c index 4c87163209ab..76b8553b7145 100644 --- a/BaseTools/Source/C/DevicePath/DevicePath.c +++ b/BaseTools/Source/C/DevicePath/DevicePath.c @@ -103,11 +103,19 @@ Returns: } =20 =20 -void print_mem(void const *vp, size_t n) +STATIC +VOID +PrintMem ( + CONST VOID *Buffer, + UINTN Count + ) { - unsigned char const *p =3D vp; - for (size_t i=3D0; iType =3D=3D END_DEVICE_PATH_TYPE) && (DevicePath->= SubType =3D=3D END_ENTIRE_DEVICE_PATH_SUBTYPE)) ) { - print_mem(DevicePath, (DevicePath->Length[0] | DevicePath->Length[1] <= < 8)); + PrintMem (DevicePath, DevicePath->Length[0] | DevicePath->Length[1] <<= 8); DevicePath =3D (EFI_DEVICE_PATH_PROTOCOL *)((UINT8 *)DevicePath + (Dev= icePath->Length[0] | DevicePath->Length[1] << 8)); } - print_mem(DevicePath, (DevicePath->Length[0] | DevicePath->Length[1] << = 8)); + PrintMem (DevicePath, DevicePath->Length[0] | DevicePath->Length[1] << 8= ); putchar('\n'); return STATUS_SUCCESS; } --=20 2.14.1.3.gb7cf6e02401b _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel