Clemens Ladisch wrote:
I'll see if I can cobble together some TLV checking code ...
Great.
Because it's useless to wait until the end of the loop to return -EINVAL,
It is not necessary to optimize for error cases.
It's not an optimization, but a simplification. Otherwise, pos would have to be tested again after the loop to differentiate the loop-skipped case from the at-least-one-loop-iteration cases to return either -EINVAL or the prev submax.
and with my patch, the after-loop code becomes the fallback case for beyond- final-range values, so it avoids adding a weird extra check there.
But why does this force you to use do instead of while?
It doesn't. It's just that it's useless to keep a while here as the 1st iteration will necessarily occur thanks to the previous if.
Regards, Benoît