提交 63c5763c 编写于 作者: W wangyulie

修改codecheck告警

Signed-off-by: Nwangyulie <wanglieyu@126.com>
上级 cf239447
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
#include <string> #include <string>
#include <unistd.h> #include <unistd.h>
void my_print(void* arg) void MyPrint(void* arg)
{ {
OH_LOG_Print(LOG_APP, LOG_INFO, 1, "testFFRT", "%{public}s", "hello ffrt\n"); OH_LOG_Print(LOG_APP, LOG_INFO, 1, "testFFRT", "%{public}s", "hello ffrt\n");
} }
...@@ -48,17 +48,17 @@ typedef struct { ...@@ -48,17 +48,17 @@ typedef struct {
ffrt_function_t func; ffrt_function_t func;
ffrt_function_t after_func; ffrt_function_t after_func;
void* arg; void* arg;
} c_function; } CFunction;
typedef struct { typedef struct {
ffrt_cond_t* cond; ffrt_cond_t* cond;
int* a; int* a;
ffrt_mutex_t* lock_; ffrt_mutex_t* lock_;
} tuple; } FfrtTuple;
void func1(void* arg) void Func1(void* arg)
{ {
tuple* t = (tuple*)arg; FfrtTuple* t = (FfrtTuple*)arg;
int ret = ffrt_mutex_lock(t->lock_); int ret = ffrt_mutex_lock(t->lock_);
if (ret != ffrt_success) { if (ret != ffrt_success) {
printf("error\n"); printf("error\n");
...@@ -81,9 +81,9 @@ void func1(void* arg) ...@@ -81,9 +81,9 @@ void func1(void* arg)
printf("a = %d", *(t->a)); printf("a = %d", *(t->a));
} }
void func2(void* arg) void Func2(void* arg)
{ {
tuple* t = (tuple*)arg; FfrtTuple* t = (FfrtTuple*)arg;
int ret = ffrt_mutex_lock(t->lock_); int ret = ffrt_mutex_lock(t->lock_);
if (ret != ffrt_success) { if (ret != ffrt_success) {
printf("error\n"); printf("error\n");
...@@ -99,9 +99,9 @@ void func2(void* arg) ...@@ -99,9 +99,9 @@ void func2(void* arg)
} }
} }
void func3(void* arg) void Func3(void* arg)
{ {
tuple* t = (tuple*)arg; FfrtTuple* t = (FfrtTuple*)arg;
int ret = ffrt_mutex_trylock(t->lock_); int ret = ffrt_mutex_trylock(t->lock_);
if (ret != ffrt_success) { if (ret != ffrt_success) {
printf("error\n"); printf("error\n");
...@@ -127,17 +127,17 @@ void func3(void* arg) ...@@ -127,17 +127,17 @@ void func3(void* arg)
printf("a = %d", *(t->a)); printf("a = %d", *(t->a));
} }
static void ffrt_exec_function_wrapper(void* t) static void FfrtExecFunctionWrapper(void* t)
{ {
c_function* f = (c_function*)t; CFunction* f = (CFunction*)t;
if (f->func) { if (f->func) {
f->func(f->arg); f->func(f->arg);
} }
} }
static void ffrt_destroy_function_wrapper(void* t) static void FfrtDestroyFunctionWrapper(void* t)
{ {
c_function* f = (c_function*)t; CFunction* f = (CFunction*)t;
if (f->after_func) { if (f->after_func) {
f->after_func(f->arg); f->after_func(f->arg);
} }
...@@ -147,11 +147,11 @@ static void ffrt_destroy_function_wrapper(void* t) ...@@ -147,11 +147,11 @@ static void ffrt_destroy_function_wrapper(void* t)
static inline ffrt_function_header_t* ffrt_create_function_wrapper(const ffrt_function_t func, static inline ffrt_function_header_t* ffrt_create_function_wrapper(const ffrt_function_t func,
const ffrt_function_t after_func, void* arg, ffrt_function_kind_t kind_t = ffrt_function_kind_general) const ffrt_function_t after_func, void* arg, ffrt_function_kind_t kind_t = ffrt_function_kind_general)
{ {
FFRT_STATIC_ASSERT(sizeof(c_function) <= ffrt_auto_managed_function_storage_size, FFRT_STATIC_ASSERT(sizeof(CFunction) <= ffrt_auto_managed_function_storage_size,
size_of_function_must_be_less_than_ffrt_auto_managed_function_storage_size); size_of_function_must_be_less_than_ffrt_auto_managed_function_storage_size);
c_function* f = (c_function*)ffrt_alloc_auto_managed_function_storage_base(kind_t); CFunction* f = (CFunction*)ffrt_alloc_auto_managed_function_storage_base(kind_t);
f->header.exec = ffrt_exec_function_wrapper; f->header.exec = FfrtExecFunctionWrapper;
f->header.destroy = ffrt_destroy_function_wrapper; f->header.destroy = FfrtDestroyFunctionWrapper;
f->func = func; f->func = func;
f->after_func = after_func; f->after_func = after_func;
f->arg = arg; f->arg = arg;
...@@ -170,7 +170,7 @@ static inline ffrt_task_handle_t ffrt_submit_h_c(ffrt_function_t func, const ffr ...@@ -170,7 +170,7 @@ static inline ffrt_task_handle_t ffrt_submit_h_c(ffrt_function_t func, const ffr
return ffrt_submit_h_base(ffrt_create_function_wrapper(func, after_func, arg), in_deps, out_deps, attr); return ffrt_submit_h_base(ffrt_create_function_wrapper(func, after_func, arg), in_deps, out_deps, attr);
} }
void ffrt_cv_task(void* arg) void FfrtCvTask(void* arg)
{ {
int* a = (int*) arg; int* a = (int*) arg;
ffrt_cond_t cond; ffrt_cond_t cond;
...@@ -179,14 +179,14 @@ void ffrt_cv_task(void* arg) ...@@ -179,14 +179,14 @@ void ffrt_cv_task(void* arg)
printf("error\n"); printf("error\n");
} }
ffrt_mutex_t lock_; ffrt_mutex_t lock_;
tuple t = {&cond, a, &lock_}; FfrtTuple t = {&cond, a, &lock_};
ret = ffrt_mutex_init(&lock_, NULL); ret = ffrt_mutex_init(&lock_, NULL);
if (ret != ffrt_success) { if (ret != ffrt_success) {
printf("error\n"); printf("error\n");
} }
ffrt_submit_c(func1, NULL, &t, NULL, NULL, NULL); ffrt_submit_c(Func1, NULL, &t, NULL, NULL, NULL);
ffrt_submit_c(func2, NULL, &t, NULL, NULL, NULL); ffrt_submit_c(Func2, NULL, &t, NULL, NULL, NULL);
ffrt_submit_c(func3, NULL, &t, NULL, NULL, NULL); ffrt_submit_c(Func3, NULL, &t, NULL, NULL, NULL);
ffrt_wait(); ffrt_wait();
ffrt_cond_destroy(&cond); ffrt_cond_destroy(&cond);
ffrt_mutex_destroy(&lock_); ffrt_mutex_destroy(&lock_);
...@@ -206,7 +206,7 @@ static napi_value SubmitSimpleFfrtTask(napi_env env, napi_callback_info info) ...@@ -206,7 +206,7 @@ static napi_value SubmitSimpleFfrtTask(napi_env env, napi_callback_info info)
OH_LOG_Print(LOG_APP, LOG_INFO, 1, "testFFRT", "qos is %{public}d", ffrt_task_attr_get_qos(&attr)); OH_LOG_Print(LOG_APP, LOG_INFO, 1, "testFFRT", "qos is %{public}d", ffrt_task_attr_get_qos(&attr));
ffrt_task_attr_set_qos(&attr, static_cast<ffrt_qos_t>(ffrt_qos_user_initiated)); ffrt_task_attr_set_qos(&attr, static_cast<ffrt_qos_t>(ffrt_qos_user_initiated));
OH_LOG_Print(LOG_APP, LOG_INFO, 1, "testFFRT", "qos2 is %{public}d", ffrt_task_attr_get_qos(&attr)); OH_LOG_Print(LOG_APP, LOG_INFO, 1, "testFFRT", "qos2 is %{public}d", ffrt_task_attr_get_qos(&attr));
ffrt_submit_c(my_print, NULL, NULL, NULL, NULL, &attr); ffrt_submit_c(MyPrint, NULL, NULL, NULL, NULL, &attr);
int result = ffrt_this_task_update_qos(static_cast<ffrt_qos_t>(ffrt_qos_default)); int result = ffrt_this_task_update_qos(static_cast<ffrt_qos_t>(ffrt_qos_default));
OH_LOG_Print(LOG_APP, LOG_INFO, 1, "testFFRT", "update_qos result is %{public}d", result); OH_LOG_Print(LOG_APP, LOG_INFO, 1, "testFFRT", "update_qos result is %{public}d", result);
OH_LOG_Print(LOG_APP, LOG_INFO, 1, "testFFRT", "qos3 is %{public}d", ffrt_task_attr_get_qos(&attr)); OH_LOG_Print(LOG_APP, LOG_INFO, 1, "testFFRT", "qos3 is %{public}d", ffrt_task_attr_get_qos(&attr));
...@@ -223,8 +223,8 @@ static napi_value SubmitSimpleFfrtTask(napi_env env, napi_callback_info info) ...@@ -223,8 +223,8 @@ static napi_value SubmitSimpleFfrtTask(napi_env env, napi_callback_info info)
static napi_value SubmitCondFfrtTask(napi_env env, napi_callback_info info) static napi_value SubmitCondFfrtTask(napi_env env, napi_callback_info info)
{ {
int a = 0; int a = 0;
ffrt_submit_c(ffrt_cv_task, NULL, &a, NULL, NULL, NULL); ffrt_submit_c(FfrtCvTask, NULL, &a, NULL, NULL, NULL);
ffrt_task_handle_t task1 = ffrt_submit_h_c(my_print, NULL, NULL, NULL, NULL, NULL); ffrt_task_handle_t task1 = ffrt_submit_h_c(MyPrint, NULL, NULL, NULL, NULL, NULL);
ffrt_wait_deps(nullptr); ffrt_wait_deps(nullptr);
ffrt_wait(); ffrt_wait();
OH_LOG_Print(LOG_APP, LOG_INFO, 1, "testFFRT", "cond task a is %{public}d", a); OH_LOG_Print(LOG_APP, LOG_INFO, 1, "testFFRT", "cond task a is %{public}d", a);
...@@ -241,17 +241,23 @@ static napi_value SubmitQueueFfrtTask(napi_env env, napi_callback_info info) ...@@ -241,17 +241,23 @@ static napi_value SubmitQueueFfrtTask(napi_env env, napi_callback_info info)
ffrt_queue_attr_t queue_attr; ffrt_queue_attr_t queue_attr;
(void)ffrt_queue_attr_init(&queue_attr); (void)ffrt_queue_attr_init(&queue_attr);
ffrt_queue_attr_set_qos(&queue_attr, ffrt_qos_default); ffrt_queue_attr_set_qos(&queue_attr, ffrt_qos_default);
OH_LOG_Print(LOG_APP, LOG_INFO, 1, "testFFRT", "queue task qos is %{public}d", ffrt_queue_attr_get_qos(&queue_attr)); OH_LOG_Print(LOG_APP, LOG_INFO, 1, "testFFRT", "queue task qos is %{public}d",
ffrt_queue_attr_get_qos(&queue_attr));
ffrt_queue_attr_set_timeout(&queue_attr, 10000); ffrt_queue_attr_set_timeout(&queue_attr, 10000);
OH_LOG_Print(LOG_APP, LOG_INFO, 1, "testFFRT", "queue task time is %{public}d", ffrt_queue_attr_get_timeout(&queue_attr)); OH_LOG_Print(LOG_APP, LOG_INFO, 1, "testFFRT", "queue task time is %{public}d",
ffrt_queue_attr_set_callback(&queue_attr, ffrt_create_function_wrapper(OnePlusForTest, NULL, &b, ffrt_function_kind_queue)); ffrt_queue_attr_get_timeout(&queue_attr));
ffrt_queue_attr_set_callback(&queue_attr,
ffrt_create_function_wrapper(OnePlusForTest, NULL, &b, ffrt_function_kind_queue));
ffrt_queue_attr_get_callback(&queue_attr); ffrt_queue_attr_get_callback(&queue_attr);
ffrt_queue_t queue_handle = ffrt_queue_create(ffrt_queue_serial, "test_queue", &queue_attr); ffrt_queue_t queue_handle = ffrt_queue_create(ffrt_queue_serial, "test_queue", &queue_attr);
ffrt_task_handle_t task1 = ffrt_queue_submit_h(queue_handle, ffrt_create_function_wrapper(OnePlusForTest, NULL, &a, ffrt_function_kind_queue), nullptr); ffrt_task_handle_t task1 = ffrt_queue_submit_h(queue_handle,
ffrt_create_function_wrapper(OnePlusForTest, NULL, &a, ffrt_function_kind_queue), nullptr);
ffrt_queue_cancel(task1); ffrt_queue_cancel(task1);
ffrt_queue_wait(task1); ffrt_queue_wait(task1);
ffrt_queue_submit(queue_handle, ffrt_create_function_wrapper(MulipleForTest, nullptr, &a, ffrt_function_kind_queue), nullptr); ffrt_queue_submit(queue_handle,
ffrt_queue_submit(queue_handle, ffrt_create_function_wrapper(SubForTest, nullptr, &a, ffrt_function_kind_queue), nullptr); ffrt_create_function_wrapper(MulipleForTest, nullptr, &a, ffrt_function_kind_queue), nullptr);
ffrt_queue_submit(queue_handle,
ffrt_create_function_wrapper(SubForTest, nullptr, &a, ffrt_function_kind_queue), nullptr);
sleep(2); sleep(2);
OH_LOG_Print(LOG_APP, LOG_INFO, 1, "testFFRT", "queue task a is %{public}d", a); OH_LOG_Print(LOG_APP, LOG_INFO, 1, "testFFRT", "queue task a is %{public}d", a);
OH_LOG_Print(LOG_APP, LOG_INFO, 1, "testFFRT", "queue task b is %{public}d", b); OH_LOG_Print(LOG_APP, LOG_INFO, 1, "testFFRT", "queue task b is %{public}d", b);
......
@rem Copyright (c) 2023 Huawei Device Co., Ltd.
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem http://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@if "%DEBUG%" == "" @echo off @if "%DEBUG%" == "" @echo off
@rem # Copyright (c) 2022 Huawei Device Co., Ltd.
@rem # Licensed under the Apache License, Version 2.0 (the "License");
@rem # you may not use this file except in compliance with the License.
@rem # You may obtain a copy of the License at
@rem #
@rem # http://www.apache.org/licenses/LICENSE-2.0
@rem #
@rem # Unless required by applicable law or agreed to in writing, software
@rem # distributed under the License is distributed on an "AS IS" BASIS,
@rem # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem # See the License for the specific language governing permissions and
@rem # limitations under the License.
@rem ########################################################################## @rem ##########################################################################
@rem @rem
@rem Hvigor startup script for Windows @rem Hvigor startup script for Windows
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册