diff options
author | Tom Hughes <tomhughes@chromium.org> | 2019-09-20 10:04:44 -0700 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-10-02 10:19:57 +0000 |
commit | 83d793839479a6f3414dbf51c00536aff65618f3 (patch) | |
tree | 41047552e73878fad5ddbc4126d59a52643b041f /common/battery.c | |
parent | 4e692f29e3e5af6b85df472e4c4f936c6f461cb9 (diff) | |
download | chrome-ec-83d793839479a6f3414dbf51c00536aff65618f3.tar.gz |
host_command: Change host command return value to enum ec_status
If the host command handler callback function returns an int, it's easy
to accidentally mix up the enum ec_error_list and enum ec_status types.
The host commands always expect an enum ec_status type, so we change the
return value to be of that explicit type. Compilation will then fail if
you accidentally try to return an enum ec_error_list value.
Ran the following commands and then manually fixed up a few remaining
instances that were not caught:
git grep --name-only 'static int .*(struct host_cmd_handler_args \*args)' |\
xargs sed -i 's#static int \(.*\)(struct host_cmd_handler_args \*args)#\
static enum ec_status \1(struct host_cmd_handler_args \*args)##'
git grep --name-only 'int .*(struct host_cmd_handler_args \*args)' |\
xargs sed -i 's#int \(.*\)(struct host_cmd_handler_args \*args)#\
enum ec_status \1(struct host_cmd_handler_args \*args)##'
BRANCH=none
BUG=chromium:1004831
TEST=make buildall -j
Cq-Depend: chrome-internal:1872675
Change-Id: Id93df9387ac53d016a1594dba86c6642babbfd1e
Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1816865
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
Reviewed-by: Jack Rosenthal <jrosenth@chromium.org>
Diffstat (limited to 'common/battery.c')
-rw-r--r-- | common/battery.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/common/battery.c b/common/battery.c index 3f858f6f27..7b6c3ee5bd 100644 --- a/common/battery.c +++ b/common/battery.c @@ -320,7 +320,7 @@ static void clear_pending_cutoff(void) } DECLARE_HOOK(HOOK_AC_CHANGE, clear_pending_cutoff, HOOK_PRIO_DEFAULT); -static int battery_command_cutoff(struct host_cmd_handler_args *args) +static enum ec_status battery_command_cutoff(struct host_cmd_handler_args *args) { const struct ec_params_battery_cutoff *p; int rv; @@ -429,7 +429,8 @@ DECLARE_CONSOLE_COMMAND(battparam, console_command_battery_vendor_param, "<param> [value]", "Get or set battery vendor parameters"); -static int host_command_battery_vendor_param(struct host_cmd_handler_args *args) +static enum ec_status +host_command_battery_vendor_param(struct host_cmd_handler_args *args) { int rv; const struct ec_params_battery_vendor_param *p = args->params; @@ -458,7 +459,8 @@ DECLARE_HOST_COMMAND(EC_CMD_BATTERY_VENDOR_PARAM, #ifdef CONFIG_BATTERY_V2 #ifdef CONFIG_HOSTCMD_BATTERY_V2 static void battery_update(enum battery_index i); -static int host_command_battery_get_static(struct host_cmd_handler_args *args) +static enum ec_status +host_command_battery_get_static(struct host_cmd_handler_args *args) { const struct ec_params_battery_static_info *p = args->params; struct ec_response_battery_static_info *r = args->response; @@ -475,7 +477,8 @@ DECLARE_HOST_COMMAND(EC_CMD_BATTERY_GET_STATIC, host_command_battery_get_static, EC_VER_MASK(0)); -static int host_command_battery_get_dynamic(struct host_cmd_handler_args *args) +static enum ec_status +host_command_battery_get_dynamic(struct host_cmd_handler_args *args) { const struct ec_params_battery_dynamic_info *p = args->params; struct ec_response_battery_dynamic_info *r = args->response; |