Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Titan » avoiding warnings about unused function arguments
avoiding warnings about unused function arguments [message #1781038] Wed, 31 January 2018 17:10 Go to next message
Harald Welte is currently offline Harald WelteFriend
Messages: 35
Registered: July 2017
Location: Berlin, Germany

TITAN warns about unused function return values during compilation. This is generally useful, of course, but in many cases one has a function where sometimes one is interested in the results, and in other cases one doesn't care.

Is there some kind of attribute or other syntactic sugar that I can use to tell the compiler explicitly in those instances that I know the function returns a value, but I really don't care in this particular invocation?

In absence of such a feature, it would be difficult to aim for a "no warnings raised" soure code, which is generally good practise.

p.s.: I feel like monopolizing the forum here during recent days, my apologies. Feel free to let me know if I post too many questions, or if you think I should do more research before posting
Re: avoiding warnings about unused function arguments [message #1781065 is a reply to message #1781038] Thu, 01 February 2018 07:14 Go to previous messageGo to next message
Kristof Szabados is currently offline Kristof SzabadosFriend
Messages: 28
Registered: July 2015
Junior Member
Hi Harald,

There is no such option (right now).
And it would also very problematic: The intention with these measurements is to provide information/awareness about code style/structure/quality/etc... but if once someone starts to hide/manipulate certain measurements he usually gets into a worse situation as he was in previously.
When you have a measurement you can prioritize it ... and you can mentally filter it or ignore it if you do no have the time, information to deal with it. It is also a good argument for example to say that you intentionally embrace complexity somewhere to reach certain performance threasholds there.
But when you hide away such information. You yourself have to keep in mind that your tool is no longer able to provide you with the whole picture. Such filters could hide actuall issues that appear later, force you to periodically review all code without the filters or simply misslead you into creating bad design later on.

I know this sounds kind of an "ezoteric" point of view, but contemporary research shows that while one should strive for "no warnings" actually it is not a good idea to reach it. Most probably it will either be via disabling some check - aka. cheating-, going against some naturally emergent phenomena -like the power law distribution of metrics- or simply way too costly - thinking in technical debt meaning of going into debt and repaying debt-.

Regarding the phenomenon in question, it migh also be interesting to investigate.
If the return value is something like a "did the call fail" sign ... than it would be good idea to use it (if for nothing other, mentioning it in the log, as it might help debug anunexpected behaviour later on).
On the other hand if the return value is something that is really not important in many of the cases ... that might be a good sign for some interface issues or a chance for optimization.
Maybe it would be better to have 2 function instead of the currently only 1. In case the case where the return value is not needed is actually a valid usecase that could be better served by adding a function with no return value to the system in question (to make this logic/usecase actually more visible).
On the other hand this function might also perform better. Since a value not returned is a value that might not to be calculated at all.

[Updated on: Thu, 01 February 2018 07:15]

Report message to a moderator

Re: avoiding warnings about unused function arguments [message #1781067 is a reply to message #1781065] Thu, 01 February 2018 07:33 Go to previous message
Elemer Lelik is currently offline Elemer LelikFriend
Messages: 709
Registered: January 2015
Senior Member
Hi Harald,

all warnings can be switched off globally by using the compiler flag -w:
# Flags for the TTCN-3 and ASN.1 compiler:

The recommended strategy is that in the early phases the warnings are switched off , so one can focus on errors;
after that they can be switched on again and examined, possibly dealt with.
When the code is in a state that can be considered final , they can be muted once more.

You should have no worries about about writing to the forum as many times as you consider necessary; forum activity shows interest and that we like.

Best regards
Previous Topic:Incomplete Behavior Types Support?
Next Topic:concatenating templates of list types
Goto Forum:

Current Time: Fri Mar 23 14:29:17 GMT 2018

Powered by FUDForum. Page generated in 0.02344 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software