rem: if (res > 0)
add: if (res > 0) { if ((size_t) res > size) res = size;
context: static int wait_chunk(struct read_chunk *chunk, char *buf){    int res;    sem_wait(&chunk->ready);    res = chunk->res;    if (res > 0)        buf_get_mem(&chunk->data, buf, res);    chunk_put(chunk);    return res;}