From 4b5849ad6a04bd00733e6c96dd4ffa0d3febc159 Mon Sep 17 00:00:00 2001
From: zhongtao <zhongtao17@huawei.com>
Date: Tue, 6 Jun 2023 08:53:14 +0000
Subject: [PATCH 08/15] !2048 fix some code check error * fix some code check
 error

---
 src/daemon/modules/image/oci/registry/auths.c |  4 +-
 .../graphdriver/devmapper/wrapper_devmapper.h |  2 +-
 .../modules/runtime/isula/isula_rt_ops.c      | 52 +++++++++----------
 3 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/src/daemon/modules/image/oci/registry/auths.c b/src/daemon/modules/image/oci/registry/auths.c
index a95127f2..ce67d51b 100644
--- a/src/daemon/modules/image/oci/registry/auths.c
+++ b/src/daemon/modules/image/oci/registry/auths.c
@@ -265,9 +265,9 @@ out:
 
     if (ret != 0) {
         free(element);
-        element = 0;
+        element = NULL;
         free(values);
-        values = 0;
+        values = NULL;
     }
 
     return ret;
diff --git a/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/wrapper_devmapper.h b/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/wrapper_devmapper.h
index 5a692980..e8acebc0 100644
--- a/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/wrapper_devmapper.h
+++ b/src/daemon/modules/image/oci/storage/layer_store/graphdriver/devmapper/wrapper_devmapper.h
@@ -30,7 +30,7 @@ struct dm_task;
 extern "C" {
 #endif
 
-#define DEV_ERR -1
+#define DEV_ERR (-1)
 #define DEV_OK 0
 #define DEV_INIT 1
 
diff --git a/src/daemon/modules/runtime/isula/isula_rt_ops.c b/src/daemon/modules/runtime/isula/isula_rt_ops.c
index fab0b657..9fe3ac4b 100644
--- a/src/daemon/modules/runtime/isula/isula_rt_ops.c
+++ b/src/daemon/modules/runtime/isula/isula_rt_ops.c
@@ -498,8 +498,8 @@ static int status_string_to_int(const char *status)
 static int runtime_call_status(const char *workdir, const char *runtime, const char *id,
                                struct runtime_container_status_info *ecsi)
 {
-    char *stdout = NULL;
-    char *stderr = NULL;
+    char *stdout_msg = NULL;
+    char *stderr_msg = NULL;
     oci_runtime_state *state = NULL;
     struct parser_context ctx = { OPT_GEN_SIMPLIFY, 0 };
     parser_error perr = NULL;
@@ -509,19 +509,19 @@ static int runtime_call_status(const char *workdir, const char *runtime, const c
 
     runtime_exec_info_init(&rei, workdir, runtime, "state", NULL, 0, id, params, PARAM_NUM);
 
-    if (!util_exec_cmd(runtime_exec_func, &rei, NULL, &stdout, &stderr)) {
-        ERROR("call runtime status failed: %s", stderr);
+    if (!util_exec_cmd(runtime_exec_func, &rei, NULL, &stdout_msg, &stderr_msg)) {
+        ERROR("call runtime status failed: %s", stderr_msg);
         ret = -1;
         goto out;
     }
 
-    if (stdout == NULL) {
-        ERROR("call runtime status no stdout");
+    if (stdout_msg == NULL) {
+        ERROR("call runtime status no stdout_msg");
         ret = -1;
         goto out;
     }
 
-    state = oci_runtime_state_parse_data(stdout, &ctx, &perr);
+    state = oci_runtime_state_parse_data(stdout_msg, &ctx, &perr);
     if (state == NULL) {
         ERROR("call runtime status parse json failed");
         ret = -1;
@@ -538,8 +538,8 @@ static int runtime_call_status(const char *workdir, const char *runtime, const c
 
 out:
     free_oci_runtime_state(state);
-    UTIL_FREE_AND_SET_NULL(stdout);
-    UTIL_FREE_AND_SET_NULL(stderr);
+    UTIL_FREE_AND_SET_NULL(stdout_msg);
+    UTIL_FREE_AND_SET_NULL(stderr_msg);
     UTIL_FREE_AND_SET_NULL(perr);
     return ret;
 }
@@ -547,8 +547,8 @@ out:
 static int runtime_call_stats(const char *workdir, const char *runtime, const char *id,
                               struct runtime_container_resources_stats_info *info)
 {
-    char *stdout = NULL;
-    char *stderr = NULL;
+    char *stdout_msg = NULL;
+    char *stderr_msg = NULL;
     shim_client_runtime_stats *stats = NULL;
     struct parser_context ctx = { OPT_GEN_SIMPLIFY, 0 };
     parser_error perr = NULL;
@@ -559,19 +559,19 @@ static int runtime_call_stats(const char *workdir, const char *runtime, const ch
 
     runtime_exec_info_init(&rei, workdir, runtime, "events", opts, 1, id, params, PARAM_NUM);
 
-    if (!util_exec_cmd(runtime_exec_func, &rei, NULL, &stdout, &stderr)) {
-        ERROR("call runtime events --stats failed: %s", stderr);
+    if (!util_exec_cmd(runtime_exec_func, &rei, NULL, &stdout_msg, &stderr_msg)) {
+        ERROR("call runtime events --stats failed: %s", stderr_msg);
         ret = -1;
         goto out;
     }
 
-    if (stdout == NULL) {
-        ERROR("call runtime events --stats no stdout");
+    if (stdout_msg == NULL) {
+        ERROR("call runtime events --stats no stdout_msg");
         ret = -1;
         goto out;
     }
 
-    stats = shim_client_runtime_stats_parse_data(stdout, &ctx, &perr);
+    stats = shim_client_runtime_stats_parse_data(stdout_msg, &ctx, &perr);
     if (stats == NULL) {
         ERROR("call runtime events --stats parse json failed");
         ret = -1;
@@ -595,8 +595,8 @@ static int runtime_call_stats(const char *workdir, const char *runtime, const ch
 
 out:
     free_shim_client_runtime_stats(stats);
-    UTIL_FREE_AND_SET_NULL(stdout);
-    UTIL_FREE_AND_SET_NULL(stderr);
+    UTIL_FREE_AND_SET_NULL(stdout_msg);
+    UTIL_FREE_AND_SET_NULL(stderr_msg);
     UTIL_FREE_AND_SET_NULL(perr);
     return ret;
 }
@@ -605,27 +605,27 @@ static int runtime_call_simple(const char *workdir, const char *runtime, const c
                                size_t opts_len, const char *id, handle_output_callback_t cb)
 {
     runtime_exec_info rei = { 0 };
-    char *stdout = NULL;
-    char *stderr = NULL;
+    char *stdout_msg = NULL;
+    char *stderr_msg = NULL;
     int ret = 0;
     char *params[PARAM_NUM] = { 0 };
 
     runtime_exec_info_init(&rei, workdir, runtime, subcmd, opts, opts_len, id, params, PARAM_NUM);
-    if (!util_exec_cmd(runtime_exec_func, &rei, NULL, &stdout, &stderr)) {
-        ERROR("call runtime %s failed stderr %s", subcmd, stderr);
+    if (!util_exec_cmd(runtime_exec_func, &rei, NULL, &stdout_msg, &stderr_msg)) {
+        ERROR("call runtime %s failed stderr %s", subcmd, stderr_msg);
         ret = -1;
         // additional handler for the stderr,
         // this intend to change the ret val of this function
         // for example, if output string contains some specific content,
         // we consider the runtime call simple succeeded,
         // even if the process exit with failure.
-        if (stderr != NULL && cb != NULL) {
-            ret = cb(stderr);
+        if (stderr_msg != NULL && cb != NULL) {
+            ret = cb(stderr_msg);
         }
     }
 
-    UTIL_FREE_AND_SET_NULL(stdout);
-    UTIL_FREE_AND_SET_NULL(stderr);
+    UTIL_FREE_AND_SET_NULL(stdout_msg);
+    UTIL_FREE_AND_SET_NULL(stderr_msg);
     return ret;
 }
 
-- 
2.25.1

