From 1d38a2ec5da3b393af4f53c85dc2e7153753f686 Mon Sep 17 00:00:00 2001 From: Axel Heider Date: Wed, 24 May 2023 21:20:31 +0200 Subject: [PATCH] libsel4camkes/virtqueue: use const qualifier Ensure const correctness is kept. Sending a buffer implies that the buffer is not modified. Signed-off-by: Axel Heider --- libsel4camkes/include/camkes/virtqueue.h | 4 ++-- libsel4camkes/src/virtqueue.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libsel4camkes/include/camkes/virtqueue.h b/libsel4camkes/include/camkes/virtqueue.h index 65a58bff..d0de32b3 100644 --- a/libsel4camkes/include/camkes/virtqueue.h +++ b/libsel4camkes/include/camkes/virtqueue.h @@ -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 @@ -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, diff --git a/libsel4camkes/src/virtqueue.c b/libsel4camkes/src/virtqueue.c index 57629416..71d7e87c 100644 --- a/libsel4camkes/src/virtqueue.c +++ b/libsel4camkes/src/virtqueue.c @@ -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; @@ -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;