A follow-up to r231949 and r194990.
Details
Diff Detail
- Repository
- rS FreeBSD src repository - subversion
- Lint
Lint Not Applicable - Unit
Tests Not Applicable
Event Timeline
sys/kern/uipc_mbuf.c | ||
---|---|---|
1520 ↗ | (On Diff #30109) | This is fine in principle, but qmin() is the wrong function to use. uio_resid is not of quad_t type. Use normal comparision operations there. |
sys/kern/uipc_mbuf.c | ||
---|---|---|
1520 ↗ | (On Diff #30109) | Hm, the rest of this function assumes that "total" fits in an int. |
sys/kern/uipc_mbuf.c | ||
---|---|---|
1520 ↗ | (On Diff #30109) | It will fit indeed, because len is int. Just that the comparision should use unclipped value of uio_resid. |
sys/kern/uipc_mbuf.c | ||
---|---|---|
1520 ↗ | (On Diff #30109) | quad_t encompasses all values ssize_t can have, on current platforms. It's too bad we don't have type-safe min/max macros like Linux. By normal comparison operations, you mean trinary operator? |
sys/kern/uipc_mbuf.c | ||
---|---|---|
1520 ↗ | (On Diff #30109) | So... uqmin...? sys/sys/libkern.h:static __inline u_quad_t uqmin(u_quad_t a, u_quad_t b) { return (a < b ? a : b); } |
sys/kern/uipc_mbuf.c | ||
---|---|---|
1520 ↗ | (On Diff #30109) | Actually, szmin? static __inline ssize_t szmin(ssize_t a, ssize_t b) { return (a < b ? a : b); } |
sys/kern/uipc_mbuf.c | ||
---|---|---|
1520 ↗ | (On Diff #30109) | It does not matter what quad_t current domain is. I mean, use normal C comparision operators like <, be it used in ?: or if is not important. Normal integer promotion rules make it correct. |
sys/kern/uipc_mbuf.c | ||
---|---|---|
1520 ↗ | (On Diff #30136) | Could you please add a comment so someone doesn't reintroduce the bug after they note that the expression is similar to min(..)? |
sys/kern/uipc_mbuf.c | ||
---|---|---|
1520 ↗ | (On Diff #30136) | Style states that () should be not used, since they are not needed. |
sys/kern/uipc_mbuf.c | ||
---|---|---|
1520 ↗ | (On Diff #30136) | It also makes an allowance for confusion. |