Nico Huber has uploaded this change for review. ( https://review.coreboot.org/21801
Change subject: ich_descriptors: Fix more odd +1s ......................................................................
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.
Original-Change-Id: Ifa5455c999e90ff9121aed29f542d71ac9ca2b1c Original-Reviewed-on: https://review.coreboot.org/19044 Original-Tested-by: build bot (Jenkins) no-reply@coreboot.org Original-Reviewed-by: Philippe Mathieu-Daudé philippe.mathieu.daude@gmail.com Original-Reviewed-by: Stefan Reinauer stefan.reinauer@coreboot.org
Change-Id: I218475648010430f17942224f7a805e821115139 Signed-off-by: Nico Huber nico.huber@secunet.com --- M ich_descriptors.c 1 file changed, 7 insertions(+), 9 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/01/21801/1
diff --git a/ich_descriptors.c b/ich_descriptors.c index ecc2b95..66dbb44 100644 --- a/ich_descriptors.c +++ b/ich_descriptors.c @@ -611,26 +611,24 @@ 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++)