Opened 13 years ago

Closed 12 years ago

#8643 closed bug (fixed)

AVLTreeMap strategy Auto discards const

Reported by: pdziepak Owned by: axeld
Priority: normal Milestone: R1
Component: System/Kernel Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description

Member functions CompareKeyNode and CompareNodes of AVLTreeMapStrategy::Auto attempt to implicitly discard const qualifier.

Attachments (1)

0001-Fix-8643-AVLTreeMap-strategy-Auto-discards-const.patch (1.1 KB ) - added by pdziepak 12 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 by pdziepak, 13 years ago

patch: 01

comment:2 by bonefish, 13 years ago

Wouldn't it be better to fix the strategy members instead. Or have you tried that and there's a problem with it?

comment:3 by pdziepak, 13 years ago

This patch fixes that particular problem in probably the best way. However, it looks like there are still const correctness problems (or at least const_casts worth removing) in AVLTreeMap implementation. At least, now, everything that NFSv4 client needs from it works correctly.

comment:4 by bonefish, 13 years ago

Thanks for the update, Pawel. In the NodeStrategy comment, the const in the return value of GetKey() is superfluous, since it isn't a reference. Please note that the return value isn't a reference by intent, since in some cases the key isn't stored as a sub-object in the node object, but has to be computed (if it can, the node strategy is allowed to return a const reference though, since that is assignment compatible).

I also wonder why the GetKey() version with a non-const Node* parameter would be needed at all. I would say a const version would suffice.

And finally I don't think the new GetValue() version is ever called. AFAICT the only caller is AVLTreeMap::_GetValue(Node* node), which has a non-const node anyway.

comment:5 by pdziepak, 12 years ago

Thank you for feedback. Now, this patch is much simpler.

comment:6 by bonefish, 12 years ago

Thanks! Applied in hrev44273.

comment:7 by bonefish, 12 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.