mirror of
https://github.com/openharmony/drivers_framework.git
synced 2026-08-27 20:49:55 -04:00
modify reviewbot of utils
Signed-off-by: zhang <zhangfengxi@huawei.com>
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -6,11 +6,8 @@
|
||||
* See the LICENSE file in the root of this repository for complete details.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,14 +6,10 @@
|
||||
* See the LICENSE file in the root of this repository for complete details.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user