kvrocks
kvrocks copied to clipboard
CMake: Enable -Werror=unused-parameter flag to treat unused-parameter warnings as errors
for #2266
this will output unused-parameters warnings as errors.
@VasuDevrani Should we also fix those errors in the scope of this PR?
@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 [[maybe_unused]].
You can use the attribute
[[maybe_unused]].
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"}; }
Wouldn't it be better to drop the unused parameter and keep the type only
It's also ok here but keeping a name might be more specific?
You can use the attribute
[[maybe_unused]].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"}; }
There's some information in the names, so we'd better to keep them.
Two more concerns, then I'll move forward with [[maybe_unused]]:
- it can make code a bit unreadable (especially if there's multiple unused params together)
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
// ...
}
}
- supported for cpp 17+ (then again project cmake sets it at 17)
We already uses C++17, yeah?
We already uses C++17, isn't we?
yes