summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbe Levkoy <alevkoy@chromium.org>2023-01-09 11:38:19 -0700
committerChromeos LUCI <chromeos-scoped@luci-project-accounts.iam.gserviceaccount.com>2023-03-17 23:33:45 +0000
commitd3c26057ad2427b902469bcc19fce83ddbaf3ff7 (patch)
tree2c7aa72e6844328d928a92fab466af7fe99f7e57
parent60b941b4e0f1afe1584d146550af61d9e88d3785 (diff)
downloadchrome-ec-d3c26057ad2427b902469bcc19fce83ddbaf3ff7.tar.gz
TCPMv2: Check PRL flag names array size
Check at build time that the list of PRL flag names is as long as the list of flags. BUG=none TEST=make buildall BRANCH=none LOW_COVERAGE_REASON=native_posix doesn't model state transition timing Change-Id: I0f4a577bea3094329e31afec0a050c26f32c1f2c Signed-off-by: Abe Levkoy <alevkoy@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/4211271 Reviewed-by: Keith Short <keithshort@chromium.org>
-rw-r--r--common/usbc/usb_prl_sm.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/common/usbc/usb_prl_sm.c b/common/usbc/usb_prl_sm.c
index 076adae40d..6fa3011fa7 100644
--- a/common/usbc/usb_prl_sm.c
+++ b/common/usbc/usb_prl_sm.c
@@ -10,6 +10,7 @@
#include "charge_state.h"
#include "chipset.h"
#include "common.h"
+#include "compile_time_macros.h"
#include "console.h"
#include "cros_version.h"
#include "ec_commands.h"
@@ -123,6 +124,9 @@ __maybe_unused static void print_flag(const char *group, int set_or_clear,
/* Flag to disable checking data role on incoming messages. */
#define PRL_FLAGS_IGNORE_DATA_ROLE BIT(11)
+/* For checking flag_bit_names[] */
+#define PRL_FLAGS_COUNT 12
+
struct bit_name {
int value;
const char *name;
@@ -143,6 +147,7 @@ static __const_data const struct bit_name flag_bit_names[] = {
{ PRL_FLAGS_CHUNKING, "PRL_FLAGS_CHUNKING" },
{ PRL_FLAGS_IGNORE_DATA_ROLE, "PRL_FLAGS_IGNORE_DATA_ROLE" },
};
+BUILD_ASSERT(ARRAY_SIZE(flag_bit_names) == PRL_FLAGS_COUNT);
__maybe_unused static void print_bits(const char *group, const char *desc,
int value, const struct bit_name *names,