From 391bf7b37c11b3d52e6f17cd8e1ff1c95c7e0e77 Mon Sep 17 00:00:00 2001 From: yangjiao Date: Fri, 9 Jun 2023 10:13:19 +0800 Subject: [PATCH] sched/mqueue/mq_receive: fix the wrong return value when message queue is not opened for reading. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In POSIX testcase "open_posix_testsuite/conformance/interfaces/mq_receive/11-2.c", it will return "EPERM" when message queue is not opened for reading, but the standard POSIX specification in URL “https://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_receive.html” requires that "EBADF" be returned.So in this change, i update it. Signed-off-by: yangjiao --- sched/mqueue/mq_rcvinternal.c | 4 ++-- sched/mqueue/mq_receive.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sched/mqueue/mq_rcvinternal.c b/sched/mqueue/mq_rcvinternal.c index 19112b5852..91c2f9009d 100644 --- a/sched/mqueue/mq_rcvinternal.c +++ b/sched/mqueue/mq_rcvinternal.c @@ -62,7 +62,7 @@ * On success, zero (OK) is returned. A negated errno value is returned * on any failure: * - * EPERM Message queue opened not opened for reading. + * EBADF Message queue opened not opened for reading. * EMSGSIZE 'msglen' was less than the maxmsgsize attribute of the message * queue. * EINVAL Invalid 'msg' or 'msgq' @@ -91,7 +91,7 @@ int nxmq_verify_receive(FAR struct file *mq, FAR char *msg, size_t msglen) if ((mq->f_oflags & O_RDOK) == 0) { - return -EPERM; + return -EBADF; } if (msglen < (size_t)msgq->maxmsgsize) diff --git a/sched/mqueue/mq_receive.c b/sched/mqueue/mq_receive.c index 89725e3304..eecae0c480 100644 --- a/sched/mqueue/mq_receive.c +++ b/sched/mqueue/mq_receive.c @@ -192,7 +192,7 @@ ssize_t nxmq_receive(mqd_t mqdes, FAR char *msg, size_t msglen, * * EAGAIN The queue was empty, and the O_NONBLOCK flag was set * for the message queue description referred to by 'mqdes'. - * EPERM Message queue opened not opened for reading. + * EBADF Message queue opened not opened for reading. * EMSGSIZE 'msglen' was less than the maxmsgsize attribute of the * message queue. * EINTR The call was interrupted by a signal handler.