Casting to int cuts off data on some platforms for some sizes, resulting in the incorrect results for swab.
Diff Detail
Diff Detail
- Lint
Lint Skipped - Unit
Tests Skipped
Event Timeline
lib/libc/string/swab.c | ||
---|---|---|
51 | 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. | |
53–55 | 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. |
lib/libc/string/swab.c | ||
---|---|---|
53–55 | I thought less was more but ok. |
lib/libc/string/swab.c | ||
---|---|---|
53–55 | Yes. Change less. |
lib/libc/string/swab.c | ||
---|---|---|
51 | Don't mark this as done if you haven't done it |
lib/libc/string/swab.c | ||
---|---|---|
51 | Changing len < 2 to len <= 1 has no effect and is clearly therefore not what I meant. I meant remove the unnecessary change entirely. |
lib/libc/string/swab.c | ||
---|---|---|
51 | Addressed! |