The patch seems correct to me.
Cool. Thanks for the review.
And thanks for the clear explanation, that's appreciated.
I always want more eyes on the code, so I try to reveal the mysteries.
If I'm hit by a bus tomorrow, you'll have to understand and fix this
code. (Not to mention, by tomorrow I will have forgotten what I thought
and did yesterday, so the explanation helps me recover my own thinking
that went with how the code ended up.) So please do try to understand
even the hairy bits, and always ask for explanations when the code is
not clear. In this particular stuff, it's now obvious that any place
the code seems questionable, I probably actually wrote a bug!
Thanks,
Roland