Casting to int cuts off data on some platforms for some sizes, resulting in the incorrect results for swab.
Unit Tests Skipped
1 works fine, it trivially ends up doing nothing. 0 does also, but that doesn't matter, the point is you don't need to touch this line.
So just make n a ssize_t or a size_t (since negative len gets an early return)? Please learn to make your changes minimal, not change the whole thing just because you feel like it.