rem: int err; struct buffer buf; struct buffer *handle = &sf->handle; buf_init(&buf, 0); buf_add_buf(&buf, handle); buf_add_uint64(&buf, chunk->offset); buf_add_uint32(&buf, chunk->size); err = sftp_request_async(SSH_FXP_READ, &buf, sshfs_read_begin, sshfs_read_end, chunk); buf_free(&buf); return err;
add: int res = 0; size_t total = 0; struct read_chunk *chunk; struct read_chunk *chunk_prev = NULL; size_t origsize = size;  pthread_mutex_lock(&lock); chunk = search_read_chunk(sf, offset); pthread_mutex_unlock(&lock);  if (chunk && chunk->size < size) { chunk_prev = chunk; size -= chunk->size; offset += chunk->size; chunk = NULL; }  if (!chunk) res = submit_read(sf, size, offset, &chunk);  if (chunk && chunk->size <= size) submit_read(sf, origsize, offset + size, &sf->readahead);  if (chunk_prev) { size_t prev_size = chunk_prev->size; res = wait_chunk(chunk_prev, rbuf, prev_size); if (res < (int) prev_size) { chunk_put_locked(chunk); return res; } rbuf += res; total += res; } res = wait_chunk(chunk, rbuf, size); if (res > 0) total += res; if (res < 0) return res;  return total;
context: static int sshfs_async_read(struct sshfs_file *sf, struct read_chunk *chunk){    int err;    struct buffer buf;    struct buffer *handle = &sf->handle;    buf_init(&buf, 0);    buf_add_buf(&buf, handle);    buf_add_uint64(&buf, chunk->offset);    buf_add_uint32(&buf, chunk->size);    err = sftp_request_async(SSH_FXP_READ, &buf, sshfs_read_begin,                             sshfs_read_end, chunk);    buf_free(&buf);    return err;    }