* Set the sbuf's end position to an arbitrary value. * Effectively truncates the sbuf at the new position. */
| 329 | * Effectively truncates the sbuf at the new position. |
| 330 | */ |
| 331 | int |
| 332 | sbuf_setpos(struct sbuf *s, ssize_t pos) |
| 333 | { |
| 334 | |
| 335 | assert_sbuf_integrity(s); |
| 336 | assert_sbuf_state(s, 0); |
| 337 | |
| 338 | KASSERT(pos >= 0, |
| 339 | ("attempt to seek to a negative position (%jd)", (intmax_t)pos)); |
| 340 | KASSERT(pos < s->s_size, |
| 341 | ("attempt to seek past end of sbuf (%jd >= %jd)", |
| 342 | (intmax_t)pos, (intmax_t)s->s_size)); |
| 343 | KASSERT(!SBUF_ISSECTION(s), |
| 344 | ("attempt to seek when in a section")); |
| 345 | |
| 346 | if (pos < 0 || pos > s->s_len) |
| 347 | return (-1); |
| 348 | s->s_len = pos; |
| 349 | return (0); |
| 350 | } |
| 351 | |
| 352 | /* |
| 353 | * Drain into a counter. Counts amount of data without producing output. |
no outgoing calls
no test coverage detected