[coreboot-gerrit] New patch to review for coreboot: amdmct: Rewrite mct_ResetDataStruct_D to avoid array-bounds warning

Martin Roth (martinroth@google.com) gerrit at coreboot.org
Thu Dec 29 22:25:46 CET 2016


Martin Roth (martinroth at google.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/17992

-gerrit

commit 160d6d2ec338f91651fbb8910c17ebd885856d76
Author: Martin Roth <martinroth at google.com>
Date:   Thu Dec 29 14:03:50 2016 -0700

    amdmct: Rewrite mct_ResetDataStruct_D to avoid array-bounds warning
    
    The code was intentionally using an offset past the end of the array to
    get the value of the next byte when starting to clear the structure.
    Rewrite it to get the end of the array and then increment the starting
    value.
    
    Fixes warning for GCC 6.2 toolchain update:
    src/northbridge/amd/amdfam10/../amdmct/mct/mct_d.c:3628:27:
    In function 'mct_ResetDataStruct_D':
    error: index 2 denotes an offset greater than size of 'u8[2][4]
    {aka unsigned char[2][4]}' [-Werror=array-bounds]
    
    Change-Id: Ic81cf5e57992fc0e45f6c96b62a35742a8ef891f
    Signed-off-by: Martin Roth <martinroth at google.com>
---
 src/northbridge/amd/amdmct/mct/mct_d.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/northbridge/amd/amdmct/mct/mct_d.c b/src/northbridge/amd/amdmct/mct/mct_d.c
index 62fc626..b45bf1c 100644
--- a/src/northbridge/amd/amdmct/mct/mct_d.c
+++ b/src/northbridge/amd/amdmct/mct/mct_d.c
@@ -3625,9 +3625,9 @@ static void mct_ResetDataStruct_D(struct MCTStatStruc *pMCTstat,
 			p[i] = 0;
 		}
 
-		start = (u32)(&((struct DCTStatStruc *)0)->CH_D_BC_RCVRDLY[2][4]);
+		start = (u32)(&((struct DCTStatStruc *)0)->CH_D_BC_RCVRDLY[2][3]);
 		stop = sizeof(struct DCTStatStruc);
-		for (i = start; i < stop; i++) {
+		for (i = start + 1; i < stop; i++) {
 			p[i] = 0;
 		}
 		pDCTstat->HostBiosSrvc1 = host_serv1;



More information about the coreboot-gerrit mailing list