BIND 10 #2292: eliminate const_cast from domaintree.h
BIND 10 Development
do-not-reply at isc.org
Tue Sep 25 05:55:46 UTC 2012
#2292: eliminate const_cast from domaintree.h
-------------------------------------+-------------------------------------
Reporter: jinmei | Owner:
Type: defect | Status: new
Priority: medium | Milestone: Next-
Component: data source | Sprint-Proposed
Sensitive: 0 | Keywords:
Sub-Project: DNS | Defect Severity: N/A
Estimated Difficulty: 0 | Feature Depending on Ticket:
Total Hours: 0 | Add Hours to Ticket: 0
| Internal?: 0
-------------------------------------+-------------------------------------
I don't know whether this was discussed in code review, but I don't
think we should have allowed this:
{{{#!cpp
typename DomainTree<T>::Result
DomainTree<T>::find(const isc::dns::LabelSequence& target_labels_orig,
DomainTreeNode<T>** target,
DomainTreeNodeChain<T>& node_path,
bool (*callback)(const DomainTreeNode<T>&, CBARG),
CBARG callback_arg) const
{
[...]
if (!node_path.isEmpty()) {
// Get the top node in the node chain
node = const_cast<DomainTreeNode<T>*>(node_path.top());
}}}
If we do const_cast, there should basically be something wrong. In
the previous version of the in-memory data source read-only and modify
cases are not cleanly separated and there could be a reason why we
cannot easily make things in the find() (read-only) path const. The
new version should be clean enough, and we should make sure we don't
need beasts const_cast.
From a quick check it seems we need to introduce some non trivial
adjustments, but I believe it should be possible and won't require
fundamental changes to the public interfaces.
--
Ticket URL: <http://bind10.isc.org/ticket/2292>
BIND 10 Development <http://bind10.isc.org>
BIND 10 Development
More information about the bind10-tickets
mailing list