Jacob Garber has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/33210
Change subject: nb/amd/amdfam10: Use 64 bits in multiplication ......................................................................
nb/amd/amdfam10: Use 64 bits in multiplication
The literal needs to be cast to a uint64 to prevent num_nodes from being implicitly promoted to a signed int.
Change-Id: Id2fa328fb8d0a9827c7c78157c024736e9b26dc4 Signed-off-by: Jacob Garber jgarber1@ualberta.ca Found-by: Coverity CID 1347343 --- M src/northbridge/amd/amdfam10/northbridge.c 1 file changed, 1 insertion(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/10/33210/1
diff --git a/src/northbridge/amd/amdfam10/northbridge.c b/src/northbridge/amd/amdfam10/northbridge.c index a681961..17b0512 100644 --- a/src/northbridge/amd/amdfam10/northbridge.c +++ b/src/northbridge/amd/amdfam10/northbridge.c @@ -791,7 +791,7 @@
/* Calculate CC6 storage area size */ if (interleaved) - qword = (0x1000000 * num_nodes); + qword = (uint64_t)0x1000000 * num_nodes; else qword = 0x1000000;
Martin Roth has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/33210 )
Change subject: nb/amd/amdfam10: Use 64 bits in multiplication ......................................................................
Patch Set 1: Code-Review+2
Paul Menzel has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/33210 )
Change subject: nb/amd/amdfam10: Use 64 bits in multiplication ......................................................................
Patch Set 1:
(1 comment)
https://review.coreboot.org/#/c/33210/1/src/northbridge/amd/amdfam10/northbr... File src/northbridge/amd/amdfam10/northbridge.c:
https://review.coreboot.org/#/c/33210/1/src/northbridge/amd/amdfam10/northbr... PS1, Line 794: qword = (uint64_t)0x1000000 * num_nodes; Would 0x1000000UL or so also work?
Jacob Garber has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/33210 )
Change subject: nb/amd/amdfam10: Use 64 bits in multiplication ......................................................................
Patch Set 1:
(1 comment)
https://review.coreboot.org/#/c/33210/1/src/northbridge/amd/amdfam10/northbr... File src/northbridge/amd/amdfam10/northbridge.c:
https://review.coreboot.org/#/c/33210/1/src/northbridge/amd/amdfam10/northbr... PS1, Line 794: qword = (uint64_t)0x1000000 * num_nodes;
Would 0x1000000UL or so also work?
I don't think so. UL is unsigned long, which is 32 bits for us. Of course, it could be something different on other platforms, which is the problem with these integer literal suffixes. The "standard official" way is to use a macro like UINT64_C(), but by then you might as well just use a cast anyway.
HAOUAS Elyes has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/33210 )
Change subject: nb/amd/amdfam10: Use 64 bits in multiplication ......................................................................
Patch Set 1: Code-Review+1
Patrick Georgi has submitted this change and it was merged. ( https://review.coreboot.org/c/coreboot/+/33210 )
Change subject: nb/amd/amdfam10: Use 64 bits in multiplication ......................................................................
nb/amd/amdfam10: Use 64 bits in multiplication
The literal needs to be cast to a uint64 to prevent num_nodes from being implicitly promoted to a signed int.
Change-Id: Id2fa328fb8d0a9827c7c78157c024736e9b26dc4 Signed-off-by: Jacob Garber jgarber1@ualberta.ca Found-by: Coverity CID 1347343 Reviewed-on: https://review.coreboot.org/c/coreboot/+/33210 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Martin Roth martinroth@google.com Reviewed-by: HAOUAS Elyes ehaouas@noos.fr --- M src/northbridge/amd/amdfam10/northbridge.c 1 file changed, 1 insertion(+), 1 deletion(-)
Approvals: build bot (Jenkins): Verified Martin Roth: Looks good to me, approved HAOUAS Elyes: Looks good to me, but someone else must approve
diff --git a/src/northbridge/amd/amdfam10/northbridge.c b/src/northbridge/amd/amdfam10/northbridge.c index 0c594b9..e28b89b 100644 --- a/src/northbridge/amd/amdfam10/northbridge.c +++ b/src/northbridge/amd/amdfam10/northbridge.c @@ -779,7 +779,7 @@
/* Calculate CC6 storage area size */ if (interleaved) - qword = (0x1000000 * num_nodes); + qword = (uint64_t)0x1000000 * num_nodes; else qword = 0x1000000;