summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJack Rosenthal <jrosenth@chromium.org>2019-05-09 09:40:32 -0600
committerCommit Bot <commit-bot@chromium.org>2019-05-29 20:30:17 +0000
commit76233d0a5516424ea5b5c8f2229ab291922c3a84 (patch)
treeb2121d8ca88c03d4273eb225d9bd157155f00b5d
parentd18859bee6110f7039a3268858bb068f56c3a496 (diff)
downloadchrome-ec-76233d0a5516424ea5b5c8f2229ab291922c3a84.tar.gz
common: add __maybe_unused attribute
Functions which might go unused under a particular set of CONFIG_ options have historically been wrapped in an ifdef to clear up compiler warnings about unused functions. Since we are trying to reduce conditional compilation in favor of macros like IS_ENABLED, the Linux kernel style guide suggests using __maybe_unused for these functions. This adds the __maybe_unused macro. BUG=none BRANCH=none TEST=make buildall -j Change-Id: Ia8239ad566b5aa518c258eaab0e4dceada790da4 Signed-off-by: Jack Rosenthal <jrosenth@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1602489 Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Daisuke Nojiri <dnojiri@chromium.org> (cherry picked from commit f1a16a6688f52e3de9809402564b26af67f265a6) Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/1634800 Commit-Queue: Diana Z <dzigterman@chromium.org> Tested-by: Diana Z <dzigterman@chromium.org>
-rw-r--r--include/common.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/common.h b/include/common.h
index f6bf9b1308..70243dcb26 100644
--- a/include/common.h
+++ b/include/common.h
@@ -66,6 +66,17 @@
#endif
/*
+ * __maybe_unused is equivalent to the Linux kernel definition, so we
+ * can follow the Kernel style guide more closely.
+ *
+ * An example use case is a function which is only used under certain
+ * CONFIG options.
+ */
+#ifndef __maybe_unused
+#define __maybe_unused __attribute__((unused))
+#endif
+
+/*
* externally_visible is required by GCC to avoid kicking out memset.
*/
#ifndef __visible