diff --git a/interfaces/innerkits/accesstoken/src/accesstoken_manager_proxy.h b/interfaces/innerkits/accesstoken/src/accesstoken_manager_proxy.h index 3ad9cab15b73c59f3a465e71bbfe7a6710c50cbb..5e549ade6a422f37f9c5bf8a94e72c6fb846ea1e 100644 --- a/interfaces/innerkits/accesstoken/src/accesstoken_manager_proxy.h +++ b/interfaces/innerkits/accesstoken/src/accesstoken_manager_proxy.h @@ -37,7 +37,7 @@ namespace AccessToken { class AccessTokenManagerProxy : public IRemoteProxy { public: explicit AccessTokenManagerProxy(const sptr& impl); - virtual ~AccessTokenManagerProxy() override; + ~AccessTokenManagerProxy() override; int VerifyAccessToken(AccessTokenID tokenID, const std::string& permissionName) override; int VerifyNativeToken(AccessTokenID tokenID, const std::string& permissionName) override; diff --git a/interfaces/innerkits/tokensync/src/token_sync_manager_proxy.h b/interfaces/innerkits/tokensync/src/token_sync_manager_proxy.h index 6e251e9612d32f642be1ec246d7fd026d1b63960..9568bfa6dd96dad3d903a065d72461a95c8c20d7 100644 --- a/interfaces/innerkits/tokensync/src/token_sync_manager_proxy.h +++ b/interfaces/innerkits/tokensync/src/token_sync_manager_proxy.h @@ -30,7 +30,7 @@ namespace AccessToken { class TokenSyncManagerProxy : public IRemoteProxy { public: explicit TokenSyncManagerProxy(const sptr& impl); - virtual ~TokenSyncManagerProxy() override; + ~TokenSyncManagerProxy() override; int GetRemoteHapTokenInfo(const std::string& deviceID, AccessTokenID tokenID) override; int DeleteRemoteHapTokenInfo(AccessTokenID tokenID) override; diff --git a/services/accesstokenmanager/main/cpp/src/token/accesstoken_id_manager.cpp b/services/accesstokenmanager/main/cpp/src/token/accesstoken_id_manager.cpp index 19d7f272245ec23f99be8f6c808a981a9c2adead..e96fdccf3dabb0af446180f6fb439eaacb048e0a 100644 --- a/services/accesstokenmanager/main/cpp/src/token/accesstoken_id_manager.cpp +++ b/services/accesstokenmanager/main/cpp/src/token/accesstoken_id_manager.cpp @@ -27,7 +27,7 @@ static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, SECURITY_DOMAIN_ ATokenTypeEnum AccessTokenIDManager::GetTokenIdTypeEnum(AccessTokenID id) { - AccessTokenIDInner *idInner = (AccessTokenIDInner *)&id; + AccessTokenIDInner *idInner = reinterpret_cast(&id); return (ATokenTypeEnum)idInner->type; } @@ -44,7 +44,7 @@ ATokenTypeEnum AccessTokenIDManager::GetTokenIdType(AccessTokenID id) int AccessTokenIDManager::RegisterTokenId(AccessTokenID id, ATokenTypeEnum type) { - AccessTokenIDInner *idInner = (AccessTokenIDInner *)&id; + AccessTokenIDInner *idInner = reinterpret_cast(&id); if (idInner->version != DEFAULT_TOKEN_VERSION || idInner->type != type) { return RET_FAILED; } @@ -53,7 +53,7 @@ int AccessTokenIDManager::RegisterTokenId(AccessTokenID id, ATokenTypeEnum type) for (std::set::iterator it = tokenIdSet_.begin(); it != tokenIdSet_.end(); ++it) { AccessTokenID tokenId = *it; - AccessTokenIDInner *idInnerExist = (AccessTokenIDInner *)&tokenId; + AccessTokenIDInner *idInnerExist = reinterpret_cast(&tokenId); if (idInnerExist->tokenUniqueID == idInner->tokenUniqueID) { return RET_FAILED; } diff --git a/services/tokensyncmanager/include/command/delete_remote_token_command.h b/services/tokensyncmanager/include/command/delete_remote_token_command.h index 97e3a2444aba3847c30bdca4f901e6c58f62786d..f0623b051f5ce55722147188dc3458b2f6709bfe 100644 --- a/services/tokensyncmanager/include/command/delete_remote_token_command.h +++ b/services/tokensyncmanager/include/command/delete_remote_token_command.h @@ -34,7 +34,7 @@ public: std::string ToJsonPayload() override; - DeleteRemoteTokenCommand(const std::string &json); + explicit DeleteRemoteTokenCommand(const std::string &json); DeleteRemoteTokenCommand(const std::string &srcDeviceId, const std::string &dstDeviceId, AccessTokenID deleteID); virtual ~DeleteRemoteTokenCommand() = default; diff --git a/services/tokensyncmanager/include/command/sync_remote_hap_token_command.h b/services/tokensyncmanager/include/command/sync_remote_hap_token_command.h index 14df3a21c9ca4d01f370ddd213ea300fa1692c76..a746a977242302ccc77bf742e220dfa8afbcab63 100644 --- a/services/tokensyncmanager/include/command/sync_remote_hap_token_command.h +++ b/services/tokensyncmanager/include/command/sync_remote_hap_token_command.h @@ -39,7 +39,7 @@ public: std::string ToJsonPayload() override; - SyncRemoteHapTokenCommand(const std::string &json); + explicit SyncRemoteHapTokenCommand(const std::string &json); SyncRemoteHapTokenCommand(const std::string &srcDeviceId, const std::string &dstDeviceId, AccessTokenID id); virtual ~SyncRemoteHapTokenCommand() = default; diff --git a/services/tokensyncmanager/include/command/update_remote_hap_token_command.h b/services/tokensyncmanager/include/command/update_remote_hap_token_command.h index 1e6f889195d65ab11d9e03054308fb9253295583..3786241bb31677620eac20840bd2a119b421bd34 100644 --- a/services/tokensyncmanager/include/command/update_remote_hap_token_command.h +++ b/services/tokensyncmanager/include/command/update_remote_hap_token_command.h @@ -38,7 +38,7 @@ public: std::string ToJsonPayload() override; - UpdateRemoteHapTokenCommand(const std::string &json); + explicit UpdateRemoteHapTokenCommand(const std::string &json); UpdateRemoteHapTokenCommand(const std::string &srcDeviceId, const std::string &dstDeviceId, const HapTokenInfoForSync& tokenInfo); virtual ~UpdateRemoteHapTokenCommand() = default; diff --git a/services/tokensyncmanager/include/service/token_sync_event_handler.h b/services/tokensyncmanager/include/service/token_sync_event_handler.h index f9a0caf36e0ef615a1307cece641460628443b35..a86ca94eae2a830d9c0e91a25e30c1eef376b571 100644 --- a/services/tokensyncmanager/include/service/token_sync_event_handler.h +++ b/services/tokensyncmanager/include/service/token_sync_event_handler.h @@ -26,7 +26,7 @@ namespace Security { namespace AccessToken { class TokenSyncEventHandler : public AppExecFwk::EventHandler { public: - TokenSyncEventHandler(const std::shared_ptr &runner); + explicit TokenSyncEventHandler(const std::shared_ptr &runner); virtual ~TokenSyncEventHandler(); bool ProxyPostTask(const Callback &callback, int64_t delayTime); diff --git a/services/tokensyncmanager/src/common/constant.cpp b/services/tokensyncmanager/src/common/constant.cpp index ac90d7d1990ba4086a8691fc8d551320833f42d8..a20a7cc052547f48bc296da132c9ec33cb4c1711 100644 --- a/services/tokensyncmanager/src/common/constant.cpp +++ b/services/tokensyncmanager/src/common/constant.cpp @@ -18,6 +18,9 @@ namespace OHOS { namespace Security { namespace AccessToken { +namespace { +static const std::string REPLACE_TARGET = "****"; +} // namespace const std::string Constant::COMMAND_RESULT_SUCCESS = "success"; const std::string Constant::COMMAND_RESULT_FAILED = "execute command failed"; @@ -25,9 +28,9 @@ std::string Constant::EncryptDevId(std::string deviceId) { std::string result = deviceId; if (deviceId.size() >= ENCRYPTLEN) { - result.replace(ENCRYPTBEGIN, ENCRYPTEND, "****"); + result.replace(ENCRYPTBEGIN, ENCRYPTEND, REPLACE_TARGET); } else { - result.replace(ENCRYPTBEGIN, result.size() - 1, "****"); + result.replace(ENCRYPTBEGIN, result.size() - 1, REPLACE_TARGET); } return result; } diff --git a/services/tokensyncmanager/src/remote/soft_bus_channel.cpp b/services/tokensyncmanager/src/remote/soft_bus_channel.cpp index 61695aeeb099e5cd7def4e25feb4b8c49b1ae690..ab6a481ebee14e7a64e8c3753a4d5df65875addc 100644 --- a/services/tokensyncmanager/src/remote/soft_bus_channel.cpp +++ b/services/tokensyncmanager/src/remote/soft_bus_channel.cpp @@ -32,8 +32,8 @@ namespace { static const std::string REQUEST_TYPE = "request"; static const std::string RESPONSE_TYPE = "response"; static const std::string TASK_NAME_CLOSE_SESSION = "atm_soft_bus_channel_close_session"; -static const long EXECUTE_COMMAND_TIME_OUT = 3000; -static const long WAIT_SESSION_CLOSE_MILLISECONDS = 5 * 1000; +static const int32_t EXECUTE_COMMAND_TIME_OUT = 3000; +static const int32_t WAIT_SESSION_CLOSE_MILLISECONDS = 5 * 1000; // send buf size for header static const int RPC_TRANSFER_HEAD_BYTES_LENGTH = 1024 * 256; // decompress buf size @@ -101,7 +101,7 @@ void SoftBusChannel::CloseConnection() thisPtr->isDelayClosing_ = false; }); - ACCESSTOKEN_LOG_DEBUG(LABEL, "close session after %{public}ld ms", WAIT_SESSION_CLOSE_MILLISECONDS); + ACCESSTOKEN_LOG_DEBUG(LABEL, "close session after %{public}d ms", WAIT_SESSION_CLOSE_MILLISECONDS); handler->ProxyPostTask(delayed, TASK_NAME_CLOSE_SESSION, WAIT_SESSION_CLOSE_MILLISECONDS); isDelayClosing_ = true; @@ -276,7 +276,7 @@ std::string SoftBusChannel::Decompress(const unsigned char *bytes, const int len return ""; } buf[len] = '\0'; - std::string str((char *) buf); + std::string str(reinterpret_cast(buf)); delete[] buf; ACCESSTOKEN_LOG_DEBUG(LABEL, "done, output: %{public}s", str.c_str()); return str; diff --git a/services/tokensyncmanager/test/mock/src/constant_mock.cpp b/services/tokensyncmanager/test/mock/src/constant_mock.cpp index 3995ac79a448a76f60f3700798d5b36425dede7e..6998e7fd672ed3ac601b607dc9af79b8489860c3 100644 --- a/services/tokensyncmanager/test/mock/src/constant_mock.cpp +++ b/services/tokensyncmanager/test/mock/src/constant_mock.cpp @@ -17,6 +17,9 @@ namespace OHOS { namespace Security { namespace AccessToken { +namespace { +static const std::string REPLACE_TARGET = "****"; +} // namespace const std::string Constant::COMMAND_RESULT_SUCCESS = "success"; const std::string Constant::COMMAND_RESULT_FAILED = "execute command failed"; @@ -24,9 +27,9 @@ std::string Constant::EncryptDevId(std::string deviceId) { std::string result = deviceId; if (deviceId.size() >= ENCRYPTLEN) { - result.replace(ENCRYPTBEGIN, ENCRYPTEND, "****"); + result.replace(ENCRYPTBEGIN, ENCRYPTEND, REPLACE_TARGET); } else { - result.replace(ENCRYPTBEGIN, result.size() - 1, "****"); + result.replace(ENCRYPTBEGIN, result.size() - 1, REPLACE_TARGET); } return result; }