[PATCH] uadk: Fix static analysis warning
From: Zongyu Wu <wuzongyu1@huawei.com> Fix compilation warning in the UADK module regarding an unused variable. Signed-off-by: Zongyu Wu <wuzongyu1@huawei.com> --- v1/test/hisi_zip_test_sgl/wd_sched_sgl.c | 8 ++--- v1/test/test_mm/test_wd_mem.c | 4 +-- v1/test/wd_sched.c | 1 - wd_util.c | 42 ++++++++++++++++-------- 4 files changed, 33 insertions(+), 22 deletions(-) diff --git a/v1/test/hisi_zip_test_sgl/wd_sched_sgl.c b/v1/test/hisi_zip_test_sgl/wd_sched_sgl.c index 7a3be22..21ec30c 100644 --- a/v1/test/hisi_zip_test_sgl/wd_sched_sgl.c +++ b/v1/test/hisi_zip_test_sgl/wd_sched_sgl.c @@ -27,7 +27,6 @@ static int wd_sched_pre_uninit(struct wd_scheduler *sched, int data_fmt) { unsigned int flags = 0; struct q_info *qinfo; - void *pool; int i; qinfo = sched->qs[0].qinfo; @@ -54,12 +53,13 @@ static int wd_sched_pre_uninit(struct wd_scheduler *sched, int data_fmt) static int wd_sched_preinit(struct wd_scheduler *sched, int data_fmt) { - int ret, i, j; unsigned int flags = 0; struct q_info *qinfo; struct wd_blkpool_setup mm_setup; struct wd_sglpool_setup sp; void *pool; + int ret, j; + int i = 0; if (!sched->ss_region_size) sched->ss_region_size = EXTRA_SIZE + /* add 1 page extra */ @@ -260,9 +260,7 @@ err_with_msgs: int wd_sched_init(struct wd_scheduler *sched, int data_fmt) { - int ret, j, k; - unsigned int flags; - struct q_info *qinfo; + int ret; ret = wd_sched_preinit(sched, data_fmt); if (ret < 0) diff --git a/v1/test/test_mm/test_wd_mem.c b/v1/test/test_mm/test_wd_mem.c index e2eec60..a1f55db 100644 --- a/v1/test/test_mm/test_wd_mem.c +++ b/v1/test/test_mm/test_wd_mem.c @@ -208,7 +208,7 @@ void *mmt_sys_test_thread(void *data) return NULL; } - ret = wd_request_queue(&pdata->qinfo1.q); + ret = wd_request_queue(pdata->qinfo1.q); if (ret) { wd_release_queue(&rsa_q); MMT_PRT("Proc-%d, thrd-%d:rsa queue fail!\n", @@ -226,7 +226,7 @@ void *mmt_sys_test_thread(void *data) return NULL; } - ret = wd_request_queue(&pdata->qinfo2.q); + ret = wd_request_queue(pdata->qinfo2.q); if (ret) { MMT_PRT("Proc-%d, thrd-%d:zlib queue fail!\n", pid, thread_id); diff --git a/v1/test/wd_sched.c b/v1/test/wd_sched.c index ce1d260..54f400a 100644 --- a/v1/test/wd_sched.c +++ b/v1/test/wd_sched.c @@ -26,7 +26,6 @@ static int wd_sched_pre_uninit(struct wd_scheduler *sched) { unsigned int flags = 0; struct q_info *qinfo; - void *pool; int i; qinfo = sched->qs[0].qinfo; diff --git a/wd_util.c b/wd_util.c index daa7309..138a078 100644 --- a/wd_util.c +++ b/wd_util.c @@ -2459,19 +2459,22 @@ static struct drv_lib_list *load_libraries_from_config(const char *config_path, FILE *config_file; int ret; - path_buf = calloc(WD_PATH_DIR_NUM, PATH_MAX); - if (!path_buf) { - WD_ERR("fail to alloc memery for path_buf.\n"); - return NULL; + lib_path = calloc(1, PATH_MAX); + if (!lib_path) { + WD_ERR("Failed to alloc memery for lib_path.\n"); + return head; + } + + line = calloc(1, PATH_MAX); + if (!line) { + WD_ERR("Failed to alloc memery for lib_line.\n"); + goto free_path; } - lib_path = path_buf; - line = path_buf + PATH_MAX; config_file = fopen(config_path, "r"); if (!config_file) { WD_ERR("Failed to open config file: %s\n", config_path); - free(path_buf); - return NULL; + goto free_line; } /* Read config file line by line */ @@ -2486,8 +2489,12 @@ static struct drv_lib_list *load_libraries_from_config(const char *config_path, create_lib_to_list(lib_path, &head); } - free(path_buf); fclose(config_file); + +free_line: + free(line); +free_path: + free(lib_path); return head; } @@ -2533,15 +2540,21 @@ void *wd_dlopen_drv(const char *cust_lib_dir) int ret, len; DIR *wd_dir; - path_buf = calloc(WD_PATH_DIR_NUM + 1, PATH_MAX); + path_buf = calloc(WD_PATH_DIR_NUM, PATH_MAX); if (!path_buf) { - WD_ERR("fail to alloc memory for path buffers.\n"); - return NULL; + WD_ERR("Failed to alloc memory for path_buf buffers.\n"); + return head; + } + + config_path = calloc(1, PATH_MAX); + if (!config_path) { + WD_ERR("Failed to alloc memory for config_path buffers.\n"); + free(path_buf); + return head; } lib_dir_path = path_buf; - config_path = path_buf + PATH_MAX; - lib_path = config_path + PATH_MAX; + lib_path = path_buf + PATH_MAX; if (!cust_lib_dir) { ret = wd_get_lib_file_path(NULL, lib_dir_path, true); @@ -2582,6 +2595,7 @@ close_dir: closedir(wd_dir); free_path: free(path_buf); + free(config_path); return (void *)head; } -- 2.33.0
participants (1)
-
ZongYu Wu