Re: [PATCH 3/5] testsuite/smokey/vxworktests: Fix compile error seen with gcc 16

Florian Bezdeka <[email protected]>
Newsgroups dev.linux.lists.xenomai
Message-ID <[email protected]>
On Wed, 2026-05-13 at 16:02 +0200, Jan Kiszka wrote:
> On 13.05.26 15:55, Florian Bezdeka wrote:
> > On Wed, 2026-05-13 at 15:52 +0200, Jan Kiszka wrote:
> > > On 13.05.26 14:50, Florian Bezdeka wrote:
> > > > Fixes the following error:
> > > > 
> > > > task-2.c: In function ‘backgroundTask’:
> > > > task-2.c:26:42: error: variable ‘count’ set but not used [-Werror=unused-but-set-variable=]
> > > >    26 |         unsigned int safety = 100000000, count = 0;
> > > >       |                                          ^~~~~
> > > > cc1: all warnings being treated as errors
> > > > 
> > > > Signed-off-by: Florian Bezdeka <[email protected]>
> > > > ---
> > > >  testsuite/smokey/vxworkstests/task-2.c | 5 ++---
> > > >  1 file changed, 2 insertions(+), 3 deletions(-)
> > > > 
> > > > diff --git a/testsuite/smokey/vxworkstests/task-2.c b/testsuite/smokey/vxworkstests/task-2.c
> > > > index 0cbb9e18a13383418c4360241ef244b8a24da975..ed3e31806baad930bb30edc53d2dc6b6e51d6277 100644
> > > > --- a/testsuite/smokey/vxworkstests/task-2.c
> > > > +++ b/testsuite/smokey/vxworkstests/task-2.c
> > > > @@ -23,7 +23,7 @@ static SEM_ID sem_id, fdone_sem_id;
> > > >  
> > > >  static void backgroundTask(long arg, ...)
> > > >  {
> > > > -	unsigned int safety = 100000000, count = 0;
> > > > +	unsigned int safety = 100000000;
> > > >  	int ret;
> > > >  
> > > >  	traceobj_enter(&trobj);
> > > > @@ -35,8 +35,7 @@ static void backgroundTask(long arg, ...)
> > > >  
> > > >  	traceobj_mark(&trobj, 2);
> > > >  
> > > > -	while (--safety > 0)
> > > > -		count++;
> > > > +	while (--safety > 0) {}
> > > 
> > > This first of all increases the risk of getting optimized out. I suspect
> > > this is intended to generate some load, and that needs to be preserved.
> > > We should likely do that via a busy loop which spins for a number of
> > > microseconds.
> > > 
> > 
> > I compared the generated code, where only the increment was missing. Let
> > me double check that the optimization level was > 0.
> 
> Neither the new nor the current versions are safe here, specifically
> regarding timing.
> 

Seems both "affected" tests are a bit different. The following applies
to the psos test, vxworkstests needs additional checking.

The background task has to be kept alive, so that the foreground task
can cancel it. In case of a test failure, the task has to complete, so
that we can safely report the testfailure.

First idea was to simply wait on the semaphore again, but that would
suspend the task forever, breaking the test failure detection.

v2 (as currently running in CI) will simply silence the compiler
warning. (void)count; 

Better ideas welcome, but for now fixing the tests looks out of scope
for adding the compiler support. The timing issue - if any - has been
there for more then a decade...
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.