My proposed changes are largely cosmetic, but one thing that isn't is revising the size - pos <= bound tests to instead check size - pos < bound. My reasoning for that change is: if the number of bytes remaining in the buffer is exactly equal to the maximum number we can write, we don't need to flush it yet. If that sounds correct, we should fix the LZ4 code the same way.
I agree with your patch. The patch looks good to me.
Yes, the LZ4 flush check should also be fixed. Please find the attached