Page MenuHomePhabricator

Add constants to dns.h
ClosedPublic

Authored by nakihito on Mar 9 2020, 22:44.

Details

Reviewers
Fabien
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Restricted Project
Commits
rSTAGING0da65ecee208: Add constants to dns.h
rABC0da65ecee208: Add constants to dns.h
Summary

Moves some constants from seeder/dns_tests.cpp to dns.h.

Test Plan
ninja
ninja check-bitcoin-seeder

Diff Detail

Repository
rABC Bitcoin ABC
Branch
AddConstantsToDNS
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 9779
Build 17433: Default Diff Build & Tests
Build 17432: arc lint + arc unit

Event Timeline

Owners added a reviewer: Restricted Owners Package.Mar 9 2020, 22:44
Fabien requested changes to this revision.Mar 10 2020, 08:02
Fabien added a subscriber: Fabien.
Fabien added inline comments.
src/seeder/dns.cpp
77

Please double check that this won't cause issues later...

85

Please mention the null character so the -3 makes sense

101

... here for example

142

Now a <260 chars>.pwned name will be fine.

src/seeder/dns.h
14

I think what you want here is constexpr

This revision now requires changes to proceed.Mar 10 2020, 08:02
Fabien requested changes to this revision.Mar 12 2020, 07:59
Fabien added inline comments.
src/seeder/dns.cpp
77 ↗(On Diff #16888)

Whatever the type is, if you go from signed to unsigned you need to be sure that it is safe when using the - operator (which is done a few lines below) because this is a behavior change.
What is the rational behind this change (which seems unrelated to what the summary describe as the intent for this diff) ?

130 ↗(On Diff #16888)

Mind changing k to ok while you're at it ?

142 ↗(On Diff #16888)

There is a type for pointer arithmetic: https://en.cppreference.com/w/cpp/types/ptrdiff_t

src/seeder/dns.h
14 ↗(On Diff #16888)

2 questions:

  • Is the static keyword necessary ?
  • Why not make them all constexpr ?
This revision now requires changes to proceed.Mar 12 2020, 07:59

Removed static and changed const to constexpr. Also undid changes to variables in parse_name() and write_name(). Changed MAX_LABEL_LENGTH from size_t to int.

src/seeder/dns.cpp
77 ↗(On Diff #16888)

These changes were made to answer some type comparison mismatch compiler warnings. I have determined the less intrusive change is to change the typing of the constants instead.

142 ↗(On Diff #16888)

I'll leave this for a different diff.

This revision is now accepted and ready to land.Mar 13 2020, 07:30
This revision was automatically updated to reflect the committed changes.