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:
parent
391bf7b37c
commit
59fd10000e
@ -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
|
* EAGAIN The queue was full and the O_NONBLOCK flag was set for the
|
||||||
* message queue description referred to by mqdes.
|
* message queue description referred to by mqdes.
|
||||||
* EINVAL Either msg or mqdes is NULL or the value of prio is invalid.
|
* 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
|
* EMSGSIZE 'msglen' was greater than the maxmsgsize attribute of the
|
||||||
* message queue.
|
* message queue.
|
||||||
* EINTR The call was interrupted by a signal handler.
|
* EINTR The call was interrupted by a signal handler.
|
||||||
|
@ -66,7 +66,7 @@
|
|||||||
* returned.
|
* returned.
|
||||||
*
|
*
|
||||||
* EINVAL Either msg or msgq is NULL or the value of prio is invalid.
|
* 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
|
* EMSGSIZE 'msglen' was greater than the maxmsgsize attribute of the
|
||||||
* message queue.
|
* message queue.
|
||||||
*
|
*
|
||||||
@ -88,14 +88,14 @@ int nxmq_verify_send(FAR FAR struct file *mq, FAR const char *msg,
|
|||||||
|
|
||||||
/* Verify the input parameters */
|
/* Verify the input parameters */
|
||||||
|
|
||||||
if (msg == NULL || msgq == NULL || prio > MQ_PRIO_MAX)
|
if (msg == NULL || msgq == NULL || prio >= MQ_PRIO_MAX)
|
||||||
{
|
{
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((mq->f_oflags & O_WROK) == 0)
|
if ((mq->f_oflags & O_WROK) == 0)
|
||||||
{
|
{
|
||||||
return -EPERM;
|
return -EBADF;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msglen > (size_t)msgq->maxmsgsize)
|
if (msglen > (size_t)msgq->maxmsgsize)
|
||||||
|
Loading…
Reference in New Issue
Block a user