diff options
author | Tom Hughes <tomhughes@chromium.org> | 2021-09-29 23:40:39 +0000 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-10-01 23:32:56 +0000 |
commit | 506dcb5e5b2aa1d4864a98972540ad95396ef372 (patch) | |
tree | 00d7d2e48dbb788cd7d31c09e6d9fc07a06beb5a /common | |
parent | 82393ec1c3c8a9d3e98cfccb52622d7af577427d (diff) | |
download | chrome-ec-506dcb5e5b2aa1d4864a98972540ad95396ef372.tar.gz |
common/motion_sense: Avoid comparison between negative value and unsigned char
clang fails to compile due to the following:
common/motion_sense.c:1123:34: error: result of comparison of constant -1
with expression of type 'const uint8_t' (aka 'const unsigned char') is
always false [-Werror,-Wtautological-constant-out-of-range-compare]
(in->sensor_odr.sensor_num ==
~~~~~~~~~~~~~~~~~~~~~~~~~ ^
common/motion_sense.c:1454:27: error: result of comparison of constant -1
with expression of type 'const uint8_t' (aka 'const unsigned char') is
always false [-Werror,-Wtautological-constant-out-of-range-compare]
in->spoof.sensor_id == MOTION_SENSE_ACTIVITY_SENSOR_ID) {
~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
As indicated by the TEST line, the output is identical before and after
this change.
BRANCH=none
BUG=b:172020503
TEST=./util/compare_build.sh -b all -j 90
=> MATCH
Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Change-Id: Ieb55b385dfe9e07a8a7098ac3b456a0504215d94
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3197753
Reviewed-by: Paul Fagerburg <pfagerburg@chromium.org>
Diffstat (limited to 'common')
-rw-r--r-- | common/motion_sense.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/common/motion_sense.c b/common/motion_sense.c index 0952068a72..f37b284268 100644 --- a/common/motion_sense.c +++ b/common/motion_sense.c @@ -1120,6 +1120,7 @@ static enum ec_status host_cmd_motion_sense(struct host_cmd_handler_args *args) return EC_RES_INVALID_PARAM; if (IS_ENABLED(CONFIG_GESTURE_HOST_DETECTION) && + MOTION_SENSE_ACTIVITY_SENSOR_ID >= 0 && (in->sensor_odr.sensor_num == MOTION_SENSE_ACTIVITY_SENSOR_ID)) out->info.type = MOTIONSENSE_TYPE_ACTIVITY; @@ -1451,6 +1452,7 @@ static enum ec_status host_cmd_motion_sense(struct host_cmd_handler_args *args) case MOTIONSENSE_CMD_SPOOF: { /* spoof activity if it is activity sensor */ if (IS_ENABLED(CONFIG_GESTURE_HOST_DETECTION) && + MOTION_SENSE_ACTIVITY_SENSOR_ID >= 0 && in->spoof.sensor_id == MOTION_SENSE_ACTIVITY_SENSOR_ID) { switch (in->spoof.activity_num) { #ifdef CONFIG_BODY_DETECTION |