On Fri, 2018-01-19 at 01:31 +0000, Jie, Yang wrote:
-----Original Message----- From: sound-open-firmware-bounces@alsa-project.org [mailto:sound-open- firmware-bounces@alsa-project.org] On Behalf Of Pierre-Louis Bossart Sent: Friday, January 19, 2018 4:31 AM To: sound-open-firmware@alsa-project.org Cc: Pierre-Louis Bossart pierre-louis.bossart@linux.intel.com Subject: [Sound-open-firmware] [PATCH 1/2] ipc: add missing braces for multi- line macro in block
Detected with Coverity and fix with braces.
Details:
Code that is meant to be executed conditionally may be executed unconditionally
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.
http://cwe.mitre.org/data/definitions/483.html
Signed-off-by: Pierre-Louis Bossart pierre-louis.bossart@linux.intel.com
src/ipc/byt-ipc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/ipc/byt-ipc.c b/src/ipc/byt-ipc.c index 8897bb9..b5da4b6 100644 --- a/src/ipc/byt-ipc.c +++ b/src/ipc/byt-ipc.c @@ -67,8 +67,9 @@ static void do_notify(void) goto out;
/* copy the data returned from DSP */
- if (msg->rx_size && msg->rx_size < SOF_IPC_MSG_MAX_SIZE)
- if (msg->rx_size && msg->rx_size < SOF_IPC_MSG_MAX_SIZE) { mailbox_dspbox_read(msg->rx_data, 0, msg->rx_size);
- }
Isn't it better choice to change it in the macro definition then it is safe to call it in other places also?
diff --git a/src/include/reef/mailbox.h b/src/include/reef/mailbox.h index c0580a9..1179edf 100644 --- a/src/include/reef/mailbox.h +++ b/src/include/reef/mailbox.h @@ -63,19 +63,26 @@ 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);
do { \
rmemcpy((void*)(MAILBOX_DSPBOX_BASE + dest), src, bytes); \
dcache_writeback_region((void*)(MAILBOX_DSPBOX_BASE + dest), bytes); \
} while (0)
best to make these static inline.
Liam