A follow-up to r231949 and r194990.
Details
Diff Detail
- Lint
Lint Passed - Unit
No Test Coverage - Build Status
Buildable 10151 Build 10574: arc lint + arc unit
Event Timeline
| sys/kern/uipc_mbuf.c | ||
|---|---|---|
| 1520 | 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 | Hm, the rest of this function assumes that "total" fits in an int. | |
| sys/kern/uipc_mbuf.c | ||
|---|---|---|
| 1520 | 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 | 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 | 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 | Actually, szmin? static __inline ssize_t szmin(ssize_t a, ssize_t b) { return (a < b ? a : b); } | |
| sys/kern/uipc_mbuf.c | ||
|---|---|---|
| 1520 | 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 | 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 | Style states that () should be not used, since they are not needed. | |
| sys/kern/uipc_mbuf.c | ||
|---|---|---|
| 1520 | It also makes an allowance for confusion. | |