提交 1756b289 编写于 作者: C chengjinsong

codex

Signed-off-by: Nchengjinsong <chengjinsong2@huawei.com>
上级 702e2df0
...@@ -183,7 +183,7 @@ INIT_LOCAL_API int GetDevUdid_(char *udid, int size) ...@@ -183,7 +183,7 @@ INIT_LOCAL_API int GetDevUdid_(char *udid, int size)
return EC_FAILURE; return EC_FAILURE;
} }
uint32_t len = size; uint32_t len = (uint32_t)size;
int ret = SystemGetParameter("const.product.udid", udid, &len); int ret = SystemGetParameter("const.product.udid", udid, &len);
BEGET_CHECK(ret != 0, return ret); BEGET_CHECK(ret != 0, return ret);
......
...@@ -107,13 +107,13 @@ static void SetCallbackWork(napi_env env, StorageAsyncContextPtr asyncContext) ...@@ -107,13 +107,13 @@ static void SetCallbackWork(napi_env env, StorageAsyncContextPtr asyncContext)
napi_create_async_work( napi_create_async_work(
env, nullptr, resource, env, nullptr, resource,
[](napi_env env, void *data) { [](napi_env env, void *data) {
StorageAsyncContext *asyncContext = (StorageAsyncContext *)data; StorageAsyncContext *asyncContext = reinterpret_cast<StorageAsyncContext *>(data);
asyncContext->status = SetParameter(asyncContext->key, asyncContext->value); asyncContext->status = SetParameter(asyncContext->key, asyncContext->value);
PARAM_JS_LOGV("JSApp set status: %d, key: '%s', value: '%s'.", PARAM_JS_LOGV("JSApp set status: %d, key: '%s', value: '%s'.",
asyncContext->status, asyncContext->key, asyncContext->value); asyncContext->status, asyncContext->key, asyncContext->value);
}, },
[](napi_env env, napi_status status, void *data) { [](napi_env env, napi_status status, void *data) {
StorageAsyncContext *asyncContext = (StorageAsyncContext *)data; StorageAsyncContext *asyncContext = reinterpret_cast<StorageAsyncContext *>(data);
napi_value result[ARGC_NUMBER] = { 0 }; napi_value result[ARGC_NUMBER] = { 0 };
if (asyncContext->status == 0) { if (asyncContext->status == 0) {
napi_get_undefined(env, &result[0]); napi_get_undefined(env, &result[0]);
...@@ -139,7 +139,7 @@ static void SetCallbackWork(napi_env env, StorageAsyncContextPtr asyncContext) ...@@ -139,7 +139,7 @@ static void SetCallbackWork(napi_env env, StorageAsyncContextPtr asyncContext)
napi_delete_async_work(env, asyncContext->work); napi_delete_async_work(env, asyncContext->work);
delete asyncContext; delete asyncContext;
}, },
(void *)asyncContext, &asyncContext->work); reinterpret_cast<void *>(asyncContext), &asyncContext->work);
napi_queue_async_work(env, asyncContext->work); napi_queue_async_work(env, asyncContext->work);
} }
...@@ -285,7 +285,7 @@ static void GetCallbackWork(napi_env env, StorageAsyncContextPtr asyncContext) ...@@ -285,7 +285,7 @@ static void GetCallbackWork(napi_env env, StorageAsyncContextPtr asyncContext)
napi_create_async_work( napi_create_async_work(
env, nullptr, resource, env, nullptr, resource,
[](napi_env env, void *data) { [](napi_env env, void *data) {
StorageAsyncContext *asyncContext = (StorageAsyncContext *)data; StorageAsyncContext *asyncContext = reinterpret_cast<StorageAsyncContext *>(data);
std::vector<char> value(MAX_VALUE_LENGTH, 0); std::vector<char> value(MAX_VALUE_LENGTH, 0);
asyncContext->status = GetParameter(asyncContext->key, asyncContext->status = GetParameter(asyncContext->key,
(asyncContext->valueLen == 0) ? nullptr : asyncContext->value, value.data(), MAX_VALUE_LENGTH); (asyncContext->valueLen == 0) ? nullptr : asyncContext->value, value.data(), MAX_VALUE_LENGTH);
...@@ -294,7 +294,7 @@ static void GetCallbackWork(napi_env env, StorageAsyncContextPtr asyncContext) ...@@ -294,7 +294,7 @@ static void GetCallbackWork(napi_env env, StorageAsyncContextPtr asyncContext)
asyncContext->status, asyncContext->key, asyncContext->getValue.c_str(), asyncContext->value); asyncContext->status, asyncContext->key, asyncContext->getValue.c_str(), asyncContext->value);
}, },
[](napi_env env, napi_status status, void *data) { [](napi_env env, napi_status status, void *data) {
StorageAsyncContext *asyncContext = (StorageAsyncContext *)data; StorageAsyncContext *asyncContext = reinterpret_cast<StorageAsyncContext *>(data);
napi_value result[ARGC_NUMBER] = { 0 }; napi_value result[ARGC_NUMBER] = { 0 };
if (asyncContext->status > 0) { if (asyncContext->status > 0) {
napi_get_undefined(env, &result[0]); napi_get_undefined(env, &result[0]);
...@@ -321,7 +321,7 @@ static void GetCallbackWork(napi_env env, StorageAsyncContextPtr asyncContext) ...@@ -321,7 +321,7 @@ static void GetCallbackWork(napi_env env, StorageAsyncContextPtr asyncContext)
napi_delete_async_work(env, asyncContext->work); napi_delete_async_work(env, asyncContext->work);
delete asyncContext; delete asyncContext;
}, },
(void *)asyncContext, &asyncContext->work); reinterpret_cast<void *>(asyncContext), &asyncContext->work);
napi_queue_async_work(env, asyncContext->work); napi_queue_async_work(env, asyncContext->work);
} }
......
...@@ -570,7 +570,6 @@ class GenBpfPolicy: ...@@ -570,7 +570,6 @@ class GenBpfPolicy:
return bpf_policy return bpf_policy
#parse (argn & mask) == value
def compile_mask_equal_atom(self, atom, cur_size): def compile_mask_equal_atom(self, atom, cur_size):
bpf_policy = [] bpf_policy = []
left_brace_pos = atom.find('(') left_brace_pos = atom.find('(')
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
int ret = 0;
int sockFd = GetControlSocket("serversock"); int sockFd = GetControlSocket("serversock");
if (sockFd < 0) { if (sockFd < 0) {
INIT_LOGE("Failed to get server socket"); INIT_LOGE("Failed to get server socket");
...@@ -28,8 +27,7 @@ int main(int argc, char* argv[]) ...@@ -28,8 +27,7 @@ int main(int argc, char* argv[])
} }
char buffer[MAX_BUFFER_SIZE] = { 0 }; char buffer[MAX_BUFFER_SIZE] = { 0 };
while (1) { while (1) {
ret = read(sockFd, buffer, sizeof(buffer) - 1); if (read(sockFd, buffer, sizeof(buffer) - 1) > 0) {
if (ret > 0) {
INIT_LOGI("Read message: %s", buffer); INIT_LOGI("Read message: %s", buffer);
(void)memset_s(buffer, MAX_BUFFER_SIZE, 0, MAX_BUFFER_SIZE); (void)memset_s(buffer, MAX_BUFFER_SIZE, 0, MAX_BUFFER_SIZE);
} }
......
...@@ -40,7 +40,7 @@ namespace OHOS { ...@@ -40,7 +40,7 @@ namespace OHOS {
CloseStdout(); CloseStdout();
Cookie instance = {0, nullptr}; Cookie instance = {0, nullptr};
Cookie *cookie = &instance; Cookie *cookie = &instance;
if (size <= 0) { if (size == 0) {
return false; return false;
} }
if (size > PARAM_CONST_VALUE_LEN_MAX + PARAM_NAME_LEN_MAX) { if (size > PARAM_CONST_VALUE_LEN_MAX + PARAM_NAME_LEN_MAX) {
......
...@@ -198,8 +198,8 @@ public: ...@@ -198,8 +198,8 @@ public:
LE_BaseInfo info = {TASK_EVENT, NULL}; LE_BaseInfo info = {TASK_EVENT, NULL};
int testfd = 65535; // 65535 is not exist fd int testfd = 65535; // 65535 is not exist fd
BaseTask *task = CreateTask(LE_GetDefaultLoop(), testfd, &info, sizeof(StreamClientTask)); BaseTask *task = CreateTask(LE_GetDefaultLoop(), testfd, &info, sizeof(StreamClientTask));
task->handleEvent = TestHandleTaskEvent;
if (task != nullptr) { if (task != nullptr) {
task->handleEvent = TestHandleTaskEvent;
ProcessEvent((EventLoop *)LE_GetDefaultLoop(), testfd, Event_Read); ProcessEvent((EventLoop *)LE_GetDefaultLoop(), testfd, Event_Read);
} }
((HashTab *)(((EventLoop *)LE_GetDefaultLoop())->taskMap))->nodeFree(&task->hashNode); ((HashTab *)(((EventLoop *)LE_GetDefaultLoop())->taskMap))->nodeFree(&task->hashNode);
......
...@@ -155,6 +155,7 @@ bool MakeFileByJson(cJSON * mJson, const char *sandboxFileName) ...@@ -155,6 +155,7 @@ bool MakeFileByJson(cJSON * mJson, const char *sandboxFileName)
int ret1 = write(fd, cjValue1, strlen(cjValue1)); int ret1 = write(fd, cjValue1, strlen(cjValue1));
if (-1 == ret1) { if (-1 == ret1) {
std::cout << "Write file ERROR" << errno << " fd is :" << fd << std::endl; std::cout << "Write file ERROR" << errno << " fd is :" << fd << std::endl;
close(fd);
return false; return false;
} }
free(cjValue1); free(cjValue1);
......
...@@ -110,6 +110,7 @@ static void TestPermission() ...@@ -110,6 +110,7 @@ static void TestPermission()
int ret; int ret;
ParamSecurityOps *paramSecurityOps = GetParamSecurityOps(0); ParamSecurityOps *paramSecurityOps = GetParamSecurityOps(0);
EXPECT_NE(paramSecurityOps, nullptr);
paramSecurityOps->securityCheckParamPermission = TestCheckParamPermission; paramSecurityOps->securityCheckParamPermission = TestCheckParamPermission;
SetTestPermissionResult(DAC_RESULT_FORBIDED); SetTestPermissionResult(DAC_RESULT_FORBIDED);
if ((GetParamSecurityLabel() != nullptr)) { if ((GetParamSecurityLabel() != nullptr)) {
......
...@@ -55,7 +55,7 @@ static int TestGenHashCode(const char *buff) ...@@ -55,7 +55,7 @@ static int TestGenHashCode(const char *buff)
static void TestSetSelinuxLogCallback(void) {} static void TestSetSelinuxLogCallback(void) {}
static const char *forbidWriteParamName[] = { static const char *g_forbidWriteParamName[] = {
"ohos.servicectrl.", "ohos.servicectrl.",
"test.permission.read", "test.permission.read",
"test.persmission.watch" "test.persmission.watch"
...@@ -64,8 +64,8 @@ static const char *forbidWriteParamName[] = { ...@@ -64,8 +64,8 @@ static const char *forbidWriteParamName[] = {
static int TestSetParamCheck(const char *paraName, const char *context, const SrcInfo *info) static int TestSetParamCheck(const char *paraName, const char *context, const SrcInfo *info)
{ {
// forbid to read ohos.servicectrl. // forbid to read ohos.servicectrl.
for (size_t i = 0; i < ARRAY_LENGTH(forbidWriteParamName); i++) { for (size_t i = 0; i < ARRAY_LENGTH(g_forbidWriteParamName); i++) {
if (strncmp(paraName, forbidWriteParamName[i], strlen(forbidWriteParamName[i])) == 0) { if (strncmp(paraName, g_forbidWriteParamName[i], strlen(g_forbidWriteParamName[i])) == 0) {
return g_testPermissionResult; return g_testPermissionResult;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册