From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.24; helo=mga09.intel.com; envelope-from=yonghong.zhu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (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 27640222A54C3 for ; Tue, 2 Jan 2018 17:21:39 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Jan 2018 17:26:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,499,1508828400"; d="scan'208";a="23738948" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga002.jf.intel.com with ESMTP; 02 Jan 2018 17:26:41 -0800 Received: from fmsmsx158.amr.corp.intel.com (10.18.116.75) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 2 Jan 2018 17:26:41 -0800 Received: from shsmsx102.ccr.corp.intel.com (10.239.4.154) by fmsmsx158.amr.corp.intel.com (10.18.116.75) with Microsoft SMTP Server (TLS) id 14.3.319.2; Tue, 2 Jan 2018 17:26:40 -0800 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.213]) by shsmsx102.ccr.corp.intel.com ([169.254.2.189]) with mapi id 14.03.0319.002; Wed, 3 Jan 2018 09:26:39 +0800 From: "Zhu, Yonghong" To: Laszlo Ersek , edk2-devel-01 CC: "Gao, Liming" , "Zhu, Yonghong" Thread-Topic: [PATCH] BaseTools/DevicePath: fix GCC build error in print_mem(), and clean it up Thread-Index: AQHTg+2g3Vw0VRNivUiKQd9kCFezCaNhW0/A Date: Wed, 3 Jan 2018 01:26:38 +0000 Message-ID: References: <20180102171636.29351-1-lersek@redhat.com> In-Reply-To: <20180102171636.29351-1-lersek@redhat.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [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: , X-List-Received-Date: Wed, 03 Jan 2018 01:21:39 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Thanks. Reviewed-by: Yonghong Zhu =20 Best Regards, Zhu Yonghong -----Original Message----- From: Laszlo Ersek [mailto:lersek@redhat.com]=20 Sent: Wednesday, January 03, 2018 1:17 AM To: edk2-devel-01 Cc: Gao, Liming ; Zhu, Yonghong Subject: [PATCH] BaseTools/DevicePath: fix GCC build error in print_mem(), = and clean it up 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=20 > allowed in C99 mode > for (size_t i=3D0; i ^ > DevicePath.c:109:5: note: use option -std=3Dc99 or -std=3Dgnu99 to compil= e=20 > 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 super= fluous 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 --- 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]=20 + << 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]=20 + << 8); putchar('\n'); return STATUS_SUCCESS; } -- 2.14.1.3.gb7cf6e02401b