diff options
author | Tom Hughes <tomhughes@chromium.org> | 2021-10-05 22:13:55 +0000 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2021-10-06 20:00:29 +0000 |
commit | 0bd313665801b529d5e0622b802812b78148cd20 (patch) | |
tree | b9f53b9ae2bc5cac80276c91a4806a789f54c2e1 | |
parent | 9924e203b1289ca395b420abbf61b423a8465b98 (diff) | |
download | chrome-ec-0bd313665801b529d5e0622b802812b78148cd20.tar.gz |
common/usbc: Fix constness
When building with clang, it reports:
common/usbc/usb_prl_sm.c:2304:44: error: 'prl_tx_states' causes a
section type conflict with 'flag_bit_names'
static __const_data const struct usb_state prl_tx_states[] = {
^
common/usbc/usb_prl_sm.c:131:37: note: declared here
static __const_data struct bit_name flag_bit_names[] = {
^
common/usbc/usb_prl_sm.c:2346:44: error: 'prl_hr_states' causes a
section type conflict with 'flag_bit_names'
static __const_data const struct usb_state prl_hr_states[] = {
^
common/usbc/usb_prl_sm.c:131:37: note: declared here
static __const_data struct bit_name flag_bit_names[] = {
^
The issue is that flag_bit_names is not const. When making
flag_bit_names const, we must also make the argument to print_bits const
to fix the additional warning:
common/usbc/usb_prl_sm.c:169:56: error: passing 'const struct bit_name
[11]' to parameter of type 'struct bit_name *' discards qualifiers
[-Werror,-Wincompatible-pointer-types-discards-qualifiers]
print_bits(group, set_or_clear ? "Set" : "Clr", flag, flag_bit_names,
^~~~~~~~~~~~~~
common/usbc/usb_prl_sm.c:149:28: note: passing argument to parameter 'names' here
struct bit_name *names,
BRANCH=none
BUG=b:172020503
TEST=make CC=arm-none-eabi-clang BOARD=cret
Signed-off-by: Tom Hughes <tomhughes@chromium.org>
Change-Id: I95d28f53755dd23fe288ae70055e09fcf44511ad
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3205487
Reviewed-by: Edward Hill <ecgh@chromium.org>
-rw-r--r-- | common/usbc/usb_prl_sm.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/common/usbc/usb_prl_sm.c b/common/usbc/usb_prl_sm.c index a58a579775..b85a7ee553 100644 --- a/common/usbc/usb_prl_sm.c +++ b/common/usbc/usb_prl_sm.c @@ -128,7 +128,7 @@ struct bit_name { const char *name; }; -static __const_data struct bit_name flag_bit_names[] = { +static __const_data const struct bit_name flag_bit_names[] = { { PRL_FLAGS_TX_COMPLETE, "PRL_FLAGS_TX_COMPLETE" }, { PRL_FLAGS_SINK_NG, "PRL_FLAGS_SINK_NG" }, { PRL_FLAGS_WAIT_SINK_OK, "PRL_FLAGS_WAIT_SINK_OK" }, @@ -146,7 +146,7 @@ static __const_data struct bit_name flag_bit_names[] = { __maybe_unused static void print_bits(const char *group, const char *desc, int value, - struct bit_name *names, + const struct bit_name *names, int names_size) { int i; |