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

Jan Kiszka <[email protected]>
Newsgroups dev.linux.lists.xenomai
Message-ID <[email protected]>
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.

Jan

-- 
Siemens AG, Foundational Technologies
Linux Expert Center
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.