Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unused-parameter compiler warnings #94

Closed
alexandertuna opened this issue Nov 19, 2021 · 8 comments
Closed

unused-parameter compiler warnings #94

alexandertuna opened this issue Nov 19, 2021 · 8 comments

Comments

@alexandertuna
Copy link

alexandertuna commented Nov 19, 2021

Hello yall! @pnikiel

I'm doing some cleanup, and I noticed open62541-compat has 159 unused parameter compiler warnings. Would you mind if I submitted a MR for those? Or would you prefer to do it yourselves?

List: www.cern.ch/tuna/log_2021_11_19_15h11m29s.txt

@pnikiel
Copy link
Member

pnikiel commented Nov 19, 2021

Hi,
it depends what do you propose to do?
BTW could you remove duplicates from your list? There seems to be plenty of them.

@alexandertuna
Copy link
Author

Oh yes, good point.

Update: www.cern.ch/tuna/log_2021_11_19_15h11m30s.txt

[tuna@afs] sort ~/www/log_2021_11_19_15h11m29s.txt | wc -l
159
[tuna@afs] sort ~/www/log_2021_11_19_15h11m29s.txt | uniq | wc -l
57

@pnikiel
Copy link
Member

pnikiel commented Nov 19, 2021

So, please tell me what is your idea of dealing with them?

@alexandertuna
Copy link
Author

I'd suggest removing the variable name from the function definition/declaration, and not changing the function signature. That's how the internet has taught me to deal with compiler warnings when I don't actually want to change the contents of the function or change how people call the function. (I assume this is your perspective too: no changes)

Then there are two approaches to removing the variable name: the more verbose way and the less verbose way.

If I take this one as example:

open62541-compat/include/opcua_baseobjecttype.h:58:27: warning: unused parameter 'callback' [-Wunused-parameter]

The original:

	virtual UaStatus beginCall (
			MethodManagerCallback *callback,
			const ServiceContext  &context,
			OpcUa_UInt32          callbackHandle,
			MethodHandle          *methodHandle,
			const UaVariantArray  &inputArguments) { return OpcUa_Bad; }

The more verbose approach (keeps the unused variable name around):

	virtual UaStatus beginCall (
			MethodManagerCallback * /* callback */,
			const ServiceContext  &context,
			OpcUa_UInt32          callbackHandle,
			MethodHandle          *methodHandle,
			const UaVariantArray  &inputArguments) { return OpcUa_Bad; }

The less verbose approach (doesn't keep the unused variable name):

	virtual UaStatus beginCall (
			MethodManagerCallback *,
			const ServiceContext  &context,
			OpcUa_UInt32          callbackHandle,
			MethodHandle          *methodHandle,
			const UaVariantArray  &inputArguments) { return OpcUa_Bad; }

The effect is the same for both

@pnikiel
Copy link
Member

pnikiel commented Nov 19, 2021

Hang tight, we're processing your request. In the meantime Ben proposed to propose yet another way of using some macro.

@pnikiel
Copy link
Member

pnikiel commented Nov 19, 2021

Hi @alexandertuna ,

we discussed this internally and upon @ben-farnham proposal we'd prefer the following plan:
0. Make a ticket in JIRA (OPCUA project, component open62541-compat)

  1. Get yourself a branch that starts with OPCUA-XXX_YYY (XXX to match the ticket number from 0, YYY to be some optional description text)
  2. #define OPEN62541_COMPAT_UNUSED_PARAM(x) (void)(x) in include/open62541_compat.h
  3. use this macro in the fnc/method bodies, where applicable, preferably at the top of a body. ( ;-) )
  4. test it yourself,
  5. propose a MR (assignee: me)

sounds ok?

@alexandertuna
Copy link
Author

Hi @pnikiel and @ben-farnham , thanks for considering this and counter-proposing!

Do you prefer I make a JIRA ticket now, and stop commenting on github?

@alexandertuna
Copy link
Author

Hm I think the answer must be "yes", since that is step 0 of the plan, so I'm doing that now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants