summaryrefslogtreecommitdiff
path: root/extra
diff options
context:
space:
mode:
authorGwendal Grignou <gwendal@chromium.org>2018-10-16 10:32:25 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-10-23 22:50:45 -0700
commitf5d38b0ac1b64a03a23f5bf9bf938d679c33d0d4 (patch)
treea56cc57b26d0cc1b00ca1526289fb0421a45160b /extra
parent75f7dca3c3d03527e23e9414d0dff85d63c6ea26 (diff)
downloadchrome-ec-f5d38b0ac1b64a03a23f5bf9bf938d679c33d0d4.tar.gz
ec: Add macro to check if constant index is too large
BUILD_ASSERT can only be used for declarative code, add a macro to check if a condition resolved at build time is true or not. Take advantage of compiler detection of division by zero error message. [-Werror=div-by-zero] BUG=none BRANCH=eve,nocturne TEST=compile, check error is detected when condition is not true. Change-Id: I4ab1ad4ae516c00c9e30e778dd81f18893ef1673 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1283969 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Diffstat (limited to 'extra')
-rw-r--r--extra/lightbar/simulation.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/extra/lightbar/simulation.h b/extra/lightbar/simulation.h
index e851f718c5..6028c15dd3 100644
--- a/extra/lightbar/simulation.h
+++ b/extra/lightbar/simulation.h
@@ -48,6 +48,8 @@ int fake_consolecmd_lightbar(int argc, char *argv[]);
#define _BA0_(c, x) _BA1_(c, x)
#define BUILD_ASSERT(cond) _BA0_(cond, __LINE__)
+#define BUILD_CHECK_INLINE(value, cond_true) ((value) / (!!(cond_true)))
+
/* Number of elements in an array */
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))