mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-08 16:41:55 +00:00
Bug fix of queue empty slot calculation
Current implementation of queue_has_space doesn't handle the case where queue tail has wrapped around the end. This CL fixes the bug. BUG=None TEST=Pass the test in the following CL. BRANCH=link Change-Id: I774f388081af50f0e930a6cbc3a723da1c8283b0 Signed-off-by: Vic Yang <victoryang@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/58031 Reviewed-by: Yung-Chieh Lo <yjlou@chromium.org>
This commit is contained in:
@@ -19,8 +19,12 @@ int queue_is_empty(const struct queue *q)
|
||||
|
||||
int queue_has_space(const struct queue *q, int unit_count)
|
||||
{
|
||||
return (q->tail + unit_count * q->unit_bytes) <=
|
||||
(q->head + q->buf_bytes - q->unit_bytes);
|
||||
if (q->tail >= q->head)
|
||||
return (q->tail + unit_count * q->unit_bytes) <=
|
||||
(q->head + q->buf_bytes - q->unit_bytes);
|
||||
else
|
||||
return (q->tail + unit_count * q->unit_bytes) <=
|
||||
(q->head - q->unit_bytes);
|
||||
}
|
||||
|
||||
void queue_add_units(struct queue *q, const void *src, int unit_count)
|
||||
|
||||
Reference in New Issue
Block a user