[riot-notifications] [RIOT-OS/RIOT] sys/tsrb: bug fix for tsrb_get_one() (#11624)

Sebastian Meiling notifications at github.com
Wed Jun 5 11:40:19 CEST 2019

smlng commented on this pull request.

> @@ -32,7 +32,7 @@ static char _pop(tsrb_t *rb)
 int tsrb_get_one(tsrb_t *rb)
     if (!tsrb_empty(rb)) {
-        return _pop(rb);
+        return (unsigned char)_pop(rb);

yeah, but it should not be that much later.


Another idea for a fix:

Documentation states, that this assumes a single producer and consumer scenario, right? So actually there is no need to return `-1` on error but rather change the function to `char tsrb_get_one()` and the consumer MUST call `tsrb_empty` before access on its own otherwise the consumer might get an old/invalid value. This works because there is only one consumer hence there can be no other consumer manipulating the `reads`.

Still it might be sensible to change every `char` to `unsigned char` anyway.

You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190605/ad5f37fa/attachment-0001.html>

More information about the notifications mailing list