summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNico Huber <nico.huber@secunet.com>2017-03-29 16:31:49 +0200
committerNico Huber <nico.h@gmx.de>2017-06-20 11:47:24 +0200
commitd7c7552b4b7a94509a86404ee4bc9b0f2fdd7359 (patch)
tree3f7ac3cbf792ad89f581ff7884e6bff4a4577ca0
parent7258cf5197d2f1502430ad1c64027af2b341b7a6 (diff)
downloadflashrom-d7c7552b4b7a94509a86404ee4bc9b0f2fdd7359.tar.gz
flashrom-d7c7552b4b7a94509a86404ee4bc9b0f2fdd7359.tar.bz2
flashrom-d7c7552b4b7a94509a86404ee4bc9b0f2fdd7359.zip
ich_descriptors: Fix more odd +1s
+1 on everything doesn't make software greater per se. v2: o Fix another +1. o Amend style of similar (not +1 suffering) code, too. Change-Id: Ifa5455c999e90ff9121aed29f542d71ac9ca2b1c Signed-off-by: Nico Huber <nico.huber@secunet.com> Reviewed-on: https://review.coreboot.org/19044 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Philippe Mathieu-Daudé <philippe.mathieu.daude@gmail.com> Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
-rw-r--r--ich_descriptors.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/ich_descriptors.c b/ich_descriptors.c
index b6453cea0..7e2521a40 100644
--- a/ich_descriptors.c
+++ b/ich_descriptors.c
@@ -611,26 +611,24 @@ void prettyprint_ich_descriptor_straps(enum ich_chipset cs, const struct ich_des
unsigned int i, max_count;
msg_pdbg2("=== Softstraps ===\n");
- if (sizeof(desc->north.STRPs) / 4 + 1 < desc->content.MSL) {
- max_count = sizeof(desc->north.STRPs) / 4 + 1;
+ max_count = min(ARRAY_SIZE(desc->north.STRPs), desc->content.MSL);
+ if (max_count < desc->content.MSL) {
msg_pdbg2("MSL (%u) is greater than the current maximum of %u entries.\n",
- desc->content.MSL, max_count + 1);
+ desc->content.MSL, max_count);
msg_pdbg2("Only the first %u entries will be printed.\n", max_count);
- } else
- max_count = desc->content.MSL;
+ }
msg_pdbg2("--- North/MCH/PROC (%d entries) ---\n", max_count);
for (i = 0; i < max_count; i++)
msg_pdbg2("STRP%-2d = 0x%08x\n", i, desc->north.STRPs[i]);
msg_pdbg2("\n");
- if (sizeof(desc->south.STRPs) / 4 < desc->content.ISL) {
- max_count = sizeof(desc->south.STRPs) / 4;
+ max_count = min(ARRAY_SIZE(desc->south.STRPs), desc->content.ISL);
+ if (max_count < desc->content.ISL) {
msg_pdbg2("ISL (%u) is greater than the current maximum of %u entries.\n",
desc->content.ISL, max_count);
msg_pdbg2("Only the first %u entries will be printed.\n", max_count);
- } else
- max_count = desc->content.ISL;
+ }
msg_pdbg2("--- South/ICH/PCH (%d entries) ---\n", max_count);
for (i = 0; i < max_count; i++)