Loading system/osi/include/fixed_queue.h +8 −8 Original line number Diff line number Diff line Loading @@ -45,11 +45,12 @@ fixed_queue_t *fixed_queue_new(size_t capacity); // blocked on it) results in undefined behaviour. void fixed_queue_free(fixed_queue_t *queue, fixed_queue_free_cb free_cb); // Returns a value indicating whether the given |queue| is empty. |queue| may // not be NULL. // Returns a value indicating whether the given |queue| is empty. If |queue| // is NULL, the return value is true. bool fixed_queue_is_empty(fixed_queue_t *queue); // Returns the length of the |queue|. |queue| may not be NULL. // Returns the length of the |queue|. If |queue| is NULL, the return value // is 0. size_t fixed_queue_length(fixed_queue_t *queue); // Returns the maximum number of elements this queue may hold. |queue| may Loading @@ -73,19 +74,18 @@ void *fixed_queue_dequeue(fixed_queue_t *queue); bool fixed_queue_try_enqueue(fixed_queue_t *queue, void *data); // Tries to dequeue an element from |queue|. This function will never block // the caller. If the queue is empty, this function returns NULL immediately. // Otherwise, the next element in the queue is returned. |queue| may not be // NULL. // the caller. If the queue is empty or NULL, this function returns NULL // immediately. Otherwise, the next element in the queue is returned. void *fixed_queue_try_dequeue(fixed_queue_t *queue); // Returns the first element from |queue|, if present, without dequeuing it. // This function will never block the caller. Returns NULL if there are no // elements in the queue. |queue| may not be NULL. // elements in the queue or |queue| is NULL. void *fixed_queue_try_peek_first(fixed_queue_t *queue); // Returns the last element from |queue|, if present, without dequeuing it. // This function will never block the caller. Returns NULL if there are no // elements in the queue. |queue| may not be NULL. // elements in the queue or |queue| is NULL. void *fixed_queue_try_peek_last(fixed_queue_t *queue); // Tries to remove a |data| element from the middle of the |queue|. This Loading system/osi/src/fixed_queue.c +13 −7 Original line number Diff line number Diff line Loading @@ -116,7 +116,8 @@ void fixed_queue_free(fixed_queue_t *queue, fixed_queue_free_cb free_cb) { } bool fixed_queue_is_empty(fixed_queue_t *queue) { assert(queue != NULL); if (queue == NULL) return true; pthread_mutex_lock(&queue->lock); bool is_empty = list_is_empty(queue->list); Loading @@ -126,7 +127,8 @@ bool fixed_queue_is_empty(fixed_queue_t *queue) { } size_t fixed_queue_length(fixed_queue_t *queue) { assert(queue != NULL); if (queue == NULL) return 0; pthread_mutex_lock(&queue->lock); size_t length = list_length(queue->list); Loading Loading @@ -185,7 +187,8 @@ bool fixed_queue_try_enqueue(fixed_queue_t *queue, void *data) { } void *fixed_queue_try_dequeue(fixed_queue_t *queue) { assert(queue != NULL); if (queue == NULL) return NULL; if (!semaphore_try_wait(queue->dequeue_sem)) return NULL; Loading @@ -201,7 +204,8 @@ void *fixed_queue_try_dequeue(fixed_queue_t *queue) { } void *fixed_queue_try_peek_first(fixed_queue_t *queue) { assert(queue != NULL); if (queue == NULL) return NULL; pthread_mutex_lock(&queue->lock); void *ret = list_is_empty(queue->list) ? NULL : list_front(queue->list); Loading @@ -211,7 +215,8 @@ void *fixed_queue_try_peek_first(fixed_queue_t *queue) { } void *fixed_queue_try_peek_last(fixed_queue_t *queue) { assert(queue != NULL); if (queue == NULL) return NULL; pthread_mutex_lock(&queue->lock); void *ret = list_is_empty(queue->list) ? NULL : list_back(queue->list); Loading @@ -221,7 +226,8 @@ void *fixed_queue_try_peek_last(fixed_queue_t *queue) { } void *fixed_queue_try_remove_from_queue(fixed_queue_t *queue, void *data) { assert(queue != NULL); if (queue == NULL) return NULL; pthread_mutex_lock(&queue->lock); bool removed = list_remove(queue->list, data); Loading @@ -236,7 +242,7 @@ list_t *fixed_queue_get_list(fixed_queue_t *queue) { assert(queue != NULL); // NOTE: This function is not thread safe, and there is no point for // callint pthread_mutex_lock() / pthread_mutex_unlock() // calling pthread_mutex_lock() / pthread_mutex_unlock() return queue->list; } Loading system/stack/avdt/avdt_scb_act.c +46 −44 Original line number Diff line number Diff line Loading @@ -1287,6 +1287,7 @@ void avdt_scb_hdl_write_req_frag(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data) ssrc = avdt_scb_gen_ssrc(p_scb); if (! fixed_queue_is_empty(p_data->apiwrite.frag_q)) { list_t *list = fixed_queue_get_list(p_data->apiwrite.frag_q); const list_node_t *node = list_begin(list); if (node != list_end(list)) { Loading Loading @@ -1333,6 +1334,7 @@ void avdt_scb_hdl_write_req_frag(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data) /* length of all remaining transport packet */ UINT16_TO_BE_STREAM(p, p_frag->layer_specific); } } /* store it */ p_scb->frag_q = p_data->apiwrite.frag_q; Loading system/stack/btm/btm_sec.c +3 −1 Original line number Diff line number Diff line Loading @@ -6231,8 +6231,10 @@ static BOOLEAN btm_sec_is_serv_level0(UINT16 psm) static void btm_sec_check_pending_enc_req (tBTM_SEC_DEV_REC *p_dev_rec, tBT_TRANSPORT transport, UINT8 encr_enable) { UINT8 res = encr_enable ? BTM_SUCCESS : BTM_ERR_PROCESSING; if (fixed_queue_is_empty(btm_cb.sec_pending_q)) return; UINT8 res = encr_enable ? BTM_SUCCESS : BTM_ERR_PROCESSING; list_t *list = fixed_queue_get_list(btm_cb.sec_pending_q); for (const list_node_t *node = list_begin(list); node != list_end(list); ) { tBTM_SEC_QUEUE_ENTRY *p_e = (tBTM_SEC_QUEUE_ENTRY *)list_node(node); Loading system/stack/gatt/gatt_sr.c +12 −8 Original line number Diff line number Diff line Loading @@ -166,18 +166,22 @@ static BOOLEAN process_read_multi_rsp (tGATT_SR_CMD *p_cmd, tGATT_STATUS status, p_buf->len = 1; /* Now walk through the buffers puting the data into the response in order */ list_t *list = fixed_queue_get_list(p_cmd->multi_rsp_q); const list_node_t *node; list_t *list = NULL; const list_node_t *node = NULL; if (! fixed_queue_is_empty(p_cmd->multi_rsp_q)) list = fixed_queue_get_list(p_cmd->multi_rsp_q); for (ii = 0; ii < p_cmd->multi_req.num_handles; ii++) { tGATTS_RSP *p_rsp = NULL; if (list != NULL) { if (ii == 0) node = list_begin(list); else node = list_next(node); if (node != list_end(list)) p_rsp = (tGATTS_RSP *)list_node(node); } if (p_rsp != NULL) { Loading Loading
system/osi/include/fixed_queue.h +8 −8 Original line number Diff line number Diff line Loading @@ -45,11 +45,12 @@ fixed_queue_t *fixed_queue_new(size_t capacity); // blocked on it) results in undefined behaviour. void fixed_queue_free(fixed_queue_t *queue, fixed_queue_free_cb free_cb); // Returns a value indicating whether the given |queue| is empty. |queue| may // not be NULL. // Returns a value indicating whether the given |queue| is empty. If |queue| // is NULL, the return value is true. bool fixed_queue_is_empty(fixed_queue_t *queue); // Returns the length of the |queue|. |queue| may not be NULL. // Returns the length of the |queue|. If |queue| is NULL, the return value // is 0. size_t fixed_queue_length(fixed_queue_t *queue); // Returns the maximum number of elements this queue may hold. |queue| may Loading @@ -73,19 +74,18 @@ void *fixed_queue_dequeue(fixed_queue_t *queue); bool fixed_queue_try_enqueue(fixed_queue_t *queue, void *data); // Tries to dequeue an element from |queue|. This function will never block // the caller. If the queue is empty, this function returns NULL immediately. // Otherwise, the next element in the queue is returned. |queue| may not be // NULL. // the caller. If the queue is empty or NULL, this function returns NULL // immediately. Otherwise, the next element in the queue is returned. void *fixed_queue_try_dequeue(fixed_queue_t *queue); // Returns the first element from |queue|, if present, without dequeuing it. // This function will never block the caller. Returns NULL if there are no // elements in the queue. |queue| may not be NULL. // elements in the queue or |queue| is NULL. void *fixed_queue_try_peek_first(fixed_queue_t *queue); // Returns the last element from |queue|, if present, without dequeuing it. // This function will never block the caller. Returns NULL if there are no // elements in the queue. |queue| may not be NULL. // elements in the queue or |queue| is NULL. void *fixed_queue_try_peek_last(fixed_queue_t *queue); // Tries to remove a |data| element from the middle of the |queue|. This Loading
system/osi/src/fixed_queue.c +13 −7 Original line number Diff line number Diff line Loading @@ -116,7 +116,8 @@ void fixed_queue_free(fixed_queue_t *queue, fixed_queue_free_cb free_cb) { } bool fixed_queue_is_empty(fixed_queue_t *queue) { assert(queue != NULL); if (queue == NULL) return true; pthread_mutex_lock(&queue->lock); bool is_empty = list_is_empty(queue->list); Loading @@ -126,7 +127,8 @@ bool fixed_queue_is_empty(fixed_queue_t *queue) { } size_t fixed_queue_length(fixed_queue_t *queue) { assert(queue != NULL); if (queue == NULL) return 0; pthread_mutex_lock(&queue->lock); size_t length = list_length(queue->list); Loading Loading @@ -185,7 +187,8 @@ bool fixed_queue_try_enqueue(fixed_queue_t *queue, void *data) { } void *fixed_queue_try_dequeue(fixed_queue_t *queue) { assert(queue != NULL); if (queue == NULL) return NULL; if (!semaphore_try_wait(queue->dequeue_sem)) return NULL; Loading @@ -201,7 +204,8 @@ void *fixed_queue_try_dequeue(fixed_queue_t *queue) { } void *fixed_queue_try_peek_first(fixed_queue_t *queue) { assert(queue != NULL); if (queue == NULL) return NULL; pthread_mutex_lock(&queue->lock); void *ret = list_is_empty(queue->list) ? NULL : list_front(queue->list); Loading @@ -211,7 +215,8 @@ void *fixed_queue_try_peek_first(fixed_queue_t *queue) { } void *fixed_queue_try_peek_last(fixed_queue_t *queue) { assert(queue != NULL); if (queue == NULL) return NULL; pthread_mutex_lock(&queue->lock); void *ret = list_is_empty(queue->list) ? NULL : list_back(queue->list); Loading @@ -221,7 +226,8 @@ void *fixed_queue_try_peek_last(fixed_queue_t *queue) { } void *fixed_queue_try_remove_from_queue(fixed_queue_t *queue, void *data) { assert(queue != NULL); if (queue == NULL) return NULL; pthread_mutex_lock(&queue->lock); bool removed = list_remove(queue->list, data); Loading @@ -236,7 +242,7 @@ list_t *fixed_queue_get_list(fixed_queue_t *queue) { assert(queue != NULL); // NOTE: This function is not thread safe, and there is no point for // callint pthread_mutex_lock() / pthread_mutex_unlock() // calling pthread_mutex_lock() / pthread_mutex_unlock() return queue->list; } Loading
system/stack/avdt/avdt_scb_act.c +46 −44 Original line number Diff line number Diff line Loading @@ -1287,6 +1287,7 @@ void avdt_scb_hdl_write_req_frag(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data) ssrc = avdt_scb_gen_ssrc(p_scb); if (! fixed_queue_is_empty(p_data->apiwrite.frag_q)) { list_t *list = fixed_queue_get_list(p_data->apiwrite.frag_q); const list_node_t *node = list_begin(list); if (node != list_end(list)) { Loading Loading @@ -1333,6 +1334,7 @@ void avdt_scb_hdl_write_req_frag(tAVDT_SCB *p_scb, tAVDT_SCB_EVT *p_data) /* length of all remaining transport packet */ UINT16_TO_BE_STREAM(p, p_frag->layer_specific); } } /* store it */ p_scb->frag_q = p_data->apiwrite.frag_q; Loading
system/stack/btm/btm_sec.c +3 −1 Original line number Diff line number Diff line Loading @@ -6231,8 +6231,10 @@ static BOOLEAN btm_sec_is_serv_level0(UINT16 psm) static void btm_sec_check_pending_enc_req (tBTM_SEC_DEV_REC *p_dev_rec, tBT_TRANSPORT transport, UINT8 encr_enable) { UINT8 res = encr_enable ? BTM_SUCCESS : BTM_ERR_PROCESSING; if (fixed_queue_is_empty(btm_cb.sec_pending_q)) return; UINT8 res = encr_enable ? BTM_SUCCESS : BTM_ERR_PROCESSING; list_t *list = fixed_queue_get_list(btm_cb.sec_pending_q); for (const list_node_t *node = list_begin(list); node != list_end(list); ) { tBTM_SEC_QUEUE_ENTRY *p_e = (tBTM_SEC_QUEUE_ENTRY *)list_node(node); Loading
system/stack/gatt/gatt_sr.c +12 −8 Original line number Diff line number Diff line Loading @@ -166,18 +166,22 @@ static BOOLEAN process_read_multi_rsp (tGATT_SR_CMD *p_cmd, tGATT_STATUS status, p_buf->len = 1; /* Now walk through the buffers puting the data into the response in order */ list_t *list = fixed_queue_get_list(p_cmd->multi_rsp_q); const list_node_t *node; list_t *list = NULL; const list_node_t *node = NULL; if (! fixed_queue_is_empty(p_cmd->multi_rsp_q)) list = fixed_queue_get_list(p_cmd->multi_rsp_q); for (ii = 0; ii < p_cmd->multi_req.num_handles; ii++) { tGATTS_RSP *p_rsp = NULL; if (list != NULL) { if (ii == 0) node = list_begin(list); else node = list_next(node); if (node != list_end(list)) p_rsp = (tGATTS_RSP *)list_node(node); } if (p_rsp != NULL) { Loading