Add const Keyword to some function parameters in chainimpl.h

Sebastian Huber sebastian.huber at embedded-brains.de
Fri Apr 5 07:32:20 UTC 2019


On 05/04/2019 08:51, Andreas wrote:
>
> Hi there,
>
>
> while reviewing the doxygen documentation in this file I found some 
> instances where I think the function parameters should be made constant.
>
> Bellow my suggested changes:
>
>
> commit 9fc61307be4f21039b7cd4553099e29e5fd5e456 (HEAD)
>
> Author: Andreas Dachsberger <andreas.dachsberger at embedded-brains.de>
> Date:   Fri Apr 5 08:28:08 2019 +0200
>
>     Added const to function parameters.
> ---
> cpukit/include/rtems/score/chainimpl.h | 28 ++++++++++++++--------------
>
> 1 file changed, 14 insertions(+), 14 deletions(-)
>
> diff --git a/cpukit/include/rtems/score/chainimpl.h 
> b/cpukit/include/rtems/score/chainimpl.h
> index 0b9c193044..264cbe094c 100644
> --- a/cpukit/include/rtems/score/chainimpl.h
> +++ b/cpukit/include/rtems/score/chainimpl.h
> @@ -222,7 +222,7 @@ RTEMS_INLINE_ROUTINE const Chain_Node 
> *_Chain_Immutable_head(
>   * @return This method returns the permanent tail node of the chain.
>   */
>  RTEMS_INLINE_ROUTINE Chain_Node *_Chain_Tail(
> -  Chain_Control *the_chain
> +  const Chain_Control *the_chain
>  )
>  {
>    return &the_chain->Tail.Node;

It returns a non-const pointer to a member, so this cannot be made const.

> @@ -555,7 +555,7 @@ RTEMS_INLINE_ROUTINE void _Chain_Initialize_one(
>   * @param[in] the_node is the node to be extracted.
>   */
>  RTEMS_INLINE_ROUTINE void _Chain_Extract_unprotected(
> -  Chain_Node *the_node
> +  const Chain_Node *the_node
>  )
>  {
>    Chain_Node *next;

In case of RTEMS_DEBUG, this function writes to the node.

> @@ -858,10 +858,10 @@ typedef bool ( *Chain_Node_order )(
>   * @param[in] order The order relation.
>   */
>  RTEMS_INLINE_ROUTINE void _Chain_Insert_ordered_unprotected(
> -  Chain_Control    *the_chain,
> -  Chain_Node       *to_insert,
> -  const void       *left,
> -  Chain_Node_order  order
> +  Chain_Control          *the_chain,
> +  Chain_Node             *to_insert,
> +  const void             *left,
> +  const Chain_Node_order  order
>  )
>  {
>    const Chain_Node *tail = _Chain_Immutable_tail( the_chain );

Function pointers need no const.

> @@ -960,7 +960,7 @@ RTEMS_INLINE_ROUTINE void 
> _Chain_Iterator_registry_initialize(
>   */
>  RTEMS_INLINE_ROUTINE void _Chain_Iterator_registry_update(
>    Chain_Iterator_registry *the_registry,
> -  Chain_Node              *the_node_to_extract
> +  const Chain_Node        *the_node_to_extract
>  )
>  {
>    Chain_Node *iter_node;

Here we have an assignment to a non-const variable.

> @@ -1046,10 +1046,10 @@ RTEMS_INLINE_ROUTINE void 
> _Chain_Iterator_registry_update(
>   *   the linear time complexity in _Chain_Iterator_registry_update().
>   */
>  RTEMS_INLINE_ROUTINE void _Chain_Iterator_initialize(
> -  Chain_Control            *the_chain,
> -  Chain_Iterator_registry  *the_registry,
> -  Chain_Iterator           *the_iterator,
> -  Chain_Iterator_direction  direction
> +  const Chain_Control            *the_chain,
> +  Chain_Iterator_registry        *the_registry,
> +  Chain_Iterator                 *the_iterator,
> +  const Chain_Iterator_direction  direction
>  )
>  {
>    _Chain_Initialize_node( &the_iterator->Registry_node );
> @@ -1093,8 +1093,8 @@ RTEMS_INLINE_ROUTINE Chain_Node 
> *_Chain_Iterator_next(
>   * @param the_node The new iterator position.
>   */
>  RTEMS_INLINE_ROUTINE void _Chain_Iterator_set_position(
> -  Chain_Iterator *the_iterator,
> -  Chain_Node     *the_node
> +  Chain_Iterator   *the_iterator,
> +  const Chain_Node *the_node
>  )
>  {
>    the_iterator->position = the_node;
> @@ -1108,7 +1108,7 @@ RTEMS_INLINE_ROUTINE void 
> _Chain_Iterator_set_position(
>   * @param the_iterator The chain iterator.
>   */
>  RTEMS_INLINE_ROUTINE void _Chain_Iterator_destroy(
> -  Chain_Iterator *the_iterator
> +  const Chain_Iterator *the_iterator
>  )
>  {
>    _Chain_Extract_unprotected( &the_iterator->Registry_node );

The functions call non-const functions.

-- 
Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  : sebastian.huber at embedded-brains.de
PGP     : Public key available on request.

Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.




More information about the devel mailing list