From: Laszlo Ersek Date: Tue, 2 Jan 2018 17:16:36 +0000 (+0800) Subject: BaseTools/DevicePath: fix GCC build error in print_mem(), and clean it up X-Git-Tag: edk2-stable201903~2677 X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=commitdiff_plain;h=9a6b445bc2e6e2db6f67ab3cc425d5831aa1b7c8;hp=beacbc7492393992a8d10cd0a450c308a482f315 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 > allowed in C99 mode > for (size_t i=0; i ^ > DevicePath.c:109:5: note: use option -std=c99 or -std=gnu99 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 --- diff --git a/BaseTools/Source/C/DevicePath/DevicePath.c b/BaseTools/Source/C/DevicePath/DevicePath.c index 4c87163209..76b8553b71 100644 --- a/BaseTools/Source/C/DevicePath/DevicePath.c +++ b/BaseTools/Source/C/DevicePath/DevicePath.c @@ -103,11 +103,19 @@ Returns: } -void print_mem(void const *vp, size_t n) +STATIC +VOID +PrintMem ( + CONST VOID *Buffer, + UINTN Count + ) { - unsigned char const *p = vp; - for (size_t i=0; iType == END_DEVICE_PATH_TYPE) && (DevicePath->SubType == 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 = (EFI_DEVICE_PATH_PROTOCOL *)((UINT8 *)DevicePath + (DevicePath->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; }