-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
libsel4camkes/virtqueue: use const qualifier #137
base: master
Are you sure you want to change the base?
Conversation
It seems the test failure happens due to a race condition, where the output from different thread overlaps. Instead of
|
@@ -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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this function is also used for enqueuing buffers in the virtqueue to receive data on?
In this case send means that the buffer is being sent to the other end of the queue (the device side). If the queue is used for transmitting data then the data in the buffer would be read by the other end, but if the queue is being used for receiving data then the other side would modify the contents before sending it back.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fair point. Would it make sense to separate the APIs then for the different use cases to support proper semantics?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if the semantics are just enqueuing into available hands a mutable reference over, and receiving from the other queue takes it back. Whether the buffers are written to by the other side is a higher level concern depending on the protocol using the buffers.
1d38a2e
to
1785419
Compare
1785419
to
d86d6f2
Compare
Ensure const correctness is kept. Sending a buffer implies that the buffer is not modified. Signed-off-by: Axel Heider <[email protected]>
Ensure const correctness is kept. Sending a buffer implies that the buffer is not modified.
Without this change, there is always a compiler warning if a buffer with a
const
qualifier is passed to these APIs. Casting away the const qualifier contradicts the intention of usingconst
.