ec/google/chromeec: Fix Coverity Scan error (BAD_SHIFT)
commit7777e1c30b5c9d47388627c080ff86a4e043ec7e
authorTim Wawrzynczak <twawrzynczak@chromium.org>
Tue, 14 Jul 2020 19:30:46 +0000 (14 13:30 -0600)
committerTim Wawrzynczak <twawrzynczak@chromium.org>
Wed, 22 Jul 2020 21:06:56 +0000 (22 21:06 +0000)
tree08a66a6484f3267dd90a27b6c6b66efd24eae447
parent60c619f6a3c0fbe2f53095a029cd07a11f5cf5e1
ec/google/chromeec: Fix Coverity Scan error (BAD_SHIFT)

A recent Coverity scan found an issue with the way the
EC_HOST_EVENT_MASK macro was being used. It was being passed values
between 0 and 63, but since it is doing basically (1ULL << (value - 1)),
this caused a shift of -1 when `i` is 0 and also doesn't reach the 63rd
bit of the mask. This is fixed by incrementing the start and end
conditions of the loop by 1, so the event mask ranges from bits 0 to 63,
instead of -1 to 62.

Found-by: Coverity CID 1430218
Signed-off-by: Tim Wawrzynczak <twawrzynczak@chromium.org>
Change-Id: I6a7cfa64545f3d313de24407f0a91b48368f2a8a
Reviewed-on: https://review.coreboot.org/c/coreboot/+/43460
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Furquan Shaikh <furquan@google.com>
Reviewed-by: Karthik Ramasubramanian <kramasub@google.com>
src/ec/google/chromeec/ec.c