Subrata Banik has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/36531 )
Change subject: soc/intel/icelake: Clean up report_cpu_info() function ......................................................................
soc/intel/icelake: Clean up report_cpu_info() function
This patch makes below clean up for report_cpu_info() function 1. Replace cpu_string with cpu_not_found 2. Assign default string "Platform info not available" to cpu_not_found string 3. Add array out of bound check while skiping leading white space in cpu brand string name
Change-Id: I41c76eb93f0c5229c4a49aa041339b8ad51ad34a Signed-off-by: Subrata Banik subrata.banik@intel.com --- M src/soc/intel/icelake/bootblock/report_platform.c 1 file changed, 4 insertions(+), 5 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/31/36531/1
diff --git a/src/soc/intel/icelake/bootblock/report_platform.c b/src/soc/intel/icelake/bootblock/report_platform.c index a9eef40..b1d9647 100644 --- a/src/soc/intel/icelake/bootblock/report_platform.c +++ b/src/soc/intel/icelake/bootblock/report_platform.c @@ -93,7 +93,8 @@ { struct cpuid_result cpuidr; u32 i, index, cpu_id, cpu_feature_flag; - char cpu_string[50], *cpu_name = cpu_string; /* 48 bytes are reported */ + const char cpu_not_found[] = "Platform info not available"; + const char *cpu_name = cpu_not_found; /* 48 bytes are reported */ int vt, txt, aes; msr_t microcode_ver; static const char *const mode[] = {"NOT ", ""}; @@ -102,9 +103,7 @@
index = 0x80000000; cpuidr = cpuid(index); - if (cpuidr.eax < 0x80000004) { - strcpy(cpu_string, "Platform info not available"); - } else { + if (cpuidr.eax >= 0x80000004) { int j = 0;
for (i = 2; i <= 4; i++) { @@ -118,7 +117,7 @@ cpu_name = (char *)p; } /* Skip leading spaces in CPU name string */ - while (cpu_name[0] == ' ') + while (cpu_name[0] == ' ' && strlen(cpu_name) > 0) cpu_name++;
microcode_ver.lo = 0;
Hello Patrick Rudolph, Arthur Heymans, build bot (Jenkins),
I'd like you to reexamine a change. Please visit
https://review.coreboot.org/c/coreboot/+/36531
to look at the new patch set (#2).
Change subject: soc/intel/icelake: Clean up report_cpu_info() function ......................................................................
soc/intel/icelake: Clean up report_cpu_info() function
This patch makes below clean up for report_cpu_info() function 1. Replace cpu_string with cpu_not_found 2. Assign default string "Platform info not available" to cpu_not_found string 3. Add array out of bound check while skiping leading white space in cpu brand string name
Change-Id: I41c76eb93f0c5229c4a49aa041339b8ad51ad34a Signed-off-by: Subrata Banik subrata.banik@intel.com --- M src/soc/intel/icelake/bootblock/report_platform.c 1 file changed, 7 insertions(+), 7 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/31/36531/2
Subrata Banik has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/36531 )
Change subject: soc/intel/icelake: Clean up report_cpu_info() function ......................................................................
Patch Set 2:
(1 comment)
https://review.coreboot.org/c/coreboot/+/36531/1/src/soc/intel/icelake/bootb... File src/soc/intel/icelake/bootblock/report_platform.c:
https://review.coreboot.org/c/coreboot/+/36531/1/src/soc/intel/icelake/bootb... PS1, Line 119: /* Skip leading spaces in CPU name string */ : while (cpu_name[0] == ' ' && strlen(cpu_name) > 0) : cpu_name++;
Nit: I think it would be clearer if this was placed in the if path.
Done
Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/36531 )
Change subject: soc/intel/icelake: Clean up report_cpu_info() function ......................................................................
Patch Set 2: Code-Review+2
Subrata Banik has submitted this change. ( https://review.coreboot.org/c/coreboot/+/36531 )
Change subject: soc/intel/icelake: Clean up report_cpu_info() function ......................................................................
soc/intel/icelake: Clean up report_cpu_info() function
This patch makes below clean up for report_cpu_info() function 1. Replace cpu_string with cpu_not_found 2. Assign default string "Platform info not available" to cpu_not_found string 3. Add array out of bound check while skiping leading white space in cpu brand string name
Change-Id: I41c76eb93f0c5229c4a49aa041339b8ad51ad34a Signed-off-by: Subrata Banik subrata.banik@intel.com Reviewed-on: https://review.coreboot.org/c/coreboot/+/36531 Reviewed-by: Angel Pons th3fanbus@gmail.com Tested-by: build bot (Jenkins) no-reply@coreboot.org --- M src/soc/intel/icelake/bootblock/report_platform.c 1 file changed, 7 insertions(+), 7 deletions(-)
Approvals: build bot (Jenkins): Verified Angel Pons: Looks good to me, approved
diff --git a/src/soc/intel/icelake/bootblock/report_platform.c b/src/soc/intel/icelake/bootblock/report_platform.c index a9eef40..660aab9 100644 --- a/src/soc/intel/icelake/bootblock/report_platform.c +++ b/src/soc/intel/icelake/bootblock/report_platform.c @@ -93,7 +93,8 @@ { struct cpuid_result cpuidr; u32 i, index, cpu_id, cpu_feature_flag; - char cpu_string[50], *cpu_name = cpu_string; /* 48 bytes are reported */ + const char cpu_not_found[] = "Platform info not available"; + const char *cpu_name = cpu_not_found; /* 48 bytes are reported */ int vt, txt, aes; msr_t microcode_ver; static const char *const mode[] = {"NOT ", ""}; @@ -102,9 +103,7 @@
index = 0x80000000; cpuidr = cpuid(index); - if (cpuidr.eax < 0x80000004) { - strcpy(cpu_string, "Platform info not available"); - } else { + if (cpuidr.eax >= 0x80000004) { int j = 0;
for (i = 2; i <= 4; i++) { @@ -116,10 +115,11 @@ } p[12] = 0; cpu_name = (char *)p; + + /* Skip leading spaces in CPU name string */ + while (cpu_name[0] == ' ' && strlen(cpu_name) > 0) + cpu_name++; } - /* Skip leading spaces in CPU name string */ - while (cpu_name[0] == ' ') - cpu_name++;
microcode_ver.lo = 0; microcode_ver.hi = 0;