[PATCH v3 07/10] spmsgq_err01: Use correct max values and fix 64bit

Joel Sherrill joel at rtems.org
Mon Oct 5 12:19:53 UTC 2020


On Mon, Oct 5, 2020 at 2:18 AM Sebastian Huber <
sebastian.huber at embedded-brains.de> wrote:

> On 04/10/2020 06:18, Kinsey Moore wrote:
>
> > Fix spmsgq_err01 on systems with 64-bit pointers and correct max value
> > mismatches and inaccuracies that are more noticable on 64-bit systems.
> > ---
> >   testsuites/sptests/spmsgq_err01/init.c | 6 +++---
> >   1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/testsuites/sptests/spmsgq_err01/init.c
> b/testsuites/sptests/spmsgq_err01/init.c
> > index c68d30da16..9a6a8855be 100644
> > --- a/testsuites/sptests/spmsgq_err01/init.c
> > +++ b/testsuites/sptests/spmsgq_err01/init.c
> > @@ -101,7 +101,7 @@ rtems_task Init(
> >     /* not enough memory for messages */
> >     status = rtems_message_queue_create(
> >       Queue_name[ 1 ],
> > -    SIZE_MAX / ( sizeof( uintptr_t ) + sizeof(
> CORE_message_queue_Buffer ) ),
> > +    UINT_MAX / ( sizeof( uintptr_t ) + sizeof(
> CORE_message_queue_Buffer ) ),
> I think this should be UINT32_MAX. However, on a 64-bit system this test
> case doesn't produce the intended error case.
> >       1,
> I think we need here something like MIN(SIZE_MAX / UINT32_MAX, 1)).
> >       RTEMS_DEFAULT_ATTRIBUTES,
> >       &Queue_id[ 1 ]
> > @@ -116,8 +116,8 @@ rtems_task Init(
> >     /* too large a request for messages */
> >     status = rtems_message_queue_create(
> >       Queue_name[ 1 ],
> > -    INT_MAX,
> > -    INT_MAX,
> > +    UINT_MAX,
> UINT32_MAX?
>

The signature is his:

rtems_status_code rtems_message_queue_create(
  rtems_name       name,
  uint32_t         count,
  size_t           max_message_size,
  rtems_attribute  attribute_set,
  rtems_id        *id
)

UINT32_MAX is right for count.

SIZE_MAX is right for max_message_size.

 > +    SIZE_MAX - sizeof( uintptr_t ) + 1 - sizeof(
> CORE_message_queue_Buffer ),
> >       RTEMS_DEFAULT_ATTRIBUTES,
> >       &Queue_id[ 1 ]
> >     );
> I am not sure about these changes.
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20201005/261a23ac/attachment.html>


More information about the devel mailing list