From ee83d02aa1beef3ebea3de6fe46ee885fcca6758 Mon Sep 17 00:00:00 2001 From: YOUR_NAME Date: Sat, 18 Sep 2021 17:30:41 +0800 Subject: [PATCH] Repair alarms Signed-off-by: YOUR_NAME --- utils/include/hdf_block_buffer.h | 3 +-- utils/include/hdf_blocking_queue.h | 6 ++---- utils/include/hdf_ordered_list.h | 2 +- utils/src/hdf_block_buffer.c | 24 +++++++++++------------- utils/src/hdf_blocking_queue.c | 4 ++-- utils/src/hdf_object_alloc.c | 14 ++------------ utils/src/hdf_ordered_list.c | 5 ++--- 7 files changed, 21 insertions(+), 37 deletions(-) diff --git a/utils/include/hdf_block_buffer.h b/utils/include/hdf_block_buffer.h index 205897e25..6e6b2f573 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 5cfda6ecd..7b51f3a8d 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 ffb4ad02d..4fa7ed08a 100644 --- a/utils/include/hdf_ordered_list.h +++ b/utils/include/hdf_ordered_list.h @@ -30,7 +30,7 @@ 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 7816114ed..3c9f1c240 100644 --- a/utils/src/hdf_block_buffer.c +++ b/utils/src/hdf_block_buffer.c @@ -6,11 +6,10 @@ * 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" +#include + +#define NUM 8 struct HdfHdfBlockBuffer *HdfHdfBlockBufferNew(const uint8_t *data, uint16_t size) { @@ -25,10 +24,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; } @@ -39,14 +38,14 @@ void HdfBlockBufferFree(struct HdfBlockBuffer *buffer) } } -uint16_t HdfBlockBufferGetDataSize(struct HdfBlockBuffer *buffer) +uint16_t HdfBlockBufferGetDataSize(const struct HdfBlockBuffer *buffer) { return (buffer == NULL) ? 0 : buffer->dataSize; } 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) @@ -159,7 +158,7 @@ bool HdfBlockBufferWriteUint16(struct HdfBlockBuffer *buffer, uint16_t in_value) return false; } if (buffer->position + BYTES_UINT16 <= buffer->dataSize) { - buffer->data[buffer->position++] = (uint8_t) (in_value >> 8); + buffer->data[buffer->position++] = (uint8_t) (in_value >> NUM); buffer->data[buffer->position++] = (uint8_t) (in_value & 0xFF); return true; } @@ -181,8 +180,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(const 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 613849e9e..ed419b58c 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 ba4774c75..560a3bb36 100644 --- a/utils/src/hdf_object_alloc.c +++ b/utils/src/hdf_object_alloc.c @@ -6,14 +6,9 @@ * See the LICENSE file in the root of this repository for complete details. */ -#include -#include - #include "hdf_slist.h" #include "object_alloc.h" -#include "osal_mem.h" #include "osal_mutex.h" -#include "utils.h" struct HdfChunkLink { uint32_t buffSize; @@ -34,8 +29,7 @@ struct HdfObjectAlloc { bool isConstructed; }; static const unsigned int ALIGN_MASK = 3; -#define ALIGN4(x) (uint32_t)(((uintptr_t)(x) + ALIGN_MASK) & (~ALIGN_MASK)) - +#define ALIGN4(x) (uint32_t)((((uintptr_t)(x)) + ALIGN_MASK) & (~ALIGN_MASK)) #define OBJECT_NODE_SIZE sizeof(struct ObjectNode) #define OBJECT_CHUNK_COOKIE_SIZE (sizeof(struct ChunkLink) + sizeof(void *)) @@ -66,7 +60,6 @@ struct HdfObjectNode *HdfObjectAllocFindSuitableChunk( while (HdfSListIteratorHasNext(&it)) { objectNode = (struct HdfObjectNode *)HdfSListIteratorNext(&it); - if (size == objectNode->chunkSize) { bestFitNode = objectNode; break; @@ -87,7 +80,6 @@ static void HdfObjectAllocPushObjectNode( while (HdfSListIteratorHasNext(&it)) { objectNode = (struct HdfObjectNode *)HdfSListIteratorNext(&it); - if (node->chunkSize >= objectNode->chunkSize) { break; } @@ -128,7 +120,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 +153,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 +175,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 a3cc2e2b9..8cf6dbeee 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) @@ -85,8 +84,8 @@ long HdfOrderedListPeekKey(struct HdfOrderedList *list) return orderedKey; } -struct HdfOrderedListEntity *HdfOrderedListFetch( - struct HdfOrderedList *list, long matchKey, HdfOrderedListComparer comparer) +struct HdfOrderedListEntity *HdfOrderedListFetch(const struct HdfOrderedList *list, long matchKey, + HdfOrderedListComparer comparer) { struct HdfSListIterator it; struct HdfOrderedListEntity *matchEntity = NULL; -- Gitee