]> git.ipfire.org Git - thirdparty/pdns.git/commit
dnsdist: Prevent implicit conversions between dnsdist::Protocol and uint8_t
authorRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 11 Oct 2021 13:52:18 +0000 (15:52 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Mon, 11 Oct 2021 13:52:18 +0000 (15:52 +0200)
commit426ccc675bb77250bd83dd0ceab308b5ccf8b839
tree641b3c534f94426a7889a53adf900e86ba200df4
parent952ca332cccc4c4dad17aaf0a43238be0719a30d
dnsdist: Prevent implicit conversions between dnsdist::Protocol and uint8_t

This commit makes sure that we always use the dnsdist::Protocol type,
and that we cannot easily convert to or from a different type by mistake.

C++ really dropped the ball by making it impossible to declare methods
on the 'enum class' that solved the issue of making regular enums
implicitly convertible to int and back, thus making it possible to
assign and compare different types of enums together, as well as
enums and ints.
The result is that we are stuck with declaring classes to hold our
methods, along with a lot of plumbing to make sure that we can convert
in some cases but not allow obvious mistakes from happening.
pdns/dnsdist-lua-actions.cc
pdns/dnsdist-protocols.cc
pdns/dnsdist-protocols.hh
pdns/dnsdist-rings.cc
pdns/dnsdist-rings.hh
pdns/dnsdist.cc
pdns/dnsdist.hh
pdns/dnsdistdist/test-dnsdistdynblocks_hh.cc
pdns/dnsdistdist/test-dnsdistrings_cc.cc
pdns/dnsdistdist/test-dnsdisttcp_cc.cc