
Hi Anton,
Previously reading or writing zero full sectors (reading the end of one sector and the beginning of the next for example) was special cased and involved stack allocating a second sector buffer. This change uses the same code path for this case as well as when there are a non-zero number of full sectors to access. The result is easier to read and reduces the maximum stack used.
It's non-trivial to prove that your change is equivalent and unfortunately I do not have enough time to do this. If your tests work, than this is certainly a good indication ;) The one thing I'd like to be sure is that the previous code looks like it used the stack for whole sectors but copied only parts of this to the provided address pointer. Your new code looks like it always writes whole sectors to the provided pointer. Is this safe even if the caller allocated space without overhead for whole sectors?
Cheers Detlev