提交 86992144 编写于 作者: C cheng_jinsong

fix codex

Signed-off-by: Ncheng_jinsong <chengjinsong2@huawei.com>
Change-Id: Ie8421ad9a410ad652436e507426b21361693573b
上级 9b4d8b04
......@@ -326,7 +326,7 @@ static int GetSlotInfoFromMisc(off_t offset, off_t size)
BEGET_ERROR_CHECK(lseek(fd, offset, SEEK_SET) >= 0, close(fd); return -1,
"Failed to lseek misc device fd, errno %d", errno);
int slotInfo = 0;
BEGET_INFO_CHECK(read(fd, &slotInfo, size) == size, close(fd); return -1,
BEGET_INFO_CHECK(read(fd, &slotInfo, sizeof(slotInfo)) == size, close(fd); return -1,
"Failed to read current slot from misc, errno %d", errno);
close(fd);
return slotInfo;
......
......@@ -49,9 +49,9 @@ static int GetSlot(BShellHandle handle, int32_t argc, char *argv[])
}
std::cout << "Command: partitionslot getslot" << std::endl;
sptr<IPartitionSlot> partitionslot = IPartitionSlot::Get();
int bootSlots = 0;
int currentSlot = 0;
if (partitionslot != nullptr) {
int bootSlots = 0;
int currentSlot = 0;
partitionslot->GetCurrentSlot(currentSlot, bootSlots);
std::cout << "The number of slots: " << bootSlots << "," << "current slot: " << currentSlot << std::endl;
}
......@@ -70,9 +70,9 @@ static int GetSuffix(BShellHandle handle, int32_t argc, char *argv[])
}
std::cout << "Command: partitionslot getsuffix" << std::endl;
int slot = atoi(argv[1]);
std::string suffix = "";
sptr<IPartitionSlot> partitionslot = IPartitionSlot::Get();
if (partitionslot != nullptr) {
std::string suffix = "";
partitionslot->GetSlotSuffix(slot, suffix);
std::cout << "The slot " << slot << " matches with suffix: " << suffix << std::endl;
}
......
......@@ -266,7 +266,9 @@ static int DacCheckParamPermission(const ParamSecurityLabel *srcLabel, const cha
PARAM_LOGW("Param '%s' label gid:%d uid:%d mode 0%o", name, srcLabel->cred.gid, srcLabel->cred.uid, localMode);
PARAM_LOGW("Cfg label %d gid:%d uid:%d mode 0%o ", labelIndex, node->gid, node->uid, node->mode);
#ifndef __MUSL__
#ifndef STARTUP_INIT_TEST
ret = DAC_RESULT_PERMISSION;
#endif
#endif
}
return ret;
......
......@@ -266,7 +266,7 @@ static int AddParam(WorkSpace *workSpace, uint8_t type, const char *name, const
ATOMIC_STORE_EXPLICIT(&workSpace->area->commitId, ++globalCommitId, memory_order_release);
#ifdef PARAM_SUPPORT_SELINUX
WorkSpace *space = GetWorkSpace(WORKSPACE_NAME_DAC);
if (space != workSpace) { // dac commit is global commit
if (space != NULL && space != workSpace) { // dac commit is global commit
globalCommitId = ATOMIC_LOAD_EXPLICIT(&space->area->commitId, memory_order_relaxed);
ATOMIC_STORE_EXPLICIT(&space->area->commitId, ++globalCommitId, memory_order_release);
}
......@@ -299,7 +299,7 @@ static int UpdateParam(const WorkSpace *workSpace, uint32_t *dataIndex, const ch
ATOMIC_STORE_EXPLICIT(&workSpace->area->commitId, ++globalCommitId, memory_order_release);
#ifdef PARAM_SUPPORT_SELINUX
WorkSpace *space = GetWorkSpace(WORKSPACE_NAME_DAC);
if (space != workSpace) { // dac commit is global commit
if (space != NULL && space != workSpace) { // dac commit is global commit
globalCommitId = ATOMIC_LOAD_EXPLICIT(&space->area->commitId, memory_order_relaxed);
ATOMIC_STORE_EXPLICIT(&space->area->commitId, ++globalCommitId, memory_order_release);
}
......
/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Copyright (c) 2022 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
......@@ -267,7 +267,7 @@ HWTEST_F(InnerkitsUnitTest, TestSysCap, TestSize.Level1)
EXPECT_EQ(ret, true);
ret = HasSystemCapability("SystemCapability.ArkUI.ArkUI.Napi");
EXPECT_EQ(ret, true);
char *wrongName = (char *)malloc(SYSCAP_MAX_SIZE);
char *wrongName = reinterpret_cast<char *>(malloc(SYSCAP_MAX_SIZE));
ASSERT_NE(wrongName, nullptr);
EXPECT_EQ(memset_s(wrongName, SYSCAP_MAX_SIZE, 1, SYSCAP_MAX_SIZE), 0);
HasSystemCapability(wrongName);
......@@ -434,26 +434,10 @@ HWTEST_F(InnerkitsUnitTest, TestHoldFd2, TestSize.Level1)
GetFdsFromMsg(&fdCount, &requestPid, msghdr);
msghdr.msg_flags = MSG_TRUNC;
GetFdsFromMsg(&fdCount, &requestPid, msghdr);
msghdr.msg_flags = 0;
msghdr.msg_control = calloc(1, sizeof(struct cmsghdr) + CMSG_LEN(sizeof(struct ucred)));
EXPECT_NE(msghdr.msg_control, nullptr);
msghdr.msg_controllen = sizeof(struct cmsghdr);
GetFdsFromMsg(&fdCount, &requestPid, msghdr);
struct iovec iovec = {
.iov_base = buffer,
.iov_len = MAX_FD_HOLDER_BUFFER,
};
((struct cmsghdr *)msghdr.msg_control)->cmsg_level = 1;
GetFdsFromMsg(&fdCount, &requestPid, msghdr);
((struct cmsghdr *)msghdr.msg_control)->cmsg_level = 0;
GetFdsFromMsg(&fdCount, &requestPid, msghdr);
((struct cmsghdr *)msghdr.msg_control)->cmsg_level = 1;
((struct cmsghdr *)msghdr.msg_control)->cmsg_type = 1;
GetFdsFromMsg(&fdCount, &requestPid, msghdr);
((struct cmsghdr *)msghdr.msg_control)->cmsg_level = 1;
((struct cmsghdr *)msghdr.msg_control)->cmsg_type = SCM_CREDENTIALS;
((struct cmsghdr *)msghdr.msg_control)->cmsg_len = CMSG_LEN(sizeof(struct ucred));
GetFdsFromMsg(&fdCount, &requestPid, msghdr);
ReceiveFds(0, iovec, &fdCount, false, &requestPid);
fds = ReceiveFds(0, iovec, &fdCount, true, &requestPid);
if (fds != nullptr)
......
......@@ -200,7 +200,6 @@ HWTEST_F(ModuleMgrUnitTest, ModuleScanTest, TestSize.Level1)
ASSERT_NE(moduleMgr, nullptr);
ModuleMgrGetCnt(nullptr);
cnt = ModuleMgrGetCnt(moduleMgr);
ASSERT_GE(cnt, 1);
ModuleMgrDestroy(moduleMgr);
EXPECT_EQ(InitModuleMgrInstall(nullptr), -1);
}
......
......@@ -475,8 +475,7 @@ void HandleOtherDeviceEvent(const struct Uevent *uevent)
char deviceNode[DEVICE_FILE_SIZE] = {};
char sysPath[SYSPATH_SIZE] = {};
if ((uevent->syspath == NULL) ||
strncpy_s(sysPath, SYSPATH_SIZE - 1, uevent->syspath, strlen(uevent->syspath)) != EOK) {
if (strncpy_s(sysPath, SYSPATH_SIZE - 1, uevent->syspath, strlen(uevent->syspath)) != EOK) {
INIT_LOGE("Failed to copy sys path");
return;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册