From 18e362b2140a503573141529577ea1a2c3dfba09 Mon Sep 17 00:00:00 2001 From: zhirenx Date: Mon, 24 Jan 2022 09:33:54 +0800 Subject: [PATCH] code review issue fix. Signed-off-by: zhirenx Change-Id: Iac6221954e821702575e1be4d9d7070c663b4355 --- .../src/standard/messenger_device_session_manager.c | 4 ++-- .../src/standard/messenger_device_status_manager.c | 2 +- baselib/utils/include/utils_datetime.h | 4 ++-- baselib/utils/src/utils_datetime.c | 4 ++-- baselib/utils/src/utils_json.c | 12 ++++++------ common/include/idevice_security_level.h | 2 -- oem_property/ohos/impl/dslm_ohos_request.c | 5 +++-- oem_property/ohos/impl/dslm_ohos_verify.c | 4 ++-- test/dslm_msg_interface_mock.h | 1 - test/dslm_request_callback_mock.cpp | 2 -- test/dslm_request_callback_mock.h | 4 +--- test/dslm_test.cpp | 5 ----- 12 files changed, 19 insertions(+), 30 deletions(-) diff --git a/baselib/msglib/src/standard/messenger_device_session_manager.c b/baselib/msglib/src/standard/messenger_device_session_manager.c index 7fb73d2..016102f 100644 --- a/baselib/msglib/src/standard/messenger_device_session_manager.c +++ b/baselib/msglib/src/standard/messenger_device_session_manager.c @@ -68,7 +68,7 @@ typedef struct SessionInfo { DeviceIdentify identity; } SessionInfo; -static inline DeviceSessionManager *GetDeviceSessionManagerInstance(void) +static DeviceSessionManager *GetDeviceSessionManagerInstance(void) { static DeviceSessionManager manager = { { @@ -108,7 +108,7 @@ static void ProcessSessionMessageReceived(const uint8_t *data, uint32_t len) FREE(queueData); } -static inline void OnSessionMessageReceived(const DeviceIdentify *devId, const uint8_t *msg, uint32_t msgLen) +static void OnSessionMessageReceived(const DeviceIdentify *devId, const uint8_t *msg, uint32_t msgLen) { DeviceSessionManager *instance = GetDeviceSessionManagerInstance(); WorkQueue *queue = instance->queue; diff --git a/baselib/msglib/src/standard/messenger_device_status_manager.c b/baselib/msglib/src/standard/messenger_device_status_manager.c index f922137..24f8043 100644 --- a/baselib/msglib/src/standard/messenger_device_status_manager.c +++ b/baselib/msglib/src/standard/messenger_device_status_manager.c @@ -40,7 +40,7 @@ typedef struct QueueStatusData { uint32_t devType; } QueueStatusData; -static inline DeviceStatusManager *GetDeviceManagerInstance() +static DeviceStatusManager *GetDeviceManagerInstance(void) { static DeviceStatusManager manager = { { diff --git a/baselib/utils/include/utils_datetime.h b/baselib/utils/include/utils_datetime.h index d64a128..79ef50d 100644 --- a/baselib/utils/include/utils_datetime.h +++ b/baselib/utils/include/utils_datetime.h @@ -33,9 +33,9 @@ typedef struct DateTime { uint16_t day; } DateTime; -uint64_t GetMillisecondSinceBoot(); +uint64_t GetMillisecondSinceBoot(void); -uint64_t GetMillisecondSince1970(); +uint64_t GetMillisecondSince1970(void); bool GetDateTimeByMillisecondSince1970(uint64_t input, DateTime *datetime); diff --git a/baselib/utils/src/utils_datetime.c b/baselib/utils/src/utils_datetime.c index 30bed01..987d8c5 100644 --- a/baselib/utils/src/utils_datetime.c +++ b/baselib/utils/src/utils_datetime.c @@ -28,14 +28,14 @@ extern "C" { #define MILLISEC_TO_USEC 1000 #define MICROSEC_TO_NANOSEC 1000 -uint64_t GetMillisecondSinceBoot() +uint64_t GetMillisecondSinceBoot(void) { struct timespec ts; clock_gettime(CLOCK_MONOTONIC, &ts); return (ts.tv_sec * SEC_TO_MILLISEC + ts.tv_nsec / MILLISEC_TO_NANOSEC); } -uint64_t GetMillisecondSince1970() +uint64_t GetMillisecondSince1970(void) { struct timespec ts; clock_gettime(CLOCK_REALTIME, &ts); diff --git a/baselib/utils/src/utils_json.c b/baselib/utils/src/utils_json.c index df80154..f70b8d5 100644 --- a/baselib/utils/src/utils_json.c +++ b/baselib/utils/src/utils_json.c @@ -78,7 +78,7 @@ int32_t GetJsonFieldIntArray(JsonHandle handle, const char *field, int32_t *arra if (objValue == NULL) { return 0; } - if (!cJSON_IsArray(objValue)){ + if (!cJSON_IsArray(objValue)) { return 0; } @@ -88,11 +88,11 @@ int32_t GetJsonFieldIntArray(JsonHandle handle, const char *field, int32_t *arra } int32_t index = 0; for (int32_t i = 0; i < size; i++) { - cJSON *item = cJSON_GetArrayItem(objValue, i); - if (!cJSON_IsNumber(item)) { - continue; - } - array[index++] = item->valueint; + cJSON *item = cJSON_GetArrayItem(objValue, i); + if (!cJSON_IsNumber(item)) { + continue; + } + array[index++] = item->valueint; } return index; diff --git a/common/include/idevice_security_level.h b/common/include/idevice_security_level.h index c490e8f..5ed3b5b 100644 --- a/common/include/idevice_security_level.h +++ b/common/include/idevice_security_level.h @@ -25,7 +25,6 @@ namespace OHOS { namespace Security { namespace DeviceSecurityLevel { - constexpr int32_t SA_ID_DEVICE_SECURITY_MANAGER_SERVICE = 3511; class IDeviceSecurityLevel : public IRemoteBroker { @@ -43,7 +42,6 @@ public: CMD_SET_DEVICE_SECURITY_LEVEL = 1, }; }; - } // namespace DeviceSecurityLevel } // namespace Security } // namespace OHOS diff --git a/oem_property/ohos/impl/dslm_ohos_request.c b/oem_property/ohos/impl/dslm_ohos_request.c index 3a92fd4..0c86fa7 100644 --- a/oem_property/ohos/impl/dslm_ohos_request.c +++ b/oem_property/ohos/impl/dslm_ohos_request.c @@ -15,10 +15,11 @@ #include "dslm_ohos_request.h" -#include "utils_log.h" -#include #include +#include "securec.h" +#include "utils_log.h" + #include "utils_mem.h" int32_t RequestOhosDslmCred(const DeviceIdentify *device, const RequestObject *obj, DslmCredBuff **credBuff) diff --git a/oem_property/ohos/impl/dslm_ohos_verify.c b/oem_property/ohos/impl/dslm_ohos_verify.c index 1f231ec..e62a234 100644 --- a/oem_property/ohos/impl/dslm_ohos_verify.c +++ b/oem_property/ohos/impl/dslm_ohos_verify.c @@ -15,10 +15,10 @@ #include "dslm_ohos_verify.h" -#include "utils_log.h" -#include #include +#include "securec.h" +#include "utils_log.h" #include "utils_mem.h" #define OHOS_DEFAULT_LEVEL 1 diff --git a/test/dslm_msg_interface_mock.h b/test/dslm_msg_interface_mock.h index 5bf03ec..63912cd 100644 --- a/test/dslm_msg_interface_mock.h +++ b/test/dslm_msg_interface_mock.h @@ -60,7 +60,6 @@ public: void MakeDeviceOffline(const DeviceIdentify *devId) const; void MakeMsgReceivedFrom(const DeviceIdentify *devId, const uint8_t *msg, uint32_t msgLen) const; }; - } // namespace DslmUnitTest } // namespace Security } // namespace OHOS diff --git a/test/dslm_request_callback_mock.cpp b/test/dslm_request_callback_mock.cpp index a4abac7..5792028 100644 --- a/test/dslm_request_callback_mock.cpp +++ b/test/dslm_request_callback_mock.cpp @@ -25,7 +25,6 @@ using namespace testing::ext; namespace OHOS { namespace Security { namespace DslmUnitTest { - DslmRequestCallbackMock::DslmRequestCallbackMock() { std::lock_guard lock(mutex_); @@ -50,7 +49,6 @@ void DslmRequestCallbackMock::MockedCallback(uint32_t cookie, uint32_t result, c DslmRequestCallback *DslmRequestCallbackMock::obj_ = nullptr; std::mutex DslmRequestCallbackMock::mutex_ {}; - } // namespace DslmUnitTest } // namespace Security } // namespace OHOS diff --git a/test/dslm_request_callback_mock.h b/test/dslm_request_callback_mock.h index b3f4485..fc95d70 100644 --- a/test/dslm_request_callback_mock.h +++ b/test/dslm_request_callback_mock.h @@ -26,7 +26,6 @@ namespace OHOS { namespace Security { namespace DslmUnitTest { - class DslmRequestCallback { public: DslmRequestCallback() {}; @@ -37,7 +36,7 @@ public: class DslmRequestCallbackMock : public DslmRequestCallback { public: DslmRequestCallbackMock(); - virtual ~DslmRequestCallbackMock() override; + ~DslmRequestCallbackMock() override; MOCK_METHOD3(RequestCallback, void(uint32_t cookie, uint32_t result, const DslmCallbackInfo *info)); static void MockedCallback(uint32_t cookie, uint32_t result, const DslmCallbackInfo *info); @@ -46,7 +45,6 @@ private: static DslmRequestCallback *obj_; static std::mutex mutex_; }; - } // namespace DslmUnitTest } // namespace Security } // namespace OHOS diff --git a/test/dslm_test.cpp b/test/dslm_test.cpp index 87d0f8f..10c85bd 100644 --- a/test/dslm_test.cpp +++ b/test/dslm_test.cpp @@ -47,7 +47,6 @@ using namespace testing::ext; namespace OHOS { namespace Security { namespace DslmUnitTest { -#ifdef GTEST_INCLUDE_GTEST_GTEST_H_ void DslmTest::SetUpTestCase() { } @@ -567,7 +566,6 @@ HWTEST_F(DslmTest, InitSelfDeviceSecureLevel_case2, TestSize.Level1) HWTEST_F(DslmTest, InnerKitsTest_case1, TestSize.Level1) { - DeviceIdentify device = {DEVICE_ID_MAX_LEN, {0}}; DeviceSecurityInfo *info = NULL; @@ -598,7 +596,6 @@ void TestDeviceSecurityInfoCallback(const DeviceIdentify *identify, struct Devic HWTEST_F(DslmTest, InnerKitsTest_case2, TestSize.Level1) { - DeviceIdentify device = {DEVICE_ID_MAX_LEN, {0}}; g_cnt = 0; @@ -615,8 +612,6 @@ HWTEST_F(DslmTest, InnerKitsTest_case2, TestSize.Level1) g_cv.wait_for(lck, std::chrono::milliseconds(2000), []() { return (g_cnt == 3); }); EXPECT_EQ(g_cnt, 3); } - -#endif } // namespace DslmUnitTest } // namespace Security } // namespace OHOS -- Gitee