Skip to content

Commit

Permalink
libsel4camkes/virtqueue: use const qualifier
Browse files Browse the repository at this point in the history
Ensure const correctness is kept. Sending a buffer implies that the
buffer is not modified.

Signed-off-by: Axel Heider <[email protected]>
  • Loading branch information
Axel Heider committed May 24, 2023
1 parent 57fd6ef commit 84a9cf4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions libsel4camkes/include/camkes/virtqueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ void *camkes_virtqueue_driver_offset_to_buffer(virtqueue_driver_t *virtqueue, ui
* @param size the size of the buffer
* @return 0 on success, -1 on fail
*/
int camkes_virtqueue_driver_send_buffer(virtqueue_driver_t *vq, void *buffer, size_t size);
int camkes_virtqueue_driver_send_buffer(virtqueue_driver_t *vq, const void *buffer, size_t size);

/* Scatter and send one buffer (add to the available ring). Performs the pointer to offset conversion.
* Doesn't notify the other side. Scatters the buffer into chunks of BLOCK_SIZE, so the buffer can have
Expand All @@ -157,7 +157,7 @@ int camkes_virtqueue_driver_send_buffer(virtqueue_driver_t *vq, void *buffer, si
* @param size the size of the buffer
* @return 0 on success, -1 on fail
*/
int camkes_virtqueue_driver_scatter_send_buffer(virtqueue_driver_t *vq, void *buffer, size_t size);
int camkes_virtqueue_driver_scatter_send_buffer(virtqueue_driver_t *vq, void const *buffer, size_t size);

/* Takes a handle (obtained from a get_used_buffer invocation), iterates through all the buffers in
* the scatterlist and copies them into the buffer given as parameter. Once each buffer has been copied,
Expand Down
4 changes: 2 additions & 2 deletions libsel4camkes/src/virtqueue.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ void *camkes_virtqueue_driver_offset_to_buffer(virtqueue_driver_t *virtqueue, ui
return allocator->buffer + offset;
}

int camkes_virtqueue_driver_send_buffer(virtqueue_driver_t *vq, void *buffer, size_t size)
int camkes_virtqueue_driver_send_buffer(virtqueue_driver_t *vq, void const *buffer, size_t size)
{
uintptr_t base_offset = (uintptr_t)(((struct vq_buf_alloc *)vq->cookie)->buffer);
uintptr_t buf_offset = (uintptr_t)buffer - base_offset;
Expand All @@ -178,7 +178,7 @@ static int chain_vq_buf(virtqueue_driver_t *vq, virtqueue_ring_object_t *handle,
return 0;
}

int camkes_virtqueue_driver_scatter_send_buffer(virtqueue_driver_t *vq, void *buffer, size_t size)
int camkes_virtqueue_driver_scatter_send_buffer(virtqueue_driver_t *vq, void const *buffer, size_t size)
{
size_t sent = 0;
virtqueue_ring_object_t handle;
Expand Down

0 comments on commit 84a9cf4

Please sign in to comment.