From 6d1d5db1a9bb581b166b7181e35f35cc2ec0d256 Mon Sep 17 00:00:00 2001 From: zhang Date: Sat, 18 Sep 2021 15:35:34 +0800 Subject: [PATCH] modify reviewbot of utils Signed-off-by: zhang --- utils/include/hdf_block_buffer.h | 3 +-- utils/include/hdf_blocking_queue.h | 6 ++---- utils/include/hdf_ordered_list.h | 4 ++-- utils/src/hdf_block_buffer.c | 16 ++++++---------- utils/src/hdf_blocking_queue.c | 4 ++-- utils/src/hdf_object_alloc.c | 14 +++----------- utils/src/hdf_ordered_list.c | 3 +-- 7 files changed, 17 insertions(+), 33 deletions(-) diff --git a/utils/include/hdf_block_buffer.h b/utils/include/hdf_block_buffer.h index 205897e2..6e6b2f57 100644 --- a/utils/include/hdf_block_buffer.h +++ b/utils/include/hdf_block_buffer.h @@ -96,8 +96,7 @@ bool HdfBlockBufferWriteShort(struct BlockBuffer *buffer, uint16_t shortValue); * * @return the new instance of buff which contain specific packet. */ -struct HdfBlockBuffer *HdfBlockBufferDuplicate( - struct HdfBlockBuffer *buffer, uint16_t start, uint16_t end); +struct HdfBlockBuffer *HdfBlockBufferDuplicate(struct HdfBlockBuffer *buffer, uint16_t start, uint16_t end); /* * @brief append an byte array packet into buffer. diff --git a/utils/include/hdf_blocking_queue.h b/utils/include/hdf_blocking_queue.h index 5cfda6ec..7b51f3a8 100644 --- a/utils/include/hdf_blocking_queue.h +++ b/utils/include/hdf_blocking_queue.h @@ -17,15 +17,13 @@ extern "C" { #endif -struct HdfBlockingQueue -{ +struct HdfBlockingQueue { struct HdfSList list; struct OsalSem sem; struct OsalMutex mutex; }; -struct HdfSListEntry -{ +struct HdfSListEntry { struct HdfSListNode node; void *data; }; diff --git a/utils/include/hdf_ordered_list.h b/utils/include/hdf_ordered_list.h index ffb4ad02..6f9aa2ba 100644 --- a/utils/include/hdf_ordered_list.h +++ b/utils/include/hdf_ordered_list.h @@ -28,9 +28,9 @@ struct HdfOrderedListEntity { long key; }; -typedef void(*HdfOrderedListEntityDeleter)(struct HdfOrderedListEntity *); +typedef void (*HdfOrderedListEntityDeleter)(struct HdfOrderedListEntity *); -typedef bool (*HdfOrderedListComparer)(long , void *); +typedef bool (*HdfOrderedListComparer)(long, void *); void HdfOrderedListInit(struct HdfOrderedList *list); diff --git a/utils/src/hdf_block_buffer.c b/utils/src/hdf_block_buffer.c index 7816114e..c5361fe8 100644 --- a/utils/src/hdf_block_buffer.c +++ b/utils/src/hdf_block_buffer.c @@ -6,11 +6,8 @@ * See the LICENSE file in the root of this repository for complete details. */ -#include -#include #include "hdf_block_buffer.h" #include "osal_mem.h" -#include "utils.h" struct HdfHdfBlockBuffer *HdfHdfBlockBufferNew(const uint8_t *data, uint16_t size) { @@ -25,10 +22,10 @@ struct HdfHdfBlockBuffer *HdfHdfBlockBufferNew(const uint8_t *data, uint16_t siz return NULL; } buffer->dataSize = size; - buffer->position = 0; - if (data != NULL) { - memcpy(buffer->data, data, size); - } + buffer->position = 0; + if (data != NULL) { + memcpy(buffer->data, data, size); + } return buffer; } @@ -46,7 +43,7 @@ uint16_t HdfBlockBufferGetDataSize(struct HdfBlockBuffer *buffer) uint16_t HdfBlockBufferGetAvailableSize(struct HdfBlockBuffer *buffer) { - return (buffer == NULL) ? 0 : buffer->dataSize - buffer->position; + return (buffer == NULL) ? 0 : (buffer->dataSize - buffer->position); } uint8_t *HdfBlockBufferRead(struct HdfBlockBuffer *buffer, uint16_t size) @@ -181,8 +178,7 @@ bool HdfBlockBufferWriteData(struct HdfBlockBuffer *buffer, uint8_t *data, size_ return true; } -struct HdfBlockBuffer *HdfBlockBufferDuplicate( - struct HdfBlockBuffer *buffer, uint16_t start, uint16_t end) +struct HdfBlockBuffer *HdfBlockBufferDuplicate(struct HdfBlockBuffer *buffer, uint16_t start, uint16_t end) { uint16_t bufferSize = HdfBlockBufferGetDataSize(buffer); uint16_t newBufferSize; diff --git a/utils/src/hdf_blocking_queue.c b/utils/src/hdf_blocking_queue.c index 613849e9..ed419b58 100644 --- a/utils/src/hdf_blocking_queue.c +++ b/utils/src/hdf_blocking_queue.c @@ -110,7 +110,7 @@ void *HdfBlockingQueuePoll(struct HdfBlockingQueue *queue, long timeout) int HdfBlockingQueueOffer(struct HdfBlockingQueue *queue, void *val, long timeout) { - struct HdfSListEntry *entry = NULL; + struct HdfSListEntry *entry = NULL; if (OsalSemWait(&queue->sem, timeout) != 0) { return -1; } @@ -120,6 +120,6 @@ int HdfBlockingQueueOffer(struct HdfBlockingQueue *queue, void *val, long timeou HdfSListAddTail(&queue->list, &entry->node); OsalMutexUnlock(&queue->mutex); } - OsalSemPost(&queue->sem); + OsalSemPost(&queue->sem); } diff --git a/utils/src/hdf_object_alloc.c b/utils/src/hdf_object_alloc.c index ba4774c7..c923d493 100644 --- a/utils/src/hdf_object_alloc.c +++ b/utils/src/hdf_object_alloc.c @@ -6,14 +6,10 @@ * See the LICENSE file in the root of this repository for complete details. */ -#include -#include - +#include "hdf_base.h" +#include "hdf_object_alloc.h" #include "hdf_slist.h" -#include "object_alloc.h" -#include "osal_mem.h" #include "osal_mutex.h" -#include "utils.h" struct HdfChunkLink { uint32_t buffSize; @@ -66,7 +62,6 @@ struct HdfObjectNode *HdfObjectAllocFindSuitableChunk( while (HdfSListIteratorHasNext(&it)) { objectNode = (struct HdfObjectNode *)HdfSListIteratorNext(&it); - if (size == objectNode->chunkSize) { bestFitNode = objectNode; break; @@ -87,7 +82,6 @@ static void HdfObjectAllocPushObjectNode( while (HdfSListIteratorHasNext(&it)) { objectNode = (struct HdfObjectNode *)HdfSListIteratorNext(&it); - if (node->chunkSize >= objectNode->chunkSize) { break; } @@ -128,7 +122,7 @@ static void HdfObjectAllocPreloadChunk( void HdfObjectAllocLoadConfigs(const struct HdfObjectPoolConfig *configs) { - uint32_t idx = 0; + uint32_t idx; char *chunkBuffBegin = configs->buffer; char *chunkBuffEnd = configs->buffer + configs->bufferSize; @@ -161,7 +155,6 @@ void *HdfObjectAllocAlloc(size_t size) struct HdfObjectAlloc *allocator = HdfObjectAllocGetInstance(); OsalMutexLock(&allocator->mutex); objectNode = HdfObjectAllocFindSuitableChunk(allocator, size); - if ((objectNode != NULL) && (objectNode->freeCount == 0)) { goto finished; } @@ -184,7 +177,6 @@ void HdfObjectAllocFree(void *object) struct HdfObjectAlloc *allocator = HdfObjectAllocGetInstance(); OsalMutexLock(&allocator->mutex); objectNode = HdfObjectAllocFindSuitableChunk(allocator, chunkLink->buffSize); - if (objectNode != NULL) { objectNode->chunkStack[objectNode->freeCount++] = chunkLink; diff --git a/utils/src/hdf_ordered_list.c b/utils/src/hdf_ordered_list.c index a3cc2e2b..3f45ac33 100644 --- a/utils/src/hdf_ordered_list.c +++ b/utils/src/hdf_ordered_list.c @@ -6,7 +6,6 @@ * See the LICENSE file in the root of this repository for complete details. */ -#include "osal_mem.h" #include "hdf_ordered_list.h" void HdfOrderedListInit(struct HdfOrderedList *list) @@ -86,7 +85,7 @@ long HdfOrderedListPeekKey(struct HdfOrderedList *list) } struct HdfOrderedListEntity *HdfOrderedListFetch( - struct HdfOrderedList *list, long matchKey, HdfOrderedListComparer comparer) + struct HdfOrderedList *list, long matchKey, HdfOrderedListComparer comparer) { struct HdfSListIterator it; struct HdfOrderedListEntity *matchEntity = NULL;