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<n; 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 <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Fixes: 7dbc50bd244d95fdc1741b9cfc561f0bfd724de1
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
-void print_mem(void const *vp, size_t n)\r
+STATIC\r
+VOID\r
+PrintMem (\r
+ CONST VOID *Buffer,\r
+ UINTN Count\r
+ )\r
- unsigned char const *p = vp;\r
- for (size_t i=0; i<n; i++) {\r
- printf("0x%02x ", p[i]);\r
+ CONST UINT8 *Bytes;\r
+ UINTN Idx;\r
+\r
+ Bytes = Buffer;\r
+ for (Idx = 0; Idx < Count; Idx++) {\r
+ printf("0x%02x ", Bytes[Idx]);\r
DevicePath = UefiDevicePathLibConvertTextToDevicePath(Str16);\r
while (!((DevicePath->Type == END_DEVICE_PATH_TYPE) && (DevicePath->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE)) )\r
{\r
DevicePath = UefiDevicePathLibConvertTextToDevicePath(Str16);\r
while (!((DevicePath->Type == END_DEVICE_PATH_TYPE) && (DevicePath->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE)) )\r
{\r
- print_mem(DevicePath, (DevicePath->Length[0] | DevicePath->Length[1] << 8));\r
+ PrintMem (DevicePath, DevicePath->Length[0] | DevicePath->Length[1] << 8);\r
DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)((UINT8 *)DevicePath + (DevicePath->Length[0] | DevicePath->Length[1] << 8));\r
}\r
DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)((UINT8 *)DevicePath + (DevicePath->Length[0] | DevicePath->Length[1] << 8));\r
}\r
- print_mem(DevicePath, (DevicePath->Length[0] | DevicePath->Length[1] << 8));\r
+ PrintMem (DevicePath, DevicePath->Length[0] | DevicePath->Length[1] << 8);\r
putchar('\n');\r
return STATUS_SUCCESS;\r
}\r
putchar('\n');\r
return STATUS_SUCCESS;\r
}\r