From 5afbbd647b68854e61ece6e268c0132045bfbab0 Mon Sep 17 00:00:00 2001 From: wangjingen Date: Thu, 22 Sep 2022 21:15:00 +0800 Subject: [PATCH] fix:clean warning Signed-off-by: wangjingen --- core/connection/br/src/br_pending_packet.c | 4 +-- core/discovery/ble/include/disc_ble_utils.h | 2 -- core/discovery/ble/src/disc_ble.c | 16 +++-------- core/discovery/ble/src/disc_ble_utils.c | 27 +------------------ .../publishservice_fuzzer.cpp | 2 +- .../startdiscovery_fuzzer.cpp | 2 +- .../stopdiscovery_fuzzer.cpp | 2 +- .../unpublishservice_fuzzer.cpp | 2 +- 8 files changed, 10 insertions(+), 47 deletions(-) diff --git a/core/connection/br/src/br_pending_packet.c b/core/connection/br/src/br_pending_packet.c index 6f9e12930d..8d0320e68c 100644 --- a/core/connection/br/src/br_pending_packet.c +++ b/core/connection/br/src/br_pending_packet.c @@ -59,7 +59,7 @@ int32_t CreateBrPendingPacket(uint32_t id, uint64_t seq) if (SoftBusMutexLock(&g_pendingLock) != SOFTBUS_OK) { return SOFTBUS_LOCK_ERR; } - PendingPacket *pending = NULL; + PendingPacket *pending; LIST_FOR_EACH_ENTRY(pending, &g_pendingList, PendingPacket, node) { if (pending->id == id && pending->seq == seq) { SoftBusLog(SOFTBUS_LOG_CONN, SOFTBUS_LOG_ERROR, "PendingPacket existed. id: %u, seq: %" PRIu64, id, seq); @@ -118,7 +118,7 @@ int32_t GetBrPendingPacket(uint32_t id, uint64_t seq, uint32_t waitMillis, void return SOFTBUS_ERR; } PendingPacket *pending = NULL; - PendingPacket *item = NULL; + PendingPacket *item; LIST_FOR_EACH_ENTRY(item, &g_pendingList, PendingPacket, node) { if (item->id == id && item->seq == seq) { pending = item; diff --git a/core/discovery/ble/include/disc_ble_utils.h b/core/discovery/ble/include/disc_ble_utils.h index e4cc21c446..6b366421ff 100644 --- a/core/discovery/ble/include/disc_ble_utils.h +++ b/core/discovery/ble/include/disc_ble_utils.h @@ -49,13 +49,11 @@ typedef struct { bool CheckBitMapEmpty(uint32_t capBitMapNum, const uint32_t *capBitMap); bool CheckCapBitMapExist(uint32_t capBitMapNum, const uint32_t *capBitMap, uint32_t pos); -bool CheckCapBitMapEqual(const uint32_t *srcBitMap, const uint32_t *dstBitMap, uint32_t capBitMapNum); void SetCapBitMapPos(uint32_t capBitMapNum, uint32_t *capBitMap, uint32_t pos); void UnsetCapBitMapPos(uint32_t capBitMapNum, uint32_t *capBitMap, uint32_t pos); int32_t DiscBleGetDeviceUdid(char *udid, uint32_t len); int32_t DiscBleGetDeviceName(char *deviceName); -int32_t DiscBleGetHwAccount(char *hwAccount); uint8_t DiscBleGetDeviceType(void); int32_t DiscBleGetDeviceIdHash(unsigned char *hashStr); int32_t DiscBleGetShortUserIdHash(unsigned char *hashStr, uint32_t len); diff --git a/core/discovery/ble/src/disc_ble.c b/core/discovery/ble/src/disc_ble.c index b180eaa69d..7e917ccc1f 100644 --- a/core/discovery/ble/src/disc_ble.c +++ b/core/discovery/ble/src/disc_ble.c @@ -479,7 +479,6 @@ static void ProcessDistributePacket(const SoftBusBleScanResult *scanResultData) static void BleScanResultCallback(int listenerId, const SoftBusBleScanResult *scanResultData) { - unsigned char distinguish[] = "ble rcv"; (void)listenerId; if (scanResultData == NULL) { SoftBusLog(SOFTBUS_LOG_DISC, SOFTBUS_LOG_ERROR, "scanResultData is NULL"); @@ -493,6 +492,7 @@ static void BleScanResultCallback(int listenerId, const SoftBusBleScanResult *sc return; } if ((advData[POS_BUSINESS + ADV_HEAD_LEN] & DISTRIBUTE_BUSINESS) == DISTRIBUTE_BUSINESS) { + unsigned char distinguish[] = "ble rcv"; SignalingMsgPrint(distinguish, advData, scanResultData->advLen, SOFTBUS_LOG_DISC); ProcessDistributePacket(scanResultData); } else if ((advData[POS_BUSINESS + ADV_HEAD_LEN] & NEARBY_BUSINESS) == NEARBY_BUSINESS) { @@ -571,16 +571,6 @@ static int32_t GetMaxExchangeFreq(void) return maxFreq; } -bool GetSameAccount(void) -{ - for (uint32_t index = 0; index < CAPABILITY_MAX_BITNUM; index++) { - if (g_bleInfoManager[BLE_SUBSCRIBE | BLE_ACTIVE].isSameAccount[index]) { - return true; - } - } - return false; -} - static bool GetWakeRemote(void) { for (uint32_t index = 0; index < CAPABILITY_MAX_BITNUM; index++) { @@ -1403,7 +1393,7 @@ static RecvMessage *GetRecvMessage(const char *key) if (key == NULL) { return NULL; } - RecvMessage *msg = NULL; + RecvMessage *msg; LIST_FOR_EACH_ENTRY(msg, &g_recvMessageInfo.node, RecvMessage, node) { if (memcmp((void *)key, (void *)msg->key, SHA_HASH_LEN) == 0) { return msg; @@ -1418,7 +1408,7 @@ static int32_t MatchRecvMessage(const uint32_t *publishInfoMap, uint32_t *capBit return SOFTBUS_INVALID_PARAM; } (void)SoftBusMutexLock(&g_recvMessageInfo.lock); - RecvMessage *msg = NULL; + RecvMessage *msg; SoftBusLog(SOFTBUS_LOG_DISC, SOFTBUS_LOG_INFO, "recv message cnt: %d", g_recvMessageInfo.numNeedResp); LIST_FOR_EACH_ENTRY(msg, &g_recvMessageInfo.node, RecvMessage, node) { for (uint32_t index = 0; index < len; index++) { diff --git a/core/discovery/ble/src/disc_ble_utils.c b/core/discovery/ble/src/disc_ble_utils.c index a4b32c37de..81646483c3 100644 --- a/core/discovery/ble/src/disc_ble_utils.c +++ b/core/discovery/ble/src/disc_ble_utils.c @@ -75,19 +75,6 @@ bool CheckCapBitMapExist(uint32_t capBitMapNum, const uint32_t *capBitMap, uint3 return (capBitMap[index] >> (pos % INT32_MAX_BIT_NUM)) & 0x1 ? true : false; } -bool CheckCapBitMapEqual(const uint32_t *srcBitMap, const uint32_t *dstBitMap, uint32_t capBitMapNum) -{ - if (srcBitMap == NULL || dstBitMap == NULL) { - return false; - } - for (uint32_t i = 0; i < capBitMapNum; i++) { - if (srcBitMap[i] != dstBitMap[i]) { - return false; - } - } - return true; -} - void SetCapBitMapPos(uint32_t capBitMapNum, uint32_t *capBitMap, uint32_t pos) { if (capBitMap == NULL) { @@ -113,18 +100,6 @@ void UnsetCapBitMapPos(uint32_t capBitMapNum, uint32_t *capBitMap, uint32_t pos) capBitMap[index] = capBitMap[index] & mask; } -int32_t DiscBleGetHwAccount(char *hwAccount) -{ - if (hwAccount == NULL) { - return SOFTBUS_INVALID_PARAM; - } - const char *account = ""; - if (memcpy_s(hwAccount, strlen(account) + 1, account, strlen(account) + 1) != EOK) { - return SOFTBUS_MEM_ERR; - } - return SOFTBUS_OK; -} - int32_t DiscBleGetDeviceUdid(char *udid, uint32_t len) { if (udid == NULL) { @@ -132,7 +107,7 @@ int32_t DiscBleGetDeviceUdid(char *udid, uint32_t len) } if (LnnGetLocalStrInfo(STRING_KEY_DEV_UDID, udid, len) != SOFTBUS_OK) { SoftBusLog(SOFTBUS_LOG_DISC, SOFTBUS_LOG_ERROR, "Get local dev Id failed."); - return SOFTBUS_ERR; + return SOFTBUS_ERR; } return SOFTBUS_OK; } diff --git a/tests/sdk/discovery/fuzztest/publishservice_fuzzer/publishservice_fuzzer.cpp b/tests/sdk/discovery/fuzztest/publishservice_fuzzer/publishservice_fuzzer.cpp index f0802ea6e1..42550d4b63 100644 --- a/tests/sdk/discovery/fuzztest/publishservice_fuzzer/publishservice_fuzzer.cpp +++ b/tests/sdk/discovery/fuzztest/publishservice_fuzzer/publishservice_fuzzer.cpp @@ -54,7 +54,7 @@ void PublishServiceTest(const uint8_t* data, size_t size) .dataLen = sizeof("capdata2") }; - if ((data == nullptr) || (size <= 0)) { + if ((data == nullptr) || (size == 0)) { return; } diff --git a/tests/sdk/discovery/fuzztest/startdiscovery_fuzzer/startdiscovery_fuzzer.cpp b/tests/sdk/discovery/fuzztest/startdiscovery_fuzzer/startdiscovery_fuzzer.cpp index 54241ca4f1..7aad29a9d7 100644 --- a/tests/sdk/discovery/fuzztest/startdiscovery_fuzzer/startdiscovery_fuzzer.cpp +++ b/tests/sdk/discovery/fuzztest/startdiscovery_fuzzer/startdiscovery_fuzzer.cpp @@ -60,7 +60,7 @@ void StartDiscoveryTest(const uint8_t* data, size_t size) .dataLen = sizeof("capdata3") }; - if ((data == nullptr) || (size <= 0)) { + if ((data == nullptr) || (size == 0)) { return; } diff --git a/tests/sdk/discovery/fuzztest/stopdiscovery_fuzzer/stopdiscovery_fuzzer.cpp b/tests/sdk/discovery/fuzztest/stopdiscovery_fuzzer/stopdiscovery_fuzzer.cpp index 89f2346e60..8c302ae552 100644 --- a/tests/sdk/discovery/fuzztest/stopdiscovery_fuzzer/stopdiscovery_fuzzer.cpp +++ b/tests/sdk/discovery/fuzztest/stopdiscovery_fuzzer/stopdiscovery_fuzzer.cpp @@ -45,7 +45,7 @@ void StopDiscoveryTest(const uint8_t* data, size_t size) .dataLen = sizeof("capdata3") }; - if ((data == nullptr) || (size <= 0)) { + if ((data == nullptr) || (size == 0)) { return; } diff --git a/tests/sdk/discovery/fuzztest/unpublishservice_fuzzer/unpublishservice_fuzzer.cpp b/tests/sdk/discovery/fuzztest/unpublishservice_fuzzer/unpublishservice_fuzzer.cpp index a6c0914920..691ca3069b 100644 --- a/tests/sdk/discovery/fuzztest/unpublishservice_fuzzer/unpublishservice_fuzzer.cpp +++ b/tests/sdk/discovery/fuzztest/unpublishservice_fuzzer/unpublishservice_fuzzer.cpp @@ -43,7 +43,7 @@ void UnPublishServiceTest(const uint8_t* data, size_t size) .dataLen = sizeof("capdata2") }; - if ((data == nullptr) || (size <= 0)) { + if ((data == nullptr) || (size == 0)) { return; }