You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/11/10 14:36:29 UTC

[incubator-nuttx] 01/02: mqueue: use to DEBUGASSERT to cover some param check

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit a4b378a583027d7493b45b25f6554514cb0d609e
Author: ligd <li...@xiaomi.com>
AuthorDate: Fri Sep 9 18:00:06 2022 +0800

    mqueue: use to DEBUGASSERT to cover some param check
    
    for the speed improve
    
    Signed-off-by: ligd <li...@xiaomi.com>
---
 sched/mqueue/mq_send.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sched/mqueue/mq_send.c b/sched/mqueue/mq_send.c
index 60eb932fc1..fca28a581b 100644
--- a/sched/mqueue/mq_send.c
+++ b/sched/mqueue/mq_send.c
@@ -117,6 +117,7 @@ int file_mq_send(FAR struct file *mq, FAR const char *msg, size_t msglen,
       /* Now allocate the message. */
 
       mqmsg = nxmq_alloc_msg();
+      DEBUGASSERT(mqmsg != NULL);
 
       /* Check if the message was successfully allocated */
 
@@ -129,8 +130,7 @@ int file_mq_send(FAR struct file *mq, FAR const char *msg, size_t msglen,
        * to be exceeded in that case.
        */
 
-      ret = (mqmsg == NULL) ? -ENOMEM :
-            nxmq_do_send(msgq, mqmsg, msg, msglen, prio);
+      ret = nxmq_do_send(msgq, mqmsg, msg, msglen, prio);
     }
 
   leave_critical_section(flags);