[Sound-open-firmware] [PATCH 3/3] mailbox: move multi-line macros to static inlines
Pierre-Louis Bossart
pierre-louis.bossart at linux.intel.com
Tue Apr 3 15:57:18 CEST 2018
Detected with Coverity:
In do_notify: The indentation of this code suggests it is nested when
it is not. (CWE-483)
multi_stmt_macro: The macro on this line expands into multiple
statements, only the first of which is nested within the preceding
parent while the rest are not.
if (msg->rx_size && msg->rx_size < SOF_IPC_MSG_MAX_SIZE)
mailbox_dspbox_read(msg->rx_data, 0, msg->rx_size);
Move mailbox macros to inline functions to remove the issue, keep
indentation the same and add typecasts as needed
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart at linux.intel.com>
---
src/include/reef/mailbox.h | 58 ++++++++++++++++++++++++++++------------------
1 file changed, 36 insertions(+), 22 deletions(-)
diff --git a/src/include/reef/mailbox.h b/src/include/reef/mailbox.h
index cedfbb7..b237e44 100644
--- a/src/include/reef/mailbox.h
+++ b/src/include/reef/mailbox.h
@@ -63,27 +63,41 @@
#define mailbox_get_debug_size() \
MAILBOX_DEBUG_SIZE
-#define mailbox_dspbox_write(dest, src, bytes) \
- rmemcpy((void*)(MAILBOX_DSPBOX_BASE + dest), src, bytes); \
- dcache_writeback_region((void*)(MAILBOX_DSPBOX_BASE + dest), bytes);
-
-#define mailbox_dspbox_read(dest, src, bytes) \
- dcache_invalidate_region((void*)(MAILBOX_DSPBOX_BASE + src), bytes); \
- rmemcpy(dest, (void*)(MAILBOX_DSPBOX_BASE + src), bytes);
-
-#define mailbox_hostbox_write(dest, src, bytes) \
- rmemcpy((void*)(MAILBOX_HOSTBOX_BASE + dest), src, bytes); \
- dcache_writeback_region((void*)(MAILBOX_HOSTBOX_BASE + dest), bytes);
-
-#define mailbox_hostbox_read(dest, src, bytes) \
- dcache_invalidate_region((void*)(MAILBOX_HOSTBOX_BASE + src), bytes); \
- rmemcpy(dest, (void*)(MAILBOX_HOSTBOX_BASE + src), bytes);
-
-#define mailbox_stream_write(dest, src, bytes) \
- do { \
- rmemcpy((void *)(MAILBOX_STREAM_BASE + dest), src, bytes); \
- dcache_writeback_region((void *)(MAILBOX_STREAM_BASE + dest), \
- bytes); \
- } while (0)
+static inline
+void mailbox_dspbox_write(size_t offset, const void *src, size_t bytes)
+{
+ rmemcpy((void *)(MAILBOX_DSPBOX_BASE + offset), src, bytes);
+ dcache_writeback_region((void *)(MAILBOX_DSPBOX_BASE + offset), bytes);
+}
+
+static inline
+void mailbox_dspbox_read(void *dest, size_t offset, size_t bytes)
+{
+ dcache_invalidate_region((void *)(MAILBOX_DSPBOX_BASE + offset), bytes);
+ rmemcpy(dest, (void *)(MAILBOX_DSPBOX_BASE + offset), bytes);
+}
+
+static inline
+void mailbox_hostbox_write(size_t offset, const void *src, size_t bytes)
+{
+ rmemcpy((void *)(MAILBOX_HOSTBOX_BASE + offset), src, bytes);
+ dcache_writeback_region((void *)(MAILBOX_HOSTBOX_BASE + offset), bytes);
+}
+
+static inline
+void mailbox_hostbox_read(void *dest, size_t offset, size_t bytes)
+{
+ dcache_invalidate_region((void *)(MAILBOX_HOSTBOX_BASE + offset),
+ bytes);
+ rmemcpy(dest, (void *)(MAILBOX_HOSTBOX_BASE + offset), bytes);
+}
+
+static inline
+void mailbox_stream_write(size_t offset, const void *src, size_t bytes)
+{
+ rmemcpy((void *)(MAILBOX_STREAM_BASE + offset), src, bytes);
+ dcache_writeback_region((void *)(MAILBOX_STREAM_BASE + offset),
+ bytes);
+}
#endif
--
2.14.1
More information about the Sound-open-firmware
mailing list