Need help in writing the Strong APA code

Richi Dubey richidubey at gmail.com
Mon Jul 27 12:34:30 UTC 2020


I should have gone through the definition before asking for help.

Without RTEMS_DEBUG, _Assert() does nothing
#else
  #define _Assert( _e ) ( ( void ) 0 )

Thank you for your help.

On Mon, Jul 27, 2020 at 4:33 PM Sebastian Huber <
sebastian.huber at embedded-brains.de> wrote:

> 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.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20200727/dba53a16/attachment.html>


More information about the devel mailing list