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

clang-tidy: use std::min/max #14954

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

clang-tidy: use std::min/max #14954

wants to merge 2 commits into from

Conversation

neheb
Copy link
Contributor

@neheb neheb commented Dec 11, 2024

Found with readability-use-std-min-max

I have:

  • [x ] read the CONTRIBUTING.md document
  • [x ] compiled this code
  • tested this code
  • included documentation (including possible behaviour changes)
  • documented the code
  • added or modified regression test(s)
  • added or modified unit test(s)
  • checked that this code was merged to master

@coveralls
Copy link

coveralls commented Dec 11, 2024

Pull Request Test Coverage Report for Build 12403993595

Details

  • 9 of 16 (56.25%) changed or added relevant lines in 5 files are covered.
  • 56 unchanged lines in 13 files lost coverage.
  • Overall coverage decreased (-0.008%) to 64.817%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pdns/lua-record.cc 0 7 0.0%
Files with Coverage Reduction New Missed Lines %
pdns/validate.cc 1 68.42%
pdns/recursordist/lwres.cc 2 69.94%
pdns/recursordist/aggressive_nsec.cc 2 66.17%
pdns/dnsdistdist/dnsdist-backend.cc 2 66.73%
modules/lmdbbackend/lmdbbackend.cc 2 72.5%
pdns/recursordist/pdns_recursor.cc 2 72.85%
pdns/recursordist/syncres.cc 3 80.24%
pdns/remote_logger.cc 3 53.36%
pdns/iputils.cc 3 55.91%
pdns/opensslsigners.cc 3 61.34%
Totals Coverage Status
Change from base Build 12402122415: -0.008%
Covered Lines: 126092
Relevant Lines: 163758

💛 - Coveralls

Copy link
Contributor

@miodvallat miodvallat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, except for the seemingly unrelated change in lua-record.cc.

if (port > std::numeric_limits<uint16_t>::max()) {
port = std::numeric_limits<uint16_t>::max();
}
lua.writeFunction("ifportup", [](int port, const boost::variant<iplist_t, ipunitlist_t>& ips, const boost::optional<std::unordered_map<string, string>>& options) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you change the signature of the lambda here? (passing options by reference)

This is not related to the algorithmic changes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looked like a mistake

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid it actually breaks the feature because the options parameter is no longer optional.

if (port > std::numeric_limits<uint16_t>::max()) {
port = std::numeric_limits<uint16_t>::max();
}
lua.writeFunction("ifportup", [](int port, const boost::variant<iplist_t, ipunitlist_t>& ips, const boost::optional<std::unordered_map<string, string>>& options) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm afraid it actually breaks the feature because the options parameter is no longer optional.

@neheb
Copy link
Contributor Author

neheb commented Dec 12, 2024

sounds broken.

Copy link
Member

@rgacogne rgacogne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes look OK to me, and we can ignore clang-tidy's warning which is incorrect. I wouldn't mind a second review from either @omoerbeek or @Habbie before merging this.

pdns/lua-record.cc Outdated Show resolved Hide resolved
@neheb neheb force-pushed the mm branch 2 times, most recently from 1125d42 to eb172b3 Compare December 13, 2024 20:04
Found with readability-use-std-min-max

Signed-off-by: Rosen Penev <rosenp@gmail.com>
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants