sched/mqueue/mq_send: fix the wrong return value in mq_send function. And add the condition if message priority equal to MQ_PRIO_MAX.

Standard POSIX specification in URL “https://pubs.opengroup.org/onlinepubs/9699919799/functions/mq_send.html” requires that "EBADF" be returned when mqdes is not open for writing. And message priorities range from 0 to {MQ_PRIO_MAX}-1. In this change, i update them to follow POSIX spec.

Signed-off-by: yangjiao <yangjiao@xiaomi.com>
This commit is contained in:
yangjiao 2023-06-09 17:45:22 +08:00 committed by Xiang Xiao
parent 391bf7b37c
commit 59fd10000e
2 changed files with 4 additions and 4 deletions

View File

@ -216,7 +216,7 @@ int nxmq_send(mqd_t mqdes, FAR const char *msg, size_t msglen,
* EAGAIN The queue was full and the O_NONBLOCK flag was set for the
* message queue description referred to by mqdes.
* EINVAL Either msg or mqdes is NULL or the value of prio is invalid.
* EPERM Message queue opened not opened for writing.
* EBADF Message queue opened not opened for writing.
* EMSGSIZE 'msglen' was greater than the maxmsgsize attribute of the
* message queue.
* EINTR The call was interrupted by a signal handler.

View File

@ -66,7 +66,7 @@
* returned.
*
* EINVAL Either msg or msgq is NULL or the value of prio is invalid.
* EPERM Message queue opened not opened for writing.
* EBADF Message queue opened not opened for writing.
* EMSGSIZE 'msglen' was greater than the maxmsgsize attribute of the
* message queue.
*
@ -88,14 +88,14 @@ int nxmq_verify_send(FAR FAR struct file *mq, FAR const char *msg,
/* Verify the input parameters */
if (msg == NULL || msgq == NULL || prio > MQ_PRIO_MAX)
if (msg == NULL || msgq == NULL || prio >= MQ_PRIO_MAX)
{
return -EINVAL;
}
if ((mq->f_oflags & O_WROK) == 0)
{
return -EPERM;
return -EBADF;
}
if (msglen > (size_t)msgq->maxmsgsize)