diff options
author | Tom Hughes <tomhughes@chromium.org> | 2022-10-11 13:58:46 -0700 |
---|---|---|
committer | Chromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2022-10-12 19:51:40 +0000 |
commit | 65da9cc08766e307e5d288e1d7848c83384dae21 (patch) | |
tree | 41d555c2174abf1ecb135c501ce92dd7870ac80a | |
parent | 7047f8ffb2dc3382a1dabe16d15a3e36db479f3f (diff) | |
download | chrome-ec-65da9cc08766e307e5d288e1d7848c83384dae21.tar.gz |
include/ec_commands.h: Fix unaligned access warnings
When building with clang, it now warns if there is an unpacked struct
nested in a packed struct:
include/ec_commands.h:3053:4: error: field within 'struct
ec_params_motion_sense::(unnamed at include/ec_commands.h:3044:3)' is
less aligned than 'union ec_params_motion_sense::(anonymous at
include/ec_commands.h:3053:4)' and is usually due to 'struct
ec_params_motion_sense::(unnamed at include/ec_commands.h:3044:3)' being
packed, which can lead to unaligned accesses
[-Werror,-Wunaligned-access]
union {
^
See https://github.com/llvm/llvm-project/issues/55520.
BRANCH=none
BUG=b:172020503
TEST=./util/compare_build.sh -b all -j 120
=> MATCH
Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Change-Id: I5c89746d7e2e93183f4706376e6cda0be4589c01
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3946036
Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org>
-rw-r--r-- | include/ec_commands.h | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/include/ec_commands.h b/include/ec_commands.h index 46df67f053..7bb1f2b3d9 100644 --- a/include/ec_commands.h +++ b/include/ec_commands.h @@ -3062,7 +3062,7 @@ struct ec_params_motion_sense { /* spoof activity state */ uint8_t activity_state; }; - }; + } __ec_todo_packed; } spoof; /* Used for MOTIONSENSE_CMD_TABLET_MODE_LID_ANGLE. */ @@ -3098,7 +3098,7 @@ struct ec_params_motion_sense { uint8_t sensor_num; uint8_t activity; /* enum motionsensor_activity */ } get_activity; - }; + } __ec_todo_packed; } __ec_todo_packed; enum motion_sense_cmd_info_flags { @@ -3398,7 +3398,7 @@ struct ec_params_port80_read { uint32_t offset; uint32_t num_entries; } read_buffer; - }; + } __ec_todo_packed; } __ec_todo_packed; struct ec_response_port80_read { @@ -4732,7 +4732,7 @@ struct ec_params_charge_state { uint32_t param; /* param to set */ uint32_t value; /* value to set */ } set_param; - }; + } __ec_todo_packed; uint8_t chgnum; /* Version 1 supports chgnum */ } __ec_todo_packed; @@ -6046,7 +6046,7 @@ struct ec_response_pd_chip_info { union { uint8_t fw_version_string[8]; uint64_t fw_version_number; - }; + } __ec_align2; } __ec_align2; struct ec_response_pd_chip_info_v1 { @@ -6056,11 +6056,11 @@ struct ec_response_pd_chip_info_v1 { union { uint8_t fw_version_string[8]; uint64_t fw_version_number; - }; + } __ec_align2; union { uint8_t min_req_fw_version_string[8]; uint64_t min_req_fw_version_number; - }; + } __ec_align2; } __ec_align2; /* Run RW signature verification and get status */ |