-
Notifications
You must be signed in to change notification settings - Fork 433
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
CMake: Enable -Werror=unused-parameter flag to treat unused-parameter warnings as errors #2313
base: unstable
Are you sure you want to change the base?
Conversation
@VasuDevrani Should we also fix those errors in the scope of this PR? |
maybe yes (but they are a lot), I think the CI failing because of those. |
Yeah we should fix them otherwise the PR will be blocked by CI failure. You can use the attribute |
Wouldn't it be better to drop the unused parameter and keep the type only virtual Status ToNumber(int64_t*) const { return {Status::NotOK, "not supported"}; }
virtual Status ToBool(bool*) const { return {Status::NotOK, "not supported"}; } |
It's also ok here but keeping a name might be more specific? |
There's some information in the names, so we'd better to keep them. |
Two more concerns, then I'll move forward with
void performOperation(const Config& config, [[maybe_unused]] int param1, [[maybe_unused]] double param2, [[maybe_unused]] const std::string& param3) {
// Use only the 'config' parameter
if (config.isEnabled()) {
// Perform the operation
// ...
}
} VS void performOperation(const Config& config, int, double, const std::string&) {
// Use only the 'config' parameter
if (config.isEnabled()) {
// Perform the operation
// ...
}
}
|
We already uses C++17, yeah? |
yes |
@@ -273,6 +273,8 @@ else() | |||
target_compile_definitions(kvrocks_objs PUBLIC METADATA_ENCODING_VERSION=0) | |||
endif() | |||
|
|||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=unused-parameter") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting CMAKE_CXX_FLAGS
globally is an anti-pattern in CMake.
Maybe the same effect can be achieved with
target_compile_options(kvrocks_objs PUBLIC -Werror=unused-parameter)
for #2266
this will output
unused-parameters
warnings as errors.