Opened 7 years ago

Closed 7 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:
Has a Patch: yes 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 7 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 Changed 7 years ago by pdziepak

Has a Patch: set

comment:2 Changed 7 years ago by bonefish

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 Changed 7 years ago by pdziepak

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 Changed 7 years ago by bonefish

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 Changed 7 years ago by pdziepak

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

comment:6 Changed 7 years ago by bonefish

Thanks! Applied in hrev44273.

comment:7 Changed 7 years ago by bonefish

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