stoi告警修复

Signed-off-by: swg3156201044 <shiweigang2@huawei.com>
This commit is contained in:
swg3156201044 2024-10-11 08:58:16 +00:00
parent ebd5fa7e79
commit 201fd2145d

View File

@ -37,6 +37,7 @@
#include "os_account_subscribe_manager.h"
#include "parameter.h"
#include "parcel.h"
#include "string_ex.h"
#include <pthread.h>
#include <thread>
#include <unordered_set>
@ -896,19 +897,23 @@ ErrCode IInnerOsAccountManager::ValidateOsAccount(const OsAccountInfo &osAccount
if (result != ERR_OK) {
return result;
}
std::string localIdStr = std::to_string(osAccountInfo.GetLocalId());
int32_t id = osAccountInfo.GetLocalId();
for (const auto& element : accountIndexJson.items()) {
std::string localIdKey = element.key();
int32_t localId = 0;
if (!StrToInt(element.key(), localId)) {
ACCOUNT_LOGE("Convert localId failed");
continue;
}
auto value = element.value();
std::string localName = value[Constants::LOCAL_NAME].get<std::string>();
if ((osAccountInfo.GetLocalName() == localName) && (localIdKey != localIdStr)
&& !IsToBeRemoved(std::stoi(localIdKey))) {
if ((osAccountInfo.GetLocalName() == localName) && (localId != id)
&& !IsToBeRemoved(localId)) {
return ERR_ACCOUNT_COMMON_NAME_HAD_EXISTED;
}
if (!osAccountInfo.GetShortName().empty() && value.contains(Constants::SHORT_NAME)) {
std::string shortName = value[Constants::SHORT_NAME].get<std::string>();
if ((osAccountInfo.GetShortName() == shortName) && (localIdKey != localIdStr)
&& !IsToBeRemoved(std::stoi(localIdKey))) {
if ((osAccountInfo.GetShortName() == shortName) && (localId != id)
&& !IsToBeRemoved(localId)) {
return ERR_ACCOUNT_COMMON_SHORT_NAME_HAD_EXISTED;
}
}