Nico Huber has submitted this change and it was merged. ( https://review.coreboot.org/19044 )
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.
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 --- M ich_descriptors.c 1 file changed, 7 insertions(+), 9 deletions(-)
Approvals: build bot (Jenkins): Verified Philippe Mathieu-Daudé: Looks good to me, but someone else must approve Stefan Reinauer: Looks good to me, approved
diff --git a/ich_descriptors.c b/ich_descriptors.c index b6453ce..7e2521a 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++)