diff options
author | Gwendal Grignou <gwendal@chromium.org> | 2019-03-11 16:07:55 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2019-03-26 04:42:56 -0700 |
commit | ac77140b7f4f42075d2377fc9d956a636b05aacf (patch) | |
tree | c64c6a30916ff741a2ab235141f7bd071cd54483 /util/ectool.c | |
parent | bb266fc26fc05d4ab22de6ad7bce5b477c9f9140 (diff) | |
download | chrome-ec-ac77140b7f4f42075d2377fc9d956a636b05aacf.tar.gz |
common: bit change 1 << constants with BIT(constants)
Mechanical replacement of bit operation where operand is a constant.
More bit operation exist, but prone to errors.
Reveal a bug in npcx:
chip/npcx/system-npcx7.c:114:54: error: conversion from 'long unsigned int' to 'uint8_t' {aka 'volatile unsigned char'} changes value from '16777215' to '255' [-Werror=overflow]
BUG=None
BRANCH=None
TEST=None
Change-Id: I006614026143fa180702ac0d1cc2ceb1b3c6eeb0
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1518660
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Diffstat (limited to 'util/ectool.c')
-rw-r--r-- | util/ectool.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/util/ectool.c b/util/ectool.c index 35dab22114..522daa572e 100644 --- a/util/ectool.c +++ b/util/ectool.c @@ -661,7 +661,7 @@ int cmd_inventory(int argc, char *argv[]) printf("EC supported features:\n"); for (i = 0, idx = 0; i < 2; i++) { for (j = 0; j < 32; j++, idx++) { - if (r.flags[i] & (1 << j)) { + if (r.flags[i] & BIT(j)) { if (idx >= ARRAY_SIZE(ec_feature_names) || !ec_feature_names[idx] || strlen(ec_feature_names[idx]) == 0) @@ -820,7 +820,7 @@ int cmd_uptimeinfo(int argc, char *argv[]) printf("EC reset flags at last EC boot: "); flag_count = 0; for (flag = 0; flag != ARRAY_SIZE(reset_flag_strings); ++flag) { - if ((r.ec_reset_flags & (1 << flag)) != 0) { + if ((r.ec_reset_flags & BIT(flag)) != 0) { if (flag_count) printf(" | "); printf(reset_flag_strings[flag]); @@ -2413,7 +2413,7 @@ static int get_num_fans(void) * check whether it has fan support enabled. */ rv = ec_command(EC_CMD_GET_FEATURES, 0, NULL, 0, &r, sizeof(r)); - if (rv >= 0 && !(r.flags[0] & (1 << EC_FEATURE_PWM_FAN))) + if (rv >= 0 && !(r.flags[0] & BIT(EC_FEATURE_PWM_FAN))) return 0; for (idx = 0; idx < EC_FAN_SPEED_ENTRIES; idx++) { @@ -4142,10 +4142,10 @@ static int ms_help(const char *cmd) static void motionsense_display_activities(uint32_t activities) { - if (activities & (1 << MOTIONSENSE_ACTIVITY_SIG_MOTION)) + if (activities & BIT(MOTIONSENSE_ACTIVITY_SIG_MOTION)) printf("%d: Significant motion\n", MOTIONSENSE_ACTIVITY_SIG_MOTION); - if (activities & (1 << MOTIONSENSE_ACTIVITY_DOUBLE_TAP)) + if (activities & BIT(MOTIONSENSE_ACTIVITY_DOUBLE_TAP)) printf("%d: Double tap\n", MOTIONSENSE_ACTIVITY_DOUBLE_TAP); } @@ -7029,7 +7029,7 @@ int cmd_proto_info(int argc, char *argv[]) printf(" protocol versions:"); for (i = 0; i < 32; i++) { - if (info.protocol_versions & (1 << i)) + if (info.protocol_versions & BIT(i)) printf(" %d", i); } printf("\n"); @@ -7388,7 +7388,7 @@ static int show_fields(struct ec_mkbp_config *config, int argc, char *argv[]) param = keyconfig_params; for (i = 0; i < ARRAY_SIZE(keyconfig_params); i++, param++) { - if (mask & (1 << i)) { + if (mask & BIT(i)) { fprintf(stderr, "%-12s %u\n", param->name, get_value(param, (char *)config)); } |