summaryrefslogtreecommitdiff
path: root/common/motion_sense.c
diff options
context:
space:
mode:
authorRandall Spangler <rspangler@chromium.org>2017-12-08 13:47:29 -0800
committerchrome-bot <chrome-bot@chromium.org>2017-12-13 12:33:37 -0800
commit7d2ce0c47e06622e2f423d33eec5ffceeeeb6a01 (patch)
tree9a38a88888a208132d3c8b37083b20a6a50b5fb2 /common/motion_sense.c
parent84124045457e115e6be116fa0a7215098ba7f0d5 (diff)
downloadchrome-ec-7d2ce0c47e06622e2f423d33eec5ffceeeeb6a01.tar.gz
ec_commands: Remove zero-size structs
The size of empty structs (and unions) varies between C and C++. When including in C++ code our external API in ec_commands.h header with extern "C". clang will complain (correctly) for all empty structs: error: empty struct has size 0 in C, size 1 in C++ [-Werror,-Wextern-c-compat] Remove them from the ec_commands.h header file. ectool.c has some ugly macros which assume subcommands have both requests and responses. Change those macros so they only reference the non-empty sub-structs. The macros are still ugly, but generate identical output, and don't rely upon zero-length structs. BUG=chromium:792408 BRANCH=none TEST=manual 1) Compile the following using 'clang -Wall -Werror': #include <stdint.h> extern "C" { #include "include/ec_commands.h" } int main(void) { return 0; } It compiles without error. 2) Copy the lb_command_paramcount, ms_command_sizes, and cs_paramcount globals from ectool.c to a dummy .c file and compile with 'gcc -S' to generate assembly. Do the same after applying this patch. Confirm the arrays have the same contents. Change-Id: Iad76f10315b97205b42118ce070463071fe97128 Signed-off-by: Randall Spangler <rspangler@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/820649 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Reviewed-by: Shawn N <shawnn@chromium.org>
Diffstat (limited to 'common/motion_sense.c')
-rw-r--r--common/motion_sense.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/common/motion_sense.c b/common/motion_sense.c
index 4e3711842b..51d1f4ec03 100644
--- a/common/motion_sense.c
+++ b/common/motion_sense.c
@@ -1375,7 +1375,7 @@ static int host_cmd_motion_sense(struct host_cmd_handler_args *args)
}
if (ret != EC_RES_SUCCESS)
return ret;
- args->response_size = sizeof(out->set_activity);
+ args->response_size = 0;
break;
}
#endif /* defined(CONFIG_GESTURE_HOST_DETECTION) */