Merge pull request #1717 from cesanta/fixmipq

Fix MIP Q
This commit is contained in:
Sergey Lyubka 2022-09-07 20:59:12 +01:00 committed by GitHub
commit f4def36ccb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 2 deletions

View File

@ -184,7 +184,7 @@ static void q_copyout(struct queue *q, uint8_t *buf, size_t len, size_t tail) {
static bool q_write(struct queue *q, const void *buf, size_t len) {
bool success = false;
size_t left = q->len - q->head + q->tail;
size_t left = (q->len - q->head + q->tail -1) % q->len;
if (len + sizeof(size_t) <= left) {
q_copyin(q, (uint8_t *) &len, sizeof(len), q->head);
q_copyin(q, (uint8_t *) buf, len, (q->head + sizeof(size_t)) % q->len);

View File

@ -6472,7 +6472,7 @@ static void q_copyout(struct queue *q, uint8_t *buf, size_t len, size_t tail) {
static bool q_write(struct queue *q, const void *buf, size_t len) {
bool success = false;
size_t left = q->len - q->head + q->tail;
size_t left = (q->len - q->head + q->tail -1) % q->len;
if (len + sizeof(size_t) <= left) {
q_copyin(q, (uint8_t *) &len, sizeof(len), q->head);
q_copyin(q, (uint8_t *) buf, len, (q->head + sizeof(size_t)) % q->len);