From 376563191aa3ee1d6c76a899e80b9272a361e5d1 Mon Sep 17 00:00:00 2001 From: guodongqi Date: Tue, 1 Mar 2022 17:04:12 +0800 Subject: [PATCH] fix: clear code warnings of LTS3.0 Signed-off-by: guodongqi --- ability/config/hcs_parser/src/hcs_blob_if.c | 4 ++-- ability/config/hcs_parser/src/hcs_generate_tree.c | 2 +- model/display/driver/backlight/hdf_bl.c | 2 +- model/input/driver/hdf_input_device_manager.c | 2 +- model/input/driver/input_config_parser.c | 2 +- support/posix/src/osal_time.c | 4 ++-- tools/hc-gen/src/ast.h | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/ability/config/hcs_parser/src/hcs_blob_if.c b/ability/config/hcs_parser/src/hcs_blob_if.c index dfb023d8..e6386e72 100644 --- a/ability/config/hcs_parser/src/hcs_blob_if.c +++ b/ability/config/hcs_parser/src/hcs_blob_if.c @@ -176,11 +176,11 @@ static bool CheckHcsBlobLength(uint32_t length, struct HbcHeader *header) uint32_t minLength = rootNodeLen + HBC_HEADER_LENGTH; uint32_t blobLength; if (header->totalSize >= 0) { - blobLength = HBC_HEADER_LENGTH + header->totalSize; + blobLength = (uint32_t)(HBC_HEADER_LENGTH + header->totalSize); g_byteAlign = false; HDF_LOGI("%s: the blobLength: %u, byteAlign: %d", __func__, blobLength, g_byteAlign); } else { - blobLength = HBC_HEADER_LENGTH - header->totalSize; + blobLength = (uint32_t)(HBC_HEADER_LENGTH - header->totalSize); g_byteAlign = true; HDF_LOGI("%s: the blobLength: %u, byteAlign: %d", __func__, blobLength, g_byteAlign); } diff --git a/ability/config/hcs_parser/src/hcs_generate_tree.c b/ability/config/hcs_parser/src/hcs_generate_tree.c index c3306ed6..9fbc739e 100644 --- a/ability/config/hcs_parser/src/hcs_generate_tree.c +++ b/ability/config/hcs_parser/src/hcs_generate_tree.c @@ -33,7 +33,7 @@ static struct DeviceResourceNode *CreateTreeNode(const char *start, int32_t offs struct DeviceResourceNode *newNode = (struct DeviceResourceNode *)(*treeMem); *treeMem += sizeof(struct DeviceResourceNode); newNode->name = start + offset + HCS_PREFIX_LENGTH; - newNode->hashValue = offset + sizeof(struct HbcHeader); + newNode->hashValue = (uint32_t)(offset + sizeof(struct HbcHeader)); if (parentNode != NULL) { newNode->parent = parentNode; struct DeviceResourceNode *curNode = parentNode->child; diff --git a/model/display/driver/backlight/hdf_bl.c b/model/display/driver/backlight/hdf_bl.c index 1f074396..38bc50c8 100644 --- a/model/display/driver/backlight/hdf_bl.c +++ b/model/display/driver/backlight/hdf_bl.c @@ -282,7 +282,7 @@ static int32_t HdfGetBrightness(enum BrightnessType type, return HDF_FAILURE; } blDevManager = GetBlDevManager(); - if (devId >= blDevManager->devNum) { + if (devId >= (uint32_t)blDevManager->devNum) { HDF_LOGE("%s: devId is illegal", __func__); return HDF_FAILURE; } diff --git a/model/input/driver/hdf_input_device_manager.c b/model/input/driver/hdf_input_device_manager.c index 9be0cce5..a0edb602 100644 --- a/model/input/driver/hdf_input_device_manager.c +++ b/model/input/driver/hdf_input_device_manager.c @@ -245,7 +245,7 @@ static int32_t AllocPackageBuffer(InputDevice *inputDev) return HDF_SUCCESS; } -static uint32_t AllocDeviceID(InputDevice *inputDev) +static int32_t AllocDeviceID(InputDevice *inputDev) { InputDevice *tmpDev = g_inputManager->inputDevList; uint32_t idList[MAX_INPUT_DEV_NUM + 1]; diff --git a/model/input/driver/input_config_parser.c b/model/input/driver/input_config_parser.c index f6c49eba..5ff63abe 100644 --- a/model/input/driver/input_config_parser.c +++ b/model/input/driver/input_config_parser.c @@ -196,7 +196,7 @@ static int32_t ParsePowerSequence(struct DeviceResourceIface *parser, const stru ChipPwrSeq *pwrSeq) { int32_t ret; - uint32_t num = parser->GetElemNum(seqNode, "powerOnSeq"); + uint32_t num = (uint32_t)parser->GetElemNum(seqNode, "powerOnSeq"); pwrSeq->pwrOn.count = num; pwrSeq->pwrOn.buf = (uint32_t *)OsalMemAlloc(sizeof(uint32_t) * num); if (pwrSeq->pwrOn.buf == NULL) { diff --git a/support/posix/src/osal_time.c b/support/posix/src/osal_time.c index 841dcd9e..f71ed733 100644 --- a/support/posix/src/osal_time.c +++ b/support/posix/src/osal_time.c @@ -27,8 +27,8 @@ int32_t OsalGetTime(OsalTimespec *time) (void)memset_s(&ts, sizeof(ts), 0, sizeof(ts)); clock_gettime(CLOCK_MONOTONIC, &ts); - time->sec = ts.tv_sec; - time->usec = ts.tv_nsec / HDF_KILO_UNIT; + time->sec = (uint64_t)ts.tv_sec; + time->usec = (uint64_t)(ts.tv_nsec / HDF_KILO_UNIT); return HDF_SUCCESS; } diff --git a/tools/hc-gen/src/ast.h b/tools/hc-gen/src/ast.h index 54348339..1542d959 100644 --- a/tools/hc-gen/src/ast.h +++ b/tools/hc-gen/src/ast.h @@ -292,7 +292,7 @@ public: while (forwardWalkObj != nullptr) { if (!preVisited) { - int32_t ret = callback(forwardWalkObj, walkDepth); + int32_t ret = (int32_t)callback(forwardWalkObj, walkDepth); if (ret && ret != EASTWALKBREAK) { return false; } else if (ret != EASTWALKBREAK && forwardWalkObj->child_ != nullptr) {