-
Notifications
You must be signed in to change notification settings - Fork 664
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
Activate compiler warnings on unused parameters #697
Comments
I'm not sure we want to do this because |
The warning is perfectly compatible with external signatures that can't be changed (it would be pretty useless otherwise) Actually, I think that is when it is most useful. What you do in those cases is simply not name the parameter. For instance, DaemonRpc would declare: grpc::Status create(grpc::ServerContext*, const CreateRequest* request,
grpc::ServerWriter<CreateReply>* reply) override;
... This immediately indicates, both to the compiler and the reader, that the parameter is not used. And it actually prevents it from being used inadvertently (like passing it around, as happened there). IOW, the warning exists to promote an explicit decision: you either detect the param is a leftover and should be removed, or explicitly indicate it needs to be maintained as part of the signature even though it is not used. In the cases when one feels the param name conveys relevant information even when unused, that information can be put in a comment. It is not the case in the current example, as the name simply repeats what the type already says, but if it were, one should do simply grpc::Status create(grpc::ServerContext* /*context*/, const CreateRequest* request,
grpc::ServerWriter<CreateReply>* reply) override;
... |
Ok, thanks for the explanation and makes perfect sense. |
Fixes #697. Keeps deactivation for gRPC. Causes compilation to fail until current errors are fixed.
757: Warn unused param r=gerboland a=ricab Activates unused parameter warnings. Fixes all such cases, homogenizing implicated code. Fixes #697 Co-authored-by: Ricardo Abreu <[email protected]>
757: Warn unused param r=gerboland a=ricab Activates unused parameter warnings. Fixes all such cases, homogenizing implicated code. Fixes #697 Co-authored-by: Ricardo Abreu <[email protected]>
We currently add
-Wno-unused-parameter
in cmake. This makes it easy to leave unused parameters around, sometimes propagating them to a lot of code.For instance, there is an unused
grpc::ServerContext*
parameter that is propagated from the Rpc to all daemon handling methods and beyond (this particular case is currently being fixed in #682).The text was updated successfully, but these errors were encountered: