!1251 [Fix]: Increase initialization

Merge pull request !1251 from Bumblebee/mrsong_branch
This commit is contained in:
openharmony_ci 2023-12-19 02:57:04 +00:00 committed by Gitee
commit 9b1341406a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
14 changed files with 41 additions and 41 deletions

View File

@ -59,7 +59,7 @@ napi_value JsCooperateContext::Enable(napi_env env, napi_callback_info info)
{
CALL_INFO_TRACE;
size_t argc = TWO_PARAM;
napi_value argv[TWO_PARAM] = {};
napi_value argv[TWO_PARAM] = { nullptr };
CHKRP(napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr), GET_CB_INFO);
if (argc == ZERO_PARAM) {
@ -91,7 +91,7 @@ napi_value JsCooperateContext::Start(napi_env env, napi_callback_info info)
{
CALL_INFO_TRACE;
size_t argc = THREE_PARAM;
napi_value argv[THREE_PARAM] = {};
napi_value argv[THREE_PARAM] = { nullptr };
CHKRP(napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr), GET_CB_INFO);
if (argc < TWO_PARAM) {
@ -106,7 +106,7 @@ napi_value JsCooperateContext::Start(napi_env env, napi_callback_info info)
THROWERR(env, COMMON_PARAMETER_ERROR, "startDeviceId", "number");
return nullptr;
}
char remoteNetworkDescriptor[MAX_STRING_LEN] = {};
char remoteNetworkDescriptor[MAX_STRING_LEN] = { 0 };
int32_t startDeviceId = ZERO_PARAM;
size_t length = ZERO_PARAM;
CHKRP(napi_get_value_string_utf8(env, argv[ZERO_PARAM], remoteNetworkDescriptor,
@ -131,7 +131,7 @@ napi_value JsCooperateContext::Stop(napi_env env, napi_callback_info info)
{
CALL_INFO_TRACE;
size_t argc = ONE_PARAM;
napi_value argv[ONE_PARAM] = {};
napi_value argv[ONE_PARAM] = { nullptr };
CHKRP(napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr), GET_CB_INFO);
JsCooperateContext *jsDev = JsCooperateContext::GetInstance(env);
@ -152,7 +152,7 @@ napi_value JsCooperateContext::GetState(napi_env env, napi_callback_info info)
{
CALL_INFO_TRACE;
size_t argc = TWO_PARAM;
napi_value argv[TWO_PARAM] = {};
napi_value argv[TWO_PARAM] = { nullptr };
CHKRP(napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr), GET_CB_INFO);
if (argc == ZERO_PARAM) {
@ -186,7 +186,7 @@ napi_value JsCooperateContext::GetState(napi_env env, napi_callback_info info)
napi_value JsCooperateContext::On(napi_env env, napi_callback_info info)
{
CALL_INFO_TRACE;
napi_value argv[TWO_PARAM] = {};
napi_value argv[TWO_PARAM] = { nullptr };
size_t argc = TWO_PARAM;
CHKRP(napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr), GET_CB_INFO);
if (argc == ZERO_PARAM) {
@ -198,7 +198,7 @@ napi_value JsCooperateContext::On(napi_env env, napi_callback_info info)
THROWERR(env, COMMON_PARAMETER_ERROR, "type", "string");
return nullptr;
}
char type[MAX_STRING_LEN] = {};
char type[MAX_STRING_LEN] = { 0 };
size_t length = ZERO_PARAM;
CHKRP(napi_get_value_string_utf8(env, argv[ZERO_PARAM], type, sizeof(type), &length), GET_VALUE_STRING_UTF8);
if (std::strcmp(type, "cooperation") != ZERO_PARAM) {
@ -221,7 +221,7 @@ napi_value JsCooperateContext::Off(napi_env env, napi_callback_info info)
{
CALL_INFO_TRACE;
size_t argc = TWO_PARAM;
napi_value argv[TWO_PARAM] = {};
napi_value argv[TWO_PARAM] = { nullptr };
CHKRP(napi_get_cb_info(env, info, &argc, argv, nullptr, nullptr), GET_CB_INFO);
if (argc == ZERO_PARAM) {
@ -232,7 +232,7 @@ napi_value JsCooperateContext::Off(napi_env env, napi_callback_info info)
THROWERR(env, COMMON_PARAMETER_ERROR, "type", "string");
return nullptr;
}
char type[MAX_STRING_LEN] = {};
char type[MAX_STRING_LEN] = { 0 };
size_t length = ZERO_PARAM;
CHKRP(napi_get_value_string_utf8(env, argv[ZERO_PARAM], type, sizeof(type), &length), GET_VALUE_STRING_UTF8);
std::string typeTmp = type;
@ -403,7 +403,7 @@ void JsCooperateContext::DeclareDeviceCoordinationData(napi_env env, napi_value
napi_value JsCooperateContext::EnumClassConstructor(napi_env env, napi_callback_info info)
{
size_t argc = ZERO_PARAM;
napi_value args[ONE_PARAM] = {};
napi_value args[ONE_PARAM] = { nullptr };
napi_value result = nullptr;
void *data = nullptr;
CHKRP(napi_get_cb_info(env, info, &argc, args, &result, &data), GET_CB_INFO);

View File

@ -548,7 +548,7 @@ void JsCoordinationContext::DeclareDeviceCoordinationInterface(napi_env env, nap
napi_value JsCoordinationContext::EnumClassConstructor(napi_env env, napi_callback_info info)
{
size_t argc = 0;
napi_value args[1] = {};
napi_value args[1] = { nullptr };
napi_value result = nullptr;
void *data = nullptr;
CHKRP(napi_get_cb_info(env, info, &argc, args, &result, &data), GET_CB_INFO);

View File

@ -51,13 +51,13 @@ bool JsDragManager::IsSameHandle(napi_env env, napi_value handle, napi_ref ref)
napi_value JsDragManager::GetDataSummary(napi_env env)
{
CALL_INFO_TRACE;
napi_value arr = nullptr;
CHKRP(napi_create_array(env, &arr), CREATE_ARRAY);
std::map<std::string, int64_t> summarys;
if (INTERACTION_MGR->GetDragSummary(summarys) != RET_OK) {
FI_HILOGE("Failed to GetDragSummary");
return nullptr;
return arr;
}
napi_value arr = nullptr;
CHKRP(napi_create_array(env, &arr), CREATE_ARRAY);
uint32_t index = 0;
for (const auto &summary : summarys) {
napi_value dataType = nullptr;

View File

@ -137,9 +137,9 @@ int32_t DeviceStatusNapi::ConvertTypeToInt(const std::string &type)
bool DeviceStatusNapi::CheckArguments(napi_env env, napi_callback_info info)
{
CALL_DEBUG_ENTER;
int32_t arr[ARG_4] = {};
int32_t arr[ARG_4] = { 0 };
size_t argc = ARG_4;
napi_value args[ARG_4] = {};
napi_value args[ARG_4] = { nullptr };
napi_status status = napi_get_cb_info(env, info, &argc, args, nullptr, nullptr);
if (status != napi_ok) {
FI_HILOGE("Failed to get_cb_info");
@ -178,9 +178,9 @@ bool DeviceStatusNapi::IsMatchType(napi_env env, napi_value value, napi_valuetyp
bool DeviceStatusNapi::CheckGetArguments(napi_env env, napi_callback_info info)
{
CALL_DEBUG_ENTER;
int32_t arr[ARG_2] = {};
int32_t arr[ARG_2] = { 0 };
size_t argc = ARG_2;
napi_value args[ARG_2] = {};
napi_value args[ARG_2] = { nullptr };
napi_status status = napi_get_cb_info(env, info, &argc, args, nullptr, nullptr);
if (status != napi_ok) {
FI_HILOGE("Failed to get_cb_info");
@ -208,7 +208,7 @@ std::tuple<bool, napi_value, std::string, int32_t, int32_t> DeviceStatusNapi::Ch
{
std::tuple<bool, napi_value, std::string, int32_t, int32_t> result { false, nullptr, "", -1, -1 };
size_t argc = ARG_4;
napi_value args[ARG_4] = {};
napi_value args[ARG_4] = { nullptr };
napi_status status = napi_get_cb_info(env, info, &argc, args, nullptr, nullptr);
if ((status != napi_ok) || (argc < ARG_4)) {
ThrowErr(env, PARAM_ERROR, "Bad parameters");
@ -224,7 +224,7 @@ std::tuple<bool, napi_value, std::string, int32_t, int32_t> DeviceStatusNapi::Ch
ThrowErr(env, PARAM_ERROR, "Failed to get string item");
return result;
}
char mode[NAPI_BUF_LENGTH] = {};
char mode[NAPI_BUF_LENGTH] = { 0 };
status = napi_get_value_string_utf8(env, args[ARG_0], mode, modLen + 1, &modLen);
if (status != napi_ok) {
ThrowErr(env, PARAM_ERROR, "Failed to get mode");
@ -249,7 +249,7 @@ std::tuple<bool, napi_value, int32_t> DeviceStatusNapi::CheckGetParam(napi_env e
{
std::tuple<bool, napi_value, int32_t> result { false, nullptr, -1 };
size_t argc = ARG_2;
napi_value args[ARG_2] = {};
napi_value args[ARG_2] = { nullptr };
napi_status status = napi_get_cb_info(env, info, &argc, args, nullptr, nullptr);
if ((status != napi_ok) || (argc < ARG_2)) {
ThrowErr(env, PARAM_ERROR, "Bad parameters");
@ -265,7 +265,7 @@ std::tuple<bool, napi_value, int32_t> DeviceStatusNapi::CheckGetParam(napi_env e
ThrowErr(env, PARAM_ERROR, "Failed to get string item");
return result;
}
char mode[NAPI_BUF_LENGTH] = {};
char mode[NAPI_BUF_LENGTH] = { 0 };
napiStatus = napi_get_value_string_utf8(env, args[ARG_0], mode, modLen + 1, &modLen);
if (napiStatus != napi_ok) {
ThrowErr(env, PARAM_ERROR, "Failed to get mode");
@ -288,7 +288,7 @@ napi_value DeviceStatusNapi::GetParameters(napi_env env, size_t argc, const napi
ThrowErr(env, PARAM_ERROR, "Failed to get string item");
return nullptr;
}
char mode[NAPI_BUF_LENGTH] = {};
char mode[NAPI_BUF_LENGTH] = { 0 };
status = napi_get_value_string_utf8(env, args[0], mode, modLen + 1, &modLen);
if (status != napi_ok) {
ThrowErr(env, PARAM_ERROR, "Failed to get mode");
@ -401,7 +401,7 @@ napi_value DeviceStatusNapi::UnsubscribeDeviceStatus(napi_env env, napi_callback
CALL_DEBUG_ENTER;
CHKPP(g_obj);
size_t argc = 3;
napi_value args[3] = {};
napi_value args[3] = { nullptr };
napi_status status = napi_get_cb_info(env, info, &argc, args, nullptr, nullptr);
if (status != napi_ok) {
ThrowErr(env, PARAM_ERROR, "Bad parameters");

View File

@ -37,7 +37,7 @@ void FdListener::OnReadable(int32_t fd)
return;
}
CHKPV(iClient_);
char szBuf[MAX_PACKET_BUF_SIZE] = {};
char szBuf[MAX_PACKET_BUF_SIZE] = { 0 };
for (int32_t i = 0; i < MAX_RECV_LIMIT; i++) {
ssize_t size = recv(fd, szBuf, MAX_PACKET_BUF_SIZE, MSG_DONTWAIT | MSG_NOSIGNAL);
if (size > 0) {

View File

@ -567,7 +567,7 @@ std::string CooperateSoftbusAdapter::FindDevice(int32_t sessionId)
int32_t CooperateSoftbusAdapter::OnSessionOpened(int32_t sessionId, int32_t result)
{
CALL_INFO_TRACE;
char peerDevId[DEVICE_ID_SIZE_MAX] = {};
char peerDevId[DEVICE_ID_SIZE_MAX] = { 0 };
sessionId_ = sessionId;
int32_t getPeerDeviceIdResult = GetPeerDeviceId(sessionId, peerDevId, sizeof(peerDevId));
FI_HILOGD("Get peer device id ret:%{public}d", getPeerDeviceIdResult);

View File

@ -130,7 +130,7 @@ std::string DeviceStatusDataParse::ReadJsonFile(const std::string &filePath)
FI_HILOGE("Path is empty");
return {};
}
char realPath[PATH_MAX] = {};
char realPath[PATH_MAX] = { 0 };
if (realpath(filePath.c_str(), realPath) == nullptr) {
FI_HILOGE("Path is error, %{public}d", errno);
return {};
@ -192,7 +192,7 @@ std::string DeviceStatusDataParse::ReadFile(const std::string &filePath)
return {};
}
std::string dataStr;
char buf[READ_DATA_BUFF_SIZE] = {};
char buf[READ_DATA_BUFF_SIZE] = { 0 };
while (fgets(buf, sizeof(buf), fp) != nullptr) {
dataStr += buf;
}

View File

@ -85,7 +85,7 @@ int32_t DeviceStatusAlgorithmTest::LoadAlgoLibrary(const std::shared_ptr<MsdpAlg
}
std::string dlName = DEVICESTATUS_ALGO_LIB_PATH;
char libRealPath[PATH_MAX] = {};
char libRealPath[PATH_MAX] = { 0 };
if (realpath(dlName.c_str(), libRealPath) == nullptr) {
FI_HILOGE("Get absolute algoPath is error, errno:%{public}d", errno);
return RET_ERR;

View File

@ -80,7 +80,7 @@ int32_t DeviceStatusMsdpMocKTest::LoadMockLibrary(const std::shared_ptr<MsdpAlgo
}
std::string dlName = DEVICESTATUS_MOCK_LIB_PATH;
char libRealPath[PATH_MAX] = {};
char libRealPath[PATH_MAX] = { 0 };
if (realpath(dlName.c_str(), libRealPath) == nullptr) {
FI_HILOGE("Get absolute algoPath is error, errno:%{public}d", errno);
return RET_ERR;

View File

@ -175,7 +175,7 @@ int32_t CoordinationSoftbusAdapter::Init()
return RET_OK;
}
localSessionName_ = bindName;
char name[DEVICE_NAME_SIZE_MAX] = {};
char name[DEVICE_NAME_SIZE_MAX] = { 0 };
if (ChkAndCpyStr(name, DEVICE_NAME_SIZE_MAX, sessionName.c_str()) != RET_OK) {
FI_HILOGE("Invalid name:%{public}s", sessionName.c_str());
return RET_ERR;
@ -243,18 +243,18 @@ int32_t CoordinationSoftbusAdapter::OpenInputSoftbus(const std::string &remoteNe
FI_HILOGD("InputSoftbus session has already opened");
return RET_OK;
}
char name[DEVICE_NAME_SIZE_MAX] = {};
char name[DEVICE_NAME_SIZE_MAX] = { 0 };
if (ChkAndCpyStr(name, DEVICE_NAME_SIZE_MAX, localSessionName_.c_str()) != RET_OK) {
FI_HILOGE("Invalid name:%{public}s", localSessionName_.c_str());
return RET_ERR;
}
std::string peerSessionName = SESSION_NAME + remoteNetworkId.substr(0, INTERCEPT_STRING_LENGTH);
char peerName[DEVICE_NAME_SIZE_MAX] = {};
char peerName[DEVICE_NAME_SIZE_MAX] = { 0 };
if (ChkAndCpyStr(peerName, DEVICE_NAME_SIZE_MAX, peerSessionName.c_str()) != RET_OK) {
FI_HILOGE("Invalid peerSessionName:%{public}s", peerSessionName.c_str());
return RET_ERR;
}
char peerNetworkId[PKG_NAME_SIZE_MAX] = {};
char peerNetworkId[PKG_NAME_SIZE_MAX] = { 0 };
if (ChkAndCpyStr(peerNetworkId, PKG_NAME_SIZE_MAX, remoteNetworkId.c_str()) != RET_OK) {
FI_HILOGE("Invalid peerNetworkId:%{public}s", remoteNetworkId.c_str());
return RET_ERR;

View File

@ -384,7 +384,7 @@ void DeviceStatusDumper::CheckDefineOutput(int32_t fd, const char* fmt, Ts... ar
{
CALL_DEBUG_ENTER;
CHKPV(fmt);
char buf[MAX_PACKET_BUF_SIZE] = {};
char buf[MAX_PACKET_BUF_SIZE] = { 0 };
int32_t ret = snprintf_s(buf, MAX_PACKET_BUF_SIZE, MAX_PACKET_BUF_SIZE - 1, fmt, args...);
if (ret == -1) {
FI_HILOGE("Call snprintf_s failed, ret:%{public}d", ret);

View File

@ -350,7 +350,7 @@ ErrCode DeviceStatusMsdpClientImpl::LoadMockLibrary()
return RET_OK;
}
std::string dlName = DEVICESTATUS_MOCK_LIB_PATH;
char libRealPath[PATH_MAX] = {};
char libRealPath[PATH_MAX] = { 0 };
if (realpath(dlName .c_str(), libRealPath) == nullptr) {
FI_HILOGE("Get absolute algoPath is error, errno:%{public}d", errno);
return RET_ERR;
@ -413,7 +413,7 @@ ErrCode DeviceStatusMsdpClientImpl::LoadAlgoLibrary()
return RET_OK;
}
std::string dlName = DEVICESTATUS_ALGO_LIB_PATH;
char libRealPath[PATH_MAX] = {};
char libRealPath[PATH_MAX] = { 0 };
if (realpath(dlName .c_str(), libRealPath) == nullptr) {
FI_HILOGE("Get absolute algoPath is error, errno:%{public}d", errno);
return RET_ERR;

View File

@ -215,7 +215,7 @@ void StreamServer::OnEpollRecv(int32_t fd, epoll_event &ev)
return;
}
auto& buf = circleBufs_[fd];
char szBuf[MAX_PACKET_BUF_SIZE] = {};
char szBuf[MAX_PACKET_BUF_SIZE] = { 0 };
for (int32_t i = 0; i < MAX_RECV_LIMIT; i++) {
ssize_t size = recv(fd, szBuf, MAX_PACKET_BUF_SIZE, MSG_DONTWAIT | MSG_NOSIGNAL);
if (size > 0) {

View File

@ -54,7 +54,7 @@ static std::string GetThisThreadIdOfString()
thread_local std::string threadLocalId;
if (threadLocalId.empty()) {
long tid = syscall(SYS_gettid);
char buf[BUF_TID_SIZE] = {};
char buf[BUF_TID_SIZE] = { 0 };
const int32_t ret = sprintf_s(buf, BUF_TID_SIZE, "%06d", tid);
if (ret < 0) {
FI_HILOGE("Call sprintf_s failed, ret:%{public}d", ret);
@ -189,7 +189,7 @@ static std::string GetFileName(const std::string &path)
const char* GetProgramName()
{
static char programName[PROGRAM_NAME_SIZE] = {};
static char programName[PROGRAM_NAME_SIZE] = { 0 };
if (programName[0] != '\0') {
return programName;
}
@ -268,7 +268,7 @@ bool IsValidSvgFile(const std::string &filePath)
FI_HILOGE("FilePath is empty");
return false;
}
char realPath[PATH_MAX] = {};
char realPath[PATH_MAX] = { 0 };
if (realpath(filePath.c_str(), realPath) == nullptr) {
FI_HILOGE("Realpath return nullptr, realPath:%{public}s", realPath);
return false;