Need help in writing the Strong APA code

Sebastian Huber sebastian.huber at embedded-brains.de
Mon Jul 27 11:03:44 UTC 2020


On 27/07/2020 10:40, Richi Dubey wrote:

> Hi,
>
> When I am compiling my current code, I am getting the following 
> compiler warning:
>
> ---------------------------------------------------------------
>
> /home/richi/quick-start/src/rtems/c/src/../../cpukit/score/src/schedulerstrongapa.c: 
> In function '_Scheduler_strong_APA_Extract_from_ready':
> /home/richi/quick-start/src/rtems/c/src/../../cpukit/score/src/schedulerstrongapa.c:400:37: 
> warning: variable 'self' set but not used [-Wunused-but-set-variable]
>    Scheduler_strong_APA_Context     *self;
>                                      ^~~~
> ---------------------------------------------------------------
>
> This warning refers to the following code: 
> https://github.com/richidubey/rtems/blob/3a9843f61bbd547d150d2ee2d791668cfb5aa282/cpukit/score/src/schedulerstrongapa.c#L415
>
> We can see that the self variable is used to get the status of the 
> chain, why would I get such a warning then?

void _Scheduler_strong_APA_Extract_from_ready(
   Scheduler_Context *context,
   Scheduler_Node    *node_to_extract
)
{
   Scheduler_strong_APA_Context     *self;
   Scheduler_strong_APA_Node        *node;

   self = _Scheduler_strong_APA_Get_self( context );
   node = _Scheduler_strong_APA_Node_downcast( node_to_extract );

   _Assert( _Chain_Is_empty(self->allNodes) == false );
   _Assert( _Chain_Is_node_off_chain( &node->Node ) == false );

    _Chain_Extract_unprotected( &node->Node );    //Removed from allNodes
    _Chain_Set_off_chain( &node->Node );
}

It is only used in the _Assert(). I guess you build without the 
configure option --enable-rtems-debug? During development it is useful 
to enable the RTEMS_DEBUG support.

You should not compare boolean values against true or false. Just write

_Assert( !_Chain_Is_empty(self->allNodes) );

for example.



More information about the devel mailing list