Suppress unused return values when using -c opt.
Change-Id: I9cfe54f1b71d4b2b5e321cd09282db2852664377
diff --git a/aos/common/libc/aos_strerror.cc b/aos/common/libc/aos_strerror.cc
index 2c9735d..c91fd00 100644
--- a/aos/common/libc/aos_strerror.cc
+++ b/aos/common/libc/aos_strerror.cc
@@ -24,7 +24,11 @@
__attribute__((unused))
char *aos_strerror_handle_result(int error, int ret, char *buffer) {
if (ret != 0) {
- const int r = snprintf(buffer, kBufferSize, "Unknown error %d", error);
+#ifndef NDEBUG
+ // assert doesn't use the return value when building optimized.
+ const int r =
+#endif
+ snprintf(buffer, kBufferSize, "Unknown error %d", error);
assert(r > 0);
}
return buffer;
diff --git a/aos/linux_code/ipc_lib/aos_sync.cc b/aos/linux_code/ipc_lib/aos_sync.cc
index 1275bbf..fc1d875 100644
--- a/aos/linux_code/ipc_lib/aos_sync.cc
+++ b/aos/linux_code/ipc_lib/aos_sync.cc
@@ -1,4 +1,5 @@
#if !AOS_DEBUG
+#undef NDEBUG
#define NDEBUG
#endif
diff --git a/aos/linux_code/ipc_lib/core_lib.c b/aos/linux_code/ipc_lib/core_lib.c
index ddcd7f5..23dd256 100644
--- a/aos/linux_code/ipc_lib/core_lib.c
+++ b/aos/linux_code/ipc_lib/core_lib.c
@@ -28,8 +28,13 @@
void *msg = NULL;
aos_shm_core *shm_core = global_core->mem_struct;
- int result = mutex_grab(&shm_core->msg_alloc_lock);
+ int result =
+ mutex_grab(&shm_core->msg_alloc_lock);
+#ifdef NDEBUG
+ (void)result;
+#else
assert(result == 0);
+#endif
shm_core->msg_alloc = (uint8_t *)shm_core->msg_alloc - length;
const uint8_t align_extra = (uintptr_t)shm_core->msg_alloc % alignment;
shm_core->msg_alloc = (uint8_t *)shm_core->msg_alloc - align_extra;
diff --git a/aos/linux_code/ipc_lib/queue.cc b/aos/linux_code/ipc_lib/queue.cc
index 81ad51b..21a2ea8 100644
--- a/aos/linux_code/ipc_lib/queue.cc
+++ b/aos/linux_code/ipc_lib/queue.cc
@@ -1,4 +1,5 @@
#if !AOS_DEBUG
+#undef NDEBUG
#define NDEBUG
#endif
diff --git a/third_party/cddlib/BUILD b/third_party/cddlib/BUILD
index 17a7fc4..72ed220 100644
--- a/third_party/cddlib/BUILD
+++ b/third_party/cddlib/BUILD
@@ -26,6 +26,7 @@
'-Wno-switch-enum',
'-Wno-empty-body',
'-Wno-sign-compare',
+ '-Wno-unused-result',
] + compiler_select({
'gcc': ['-Wno-unused-but-set-variable'],
'clang': []