diff options
author | Timothy Pearson <tpearson@raptorengineeringinc.com> | 2015-04-12 14:11:27 -0500 |
---|---|---|
committer | Stefan Reinauer <stefan.reinauer@coreboot.org> | 2015-07-07 01:38:17 +0200 |
commit | 46b2271ea49d43607cbed273b367f48cf04d844d (patch) | |
tree | 76698c5bbbcb9359a73706f9d76d507208659bec /src | |
parent | 0004ae8f4bf13e549474c5db998f4708fb0b88e8 (diff) | |
download | coreboot-46b2271ea49d43607cbed273b367f48cf04d844d.tar.xz |
northbridge/amd/amdfam10: Remove array to null comparison
The address of array 'sysinfo->DCTstatA' will always evaluate to 'true'.
Remove checking the base pointer of an array for validity.
Found-by: Coverity (CID 1293135: Incorrect expression)
Found-by: Clang (Wpointer-bool-conversion)
Change-Id: I99c9c9f1564dfb997c60b2a895d664e3b06c117b
Signed-off-by: Timothy Pearson <tpearson@raptorengineeringinc.com>
Reviewed-on: http://review.coreboot.org/9596
Tested-by: build bot (Jenkins)
Tested-by: Raptor Engineering Automated Test Stand <noreply@raptorengineeringinc.com>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/northbridge/amd/amdfam10/raminit_amdmct.c | 51 |
1 files changed, 25 insertions, 26 deletions
diff --git a/src/northbridge/amd/amdfam10/raminit_amdmct.c b/src/northbridge/amd/amdfam10/raminit_amdmct.c index 3523420071..a0d47f4afd 100644 --- a/src/northbridge/amd/amdfam10/raminit_amdmct.c +++ b/src/northbridge/amd/amdfam10/raminit_amdmct.c @@ -207,40 +207,39 @@ static void raminit_amdmct(struct sys_info *sysinfo) static void amdmct_cbmem_store_info(struct sys_info *sysinfo) { + if (!sysinfo) + return; + /* Save memory info structures for use in ramstage */ size_t i; - struct MCTStatStruc *pMCTstat = &(sysinfo->MCTstat); struct DCTStatStruc *pDCTstatA = NULL; - if (pMCTstat && sysinfo->DCTstatA) { - /* Allocate memory */ - struct amdmct_memory_info* mem_info; - mem_info = cbmem_add(CBMEM_ID_AMDMCT_MEMINFO, sizeof(struct amdmct_memory_info)); - if (!mem_info) - return; + /* Allocate memory */ + struct amdmct_memory_info* mem_info; + mem_info = cbmem_add(CBMEM_ID_AMDMCT_MEMINFO, sizeof(struct amdmct_memory_info)); + if (!mem_info) + return; - printk(BIOS_DEBUG, "%s: Storing AMDMCT configuration in CBMEM\n", __func__); + printk(BIOS_DEBUG, "%s: Storing AMDMCT configuration in CBMEM\n", __func__); - /* Initialize memory */ - memset(mem_info, 0, sizeof(struct amdmct_memory_info)); + /* Initialize memory */ + memset(mem_info, 0, sizeof(struct amdmct_memory_info)); - /* Copy data */ - memcpy(&mem_info->mct_stat, &(sysinfo->MCTstat), sizeof(struct MCTStatStruc)); - for (i = 0; i < MAX_NODES_SUPPORTED; i++) { - pDCTstatA = sysinfo->DCTstatA + i; - memcpy(&mem_info->dct_stat[i], pDCTstatA, sizeof(struct DCTStatStruc)); - } - mem_info->ecc_enabled = mctGet_NVbits(NV_ECC_CAP); - mem_info->ecc_scrub_rate = mctGet_NVbits(NV_DramBKScrub); + /* Copy data */ + memcpy(&mem_info->mct_stat, &(sysinfo->MCTstat), sizeof(struct MCTStatStruc)); + for (i = 0; i < MAX_NODES_SUPPORTED; i++) { + pDCTstatA = sysinfo->DCTstatA + i; + memcpy(&mem_info->dct_stat[i], pDCTstatA, sizeof(struct DCTStatStruc)); + } + mem_info->ecc_enabled = mctGet_NVbits(NV_ECC_CAP); + mem_info->ecc_scrub_rate = mctGet_NVbits(NV_DramBKScrub); - /* Zero out invalid/unused pointers */ + /* Zero out invalid/unused pointers */ #if IS_ENABLED(CONFIG_DIMM_DDR3) - - for (i = 0; i < MAX_NODES_SUPPORTED; i++) { - mem_info->dct_stat[i].C_MCTPtr = NULL; - mem_info->dct_stat[i].C_DCTPtr[0] = NULL; - mem_info->dct_stat[i].C_DCTPtr[1] = NULL; - } -#endif + for (i = 0; i < MAX_NODES_SUPPORTED; i++) { + mem_info->dct_stat[i].C_MCTPtr = NULL; + mem_info->dct_stat[i].C_DCTPtr[0] = NULL; + mem_info->dct_stat[i].C_DCTPtr[1] = NULL; } +#endif } |