Nico Huber has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/32741
Change subject: mb/google/glados: Fix false coverity alarms ......................................................................
mb/google/glados: Fix false coverity alarms
Coverity doesn't like the filling of adjacent arrays with a single memcpy(). The structure of the FSP headers doesn't allow us to loop over them either.
As simply replicating the memcpy() calls doesn't make the code any more readable, use the new memcpy_elen() and memcpy_dlen() macros.
CID=1401338..1401340, 1401342..1401343
Change-Id: Ie1419381f812b0ba0563163139a8cf0d0599e492 Signed-off-by: Nico Huber nico.h@gmx.de --- M src/mainboard/google/glados/variants/asuka/variant.c M src/mainboard/google/glados/variants/caroline/variant.c M src/mainboard/google/glados/variants/cave/variant.c M src/mainboard/google/glados/variants/chell/variant.c M src/mainboard/google/glados/variants/glados/variant.c M src/mainboard/google/glados/variants/lars/variant.c M src/mainboard/google/glados/variants/sentry/variant.c 7 files changed, 50 insertions(+), 64 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/41/32741/1
diff --git a/src/mainboard/google/glados/variants/asuka/variant.c b/src/mainboard/google/glados/variants/asuka/variant.c index 4c77897..1800470a 100644 --- a/src/mainboard/google/glados/variants/asuka/variant.c +++ b/src/mainboard/google/glados/variants/asuka/variant.c @@ -15,9 +15,9 @@ */
#include <stdint.h> -#include <string.h> #include <baseboard/variant.h> #include <fsp/soc_binding.h> +#include <lib.h>
void variant_memory_init_params( MEMORY_INIT_UPD *const memory_params, const int spd_index) @@ -39,14 +39,12 @@ /* Rcomp target */ const u16 RcompTarget[5] = { 100, 40, 40, 23, 40 };
- memcpy(memory_params->DqByteMapCh0, dq_map, - sizeof(memory_params->DqByteMapCh0) * 2); - memcpy(memory_params->DqsMapCpu2DramCh0, dqs_map, - sizeof(memory_params->DqsMapCpu2DramCh0) * 2); - memcpy(memory_params->RcompResistor, RcompResistor, - sizeof(memory_params->RcompResistor)); - memcpy(memory_params->RcompTarget, RcompTarget, - sizeof(memory_params->RcompTarget)); + memcpy_elen(memory_params->DqByteMapCh0, dq_map[0]); + memcpy_elen(memory_params->DqByteMapCh1, dq_map[1]); + memcpy_elen(memory_params->DqsMapCpu2DramCh0, dqs_map[0]); + memcpy_elen(memory_params->DqsMapCpu2DramCh1, dqs_map[1]); + memcpy_elen(memory_params->RcompResistor, RcompResistor); + memcpy_elen(memory_params->RcompTarget, RcompTarget); }
int is_dual_channel(const int spd_index) diff --git a/src/mainboard/google/glados/variants/caroline/variant.c b/src/mainboard/google/glados/variants/caroline/variant.c index d61a538..0fa7ee4 100644 --- a/src/mainboard/google/glados/variants/caroline/variant.c +++ b/src/mainboard/google/glados/variants/caroline/variant.c @@ -17,8 +17,8 @@ #include <baseboard/variant.h> #include <fsp/soc_binding.h> #include <gpio.h> +#include <lib.h> #include <stdint.h> -#include <string.h> #include <variant/gpio.h>
void variant_memory_init_params( @@ -41,14 +41,12 @@ /* Rcomp target */ const u16 RcompTarget[5] = { 100, 40, 40, 23, 40 };
- memcpy(memory_params->DqByteMapCh0, dq_map, - sizeof(memory_params->DqByteMapCh0) * 2); - memcpy(memory_params->DqsMapCpu2DramCh0, dqs_map, - sizeof(memory_params->DqsMapCpu2DramCh0) * 2); - memcpy(memory_params->RcompResistor, RcompResistor, - sizeof(memory_params->RcompResistor)); - memcpy(memory_params->RcompTarget, RcompTarget, - sizeof(memory_params->RcompTarget)); + memcpy_elen(memory_params->DqByteMapCh0, dq_map[0]); + memcpy_elen(memory_params->DqByteMapCh1, dq_map[1]); + memcpy_elen(memory_params->DqsMapCpu2DramCh0, dqs_map[0]); + memcpy_elen(memory_params->DqsMapCpu2DramCh1, dqs_map[1]); + memcpy_elen(memory_params->RcompResistor, RcompResistor); + memcpy_elen(memory_params->RcompTarget, RcompTarget); memory_params->DdrFreqLimit = 1600; }
diff --git a/src/mainboard/google/glados/variants/cave/variant.c b/src/mainboard/google/glados/variants/cave/variant.c index fc27fb4..4c0f8fa 100644 --- a/src/mainboard/google/glados/variants/cave/variant.c +++ b/src/mainboard/google/glados/variants/cave/variant.c @@ -17,8 +17,8 @@ #include <baseboard/variant.h> #include <fsp/soc_binding.h> #include <gpio.h> +#include <lib.h> #include <stdint.h> -#include <string.h> #include <variant/gpio.h>
void variant_memory_init_params( @@ -41,14 +41,12 @@ /* Rcomp target */ const u16 RcompTarget[5] = { 100, 40, 40, 23, 40 };
- memcpy(memory_params->DqByteMapCh0, dq_map, - sizeof(memory_params->DqByteMapCh0) * 2); - memcpy(memory_params->DqsMapCpu2DramCh0, dqs_map, - sizeof(memory_params->DqsMapCpu2DramCh0) * 2); - memcpy(memory_params->RcompResistor, RcompResistor, - sizeof(memory_params->RcompResistor)); - memcpy(memory_params->RcompTarget, RcompTarget, - sizeof(memory_params->RcompTarget)); + memcpy_elen(memory_params->DqByteMapCh0, dq_map[0]); + memcpy_elen(memory_params->DqByteMapCh1, dq_map[1]); + memcpy_elen(memory_params->DqsMapCpu2DramCh0, dqs_map[0]); + memcpy_elen(memory_params->DqsMapCpu2DramCh1, dqs_map[1]); + memcpy_elen(memory_params->RcompResistor, RcompResistor); + memcpy_elen(memory_params->RcompTarget, RcompTarget); }
void mainboard_gpio_smi_sleep(void) diff --git a/src/mainboard/google/glados/variants/chell/variant.c b/src/mainboard/google/glados/variants/chell/variant.c index 2d1b363..7b29137 100644 --- a/src/mainboard/google/glados/variants/chell/variant.c +++ b/src/mainboard/google/glados/variants/chell/variant.c @@ -17,8 +17,8 @@ #include <baseboard/variant.h> #include <fsp/soc_binding.h> #include <gpio.h> +#include <lib.h> #include <stdint.h> -#include <string.h> #include <variant/gpio.h>
void variant_memory_init_params( @@ -41,14 +41,12 @@ /* Rcomp target */ const u16 RcompTarget[5] = { 100, 40, 40, 23, 40 };
- memcpy(memory_params->DqByteMapCh0, dq_map, - sizeof(memory_params->DqByteMapCh0) * 2); - memcpy(memory_params->DqsMapCpu2DramCh0, dqs_map, - sizeof(memory_params->DqsMapCpu2DramCh0) * 2); - memcpy(memory_params->RcompResistor, RcompResistor, - sizeof(memory_params->RcompResistor)); - memcpy(memory_params->RcompTarget, RcompTarget, - sizeof(memory_params->RcompTarget)); + memcpy_elen(memory_params->DqByteMapCh0, dq_map[0]); + memcpy_elen(memory_params->DqByteMapCh1, dq_map[1]); + memcpy_elen(memory_params->DqsMapCpu2DramCh0, dqs_map[0]); + memcpy_elen(memory_params->DqsMapCpu2DramCh1, dqs_map[1]); + memcpy_elen(memory_params->RcompResistor, RcompResistor); + memcpy_elen(memory_params->RcompTarget, RcompTarget); }
void mainboard_gpio_smi_sleep(void) diff --git a/src/mainboard/google/glados/variants/glados/variant.c b/src/mainboard/google/glados/variants/glados/variant.c index fc27fb4..4c0f8fa 100644 --- a/src/mainboard/google/glados/variants/glados/variant.c +++ b/src/mainboard/google/glados/variants/glados/variant.c @@ -17,8 +17,8 @@ #include <baseboard/variant.h> #include <fsp/soc_binding.h> #include <gpio.h> +#include <lib.h> #include <stdint.h> -#include <string.h> #include <variant/gpio.h>
void variant_memory_init_params( @@ -41,14 +41,12 @@ /* Rcomp target */ const u16 RcompTarget[5] = { 100, 40, 40, 23, 40 };
- memcpy(memory_params->DqByteMapCh0, dq_map, - sizeof(memory_params->DqByteMapCh0) * 2); - memcpy(memory_params->DqsMapCpu2DramCh0, dqs_map, - sizeof(memory_params->DqsMapCpu2DramCh0) * 2); - memcpy(memory_params->RcompResistor, RcompResistor, - sizeof(memory_params->RcompResistor)); - memcpy(memory_params->RcompTarget, RcompTarget, - sizeof(memory_params->RcompTarget)); + memcpy_elen(memory_params->DqByteMapCh0, dq_map[0]); + memcpy_elen(memory_params->DqByteMapCh1, dq_map[1]); + memcpy_elen(memory_params->DqsMapCpu2DramCh0, dqs_map[0]); + memcpy_elen(memory_params->DqsMapCpu2DramCh1, dqs_map[1]); + memcpy_elen(memory_params->RcompResistor, RcompResistor); + memcpy_elen(memory_params->RcompTarget, RcompTarget); }
void mainboard_gpio_smi_sleep(void) diff --git a/src/mainboard/google/glados/variants/lars/variant.c b/src/mainboard/google/glados/variants/lars/variant.c index cff0096..e3edd29 100644 --- a/src/mainboard/google/glados/variants/lars/variant.c +++ b/src/mainboard/google/glados/variants/lars/variant.c @@ -15,9 +15,9 @@ */
#include <stdint.h> -#include <string.h> #include <baseboard/variant.h> #include <fsp/soc_binding.h> +#include <lib.h>
#define K4E6E304EB_MEM_ID 0x5
@@ -29,7 +29,7 @@ #define MEM_SINGLE_CHANC 0xc
void variant_memory_init_params( - MEMORY_INIT_UPD *const params, const int spd_index) + MEMORY_INIT_UPD *const memory_params, const int spd_index) { /* DQ byte map */ const u8 dq_map[2][12] = { @@ -58,14 +58,12 @@ if (spd_index == K4E6E304EB_MEM_ID) targeted_rcomp = StrengthendRcompTarget;
- memcpy(params->DqByteMapCh0, dq_map, - sizeof(params->DqByteMapCh0) * 2); - memcpy(params->DqsMapCpu2DramCh0, dqs_map, - sizeof(params->DqsMapCpu2DramCh0) * 2); - memcpy(params->RcompResistor, RcompResistor, - sizeof(params->RcompResistor)); - memcpy(params->RcompTarget, targeted_rcomp, - sizeof(params->RcompTarget)); + memcpy_elen(memory_params->DqByteMapCh0, dq_map[0]); + memcpy_elen(memory_params->DqByteMapCh1, dq_map[1]); + memcpy_elen(memory_params->DqsMapCpu2DramCh0, dqs_map[0]); + memcpy_elen(memory_params->DqsMapCpu2DramCh1, dqs_map[1]); + memcpy_elen(memory_params->RcompResistor, RcompResistor); + memcpy_dlen(memory_params->RcompTarget, targeted_rcomp); }
int is_dual_channel(const int spd_index) diff --git a/src/mainboard/google/glados/variants/sentry/variant.c b/src/mainboard/google/glados/variants/sentry/variant.c index 4c7fa23..e73aa3c 100644 --- a/src/mainboard/google/glados/variants/sentry/variant.c +++ b/src/mainboard/google/glados/variants/sentry/variant.c @@ -15,9 +15,9 @@ */
#include <stdint.h> -#include <string.h> #include <baseboard/variant.h> #include <fsp/soc_binding.h> +#include <lib.h>
#define K4E6E304EE_MEM_ID 0x3
@@ -51,12 +51,10 @@ if (spd_index == K4E6E304EE_MEM_ID) targeted_rcomp = StrengthendRcompTarget;
- memcpy(memory_params->DqByteMapCh0, dq_map, - sizeof(memory_params->DqByteMapCh0) * 2); - memcpy(memory_params->DqsMapCpu2DramCh0, dqs_map, - sizeof(memory_params->DqsMapCpu2DramCh0) * 2); - memcpy(memory_params->RcompResistor, RcompResistor, - sizeof(memory_params->RcompResistor)); - memcpy(memory_params->RcompTarget, targeted_rcomp, - sizeof(memory_params->RcompTarget)); + memcpy_elen(memory_params->DqByteMapCh0, dq_map[0]); + memcpy_elen(memory_params->DqByteMapCh1, dq_map[1]); + memcpy_elen(memory_params->DqsMapCpu2DramCh0, dqs_map[0]); + memcpy_elen(memory_params->DqsMapCpu2DramCh1, dqs_map[1]); + memcpy_elen(memory_params->RcompResistor, RcompResistor); + memcpy_dlen(memory_params->RcompTarget, targeted_rcomp); }
build bot (Jenkins) has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/32741 )
Change subject: mb/google/glados: Fix false coverity alarms ......................................................................
Patch Set 1:
(1 comment)
https://review.coreboot.org/#/c/32741/1/src/mainboard/google/glados/variants... File src/mainboard/google/glados/variants/lars/variant.c:
https://review.coreboot.org/#/c/32741/1/src/mainboard/google/glados/variants... PS1, Line 32: MEMORY_INIT_UPD *const memory_params, const int spd_index) need consistent spacing around '*' (ctx:WxV)
Nico Huber has abandoned this change. ( https://review.coreboot.org/c/coreboot/+/32741 )
Change subject: mb/google/glados: Fix false coverity alarms ......................................................................
Abandoned
superseded