How to handle a failed iterator_init()?
Nobody has claimed this yet.
- Dominant language
- C
- Stars
- 732
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
If I call an "init" function and get an error code, I usually expect that the init function has cleaned itself up, and I don't need to call de-init on any state that remains.
In splinter_range I see the opposite, where a failed splinter_range_iterator_init() leads to splinter_range_iterator_deinit() being called.
The code is a bit complex and I haven't dug in, so I can't tell if this is a bug or just unconventional.
In the implementation of kvstore_iterator_init() in #58, I'm assuming the latter, and hiding the complexity from the kvstore user by calling deinit for them on a failed init.
It'd be good to investigate, fix if necessary, and document the correct semantics in code comments.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with splinter.c around splinter_range_iterator_init() at lines 6858-6859, then compare the failed-init handling with kvstore_iterator_init() from #58. Determine whether callers must deinitialize state after a failed init, fix the behavior if needed, and document the correct semantics in code comments.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100