188 lines
7.0 KiB
Diff
188 lines
7.0 KiB
Diff
|
|
From fb14a10d2e9bdf700dac71078327f9473ee06ed7 Mon Sep 17 00:00:00 2001
|
||
|
|
From: wujing <wujing50@huawei.com>
|
||
|
|
Date: Mon, 28 Feb 2022 20:51:06 +0800
|
||
|
|
Subject: [PATCH 13/16] fix coding irregularities
|
||
|
|
|
||
|
|
Signed-off-by: wujing <wujing50@huawei.com>
|
||
|
|
---
|
||
|
|
src/cmd/isulad/isulad_commands.c | 2 +-
|
||
|
|
src/daemon/common/selinux_label.c | 2 --
|
||
|
|
src/daemon/common/sysinfo.c | 15 +++++++--------
|
||
|
|
.../executor/container_cb/execution_create.c | 2 +-
|
||
|
|
.../executor/container_cb/execution_network.c | 2 +-
|
||
|
|
src/daemon/executor/container_cb/list.c | 11 +----------
|
||
|
|
6 files changed, 11 insertions(+), 23 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/src/cmd/isulad/isulad_commands.c b/src/cmd/isulad/isulad_commands.c
|
||
|
|
index b37c7208..2a0ccf92 100644
|
||
|
|
--- a/src/cmd/isulad/isulad_commands.c
|
||
|
|
+++ b/src/cmd/isulad/isulad_commands.c
|
||
|
|
@@ -360,7 +360,7 @@ static int check_args_auth_plugin(const struct service_arguments *args)
|
||
|
|
int ret = 0;
|
||
|
|
|
||
|
|
if (args->json_confs->authorization_plugin != NULL) {
|
||
|
|
- if (strcmp(args->json_confs->authorization_plugin, AUTH_PLUGIN)) {
|
||
|
|
+ if (strcmp(args->json_confs->authorization_plugin, AUTH_PLUGIN) != 0) {
|
||
|
|
COMMAND_ERROR("Invalid authorization plugin '%s'", args->json_confs->authorization_plugin);
|
||
|
|
ERROR("Invalid authorization plugin '%s'", args->json_confs->authorization_plugin);
|
||
|
|
ret = -1;
|
||
|
|
diff --git a/src/daemon/common/selinux_label.c b/src/daemon/common/selinux_label.c
|
||
|
|
index f6698e89..4472504d 100644
|
||
|
|
--- a/src/daemon/common/selinux_label.c
|
||
|
|
+++ b/src/daemon/common/selinux_label.c
|
||
|
|
@@ -171,8 +171,6 @@ static void find_selinux_fs(char **fs)
|
||
|
|
}
|
||
|
|
// slow path: try to find among the mounts
|
||
|
|
find_selinux_fs_among_mounts(fs);
|
||
|
|
-
|
||
|
|
- return;
|
||
|
|
}
|
||
|
|
|
||
|
|
static int get_state_selinuxfs(char **fs)
|
||
|
|
diff --git a/src/daemon/common/sysinfo.c b/src/daemon/common/sysinfo.c
|
||
|
|
index 652a3985..e60377dd 100644
|
||
|
|
--- a/src/daemon/common/sysinfo.c
|
||
|
|
+++ b/src/daemon/common/sysinfo.c
|
||
|
|
@@ -1010,7 +1010,7 @@ free_out:
|
||
|
|
|
||
|
|
static int get_cgroup_version()
|
||
|
|
{
|
||
|
|
- struct statfs fs = {0};
|
||
|
|
+ struct statfs fs = { 0 };
|
||
|
|
|
||
|
|
if (statfs(CGROUP_MOUNTPOINT, &fs) != 0) {
|
||
|
|
ERROR("failed to statfs %s: %s", CGROUP_MOUNTPOINT, strerror(errno));
|
||
|
|
@@ -1019,9 +1019,9 @@ static int get_cgroup_version()
|
||
|
|
|
||
|
|
if (fs.f_type == CGROUP2_SUPER_MAGIC) {
|
||
|
|
return CGROUP_VERSION_2;
|
||
|
|
- } else {
|
||
|
|
- return CGROUP_VERSION_1;
|
||
|
|
}
|
||
|
|
+
|
||
|
|
+ return CGROUP_VERSION_1;
|
||
|
|
}
|
||
|
|
|
||
|
|
static bool is_hugetlb_max(const char *name)
|
||
|
|
@@ -1102,7 +1102,6 @@ static char **get_huge_page_sizes()
|
||
|
|
hps[index] = util_strdup_s(pos);
|
||
|
|
dup_free:
|
||
|
|
free(dup);
|
||
|
|
- continue;
|
||
|
|
}
|
||
|
|
free_out:
|
||
|
|
|
||
|
|
@@ -1259,7 +1258,7 @@ static int cgroup2_enable_all()
|
||
|
|
char *controllers_str = NULL;
|
||
|
|
char *subtree_controller_str = NULL;
|
||
|
|
char **controllers = NULL;
|
||
|
|
- char enable_controllers[PATH_MAX] = {0};
|
||
|
|
+ char enable_controllers[PATH_MAX] = { 0 };
|
||
|
|
|
||
|
|
controllers_str = util_read_content_from_file(CGROUP2_CONTROLLERS_PATH);
|
||
|
|
if (controllers_str == NULL || strlen(controllers_str) == 0 ||
|
||
|
|
@@ -1329,7 +1328,7 @@ static int get_cgroup_info_v2(sysinfo_t *sysinfo, bool quiet)
|
||
|
|
int ret = 0;
|
||
|
|
int nret = 0;
|
||
|
|
char *size = NULL;
|
||
|
|
- char path[PATH_MAX] = {0};
|
||
|
|
+ char path[PATH_MAX] = { 0 };
|
||
|
|
|
||
|
|
if (make_sure_cgroup2_isulad_path_exist() != 0) {
|
||
|
|
return -1;
|
||
|
|
@@ -1511,7 +1510,7 @@ mountinfo_t *get_mount_info(const char *pline)
|
||
|
|
|
||
|
|
info->mountpoint = util_strdup_s(list[4]);
|
||
|
|
|
||
|
|
- if (strcmp(list[6], "-")) {
|
||
|
|
+ if (strcmp(list[6], "-") != 0) {
|
||
|
|
info->optional = util_strdup_s(list[6]);
|
||
|
|
}
|
||
|
|
|
||
|
|
@@ -1570,7 +1569,7 @@ mountinfo_t **getmountsinfo(void)
|
||
|
|
|
||
|
|
while (getline(&pline, &length, fp) != -1) {
|
||
|
|
int index;
|
||
|
|
- mountinfo_t *info;
|
||
|
|
+ mountinfo_t *info = NULL;
|
||
|
|
|
||
|
|
info = get_mount_info(pline);
|
||
|
|
if (info == NULL) {
|
||
|
|
diff --git a/src/daemon/executor/container_cb/execution_create.c b/src/daemon/executor/container_cb/execution_create.c
|
||
|
|
index 43734d19..850e0a0f 100644
|
||
|
|
--- a/src/daemon/executor/container_cb/execution_create.c
|
||
|
|
+++ b/src/daemon/executor/container_cb/execution_create.c
|
||
|
|
@@ -1026,7 +1026,7 @@ static int get_request_image_info(const container_create_request *request, char
|
||
|
|
}
|
||
|
|
|
||
|
|
// Do not use none image because none image has no config.
|
||
|
|
- if (strcmp(request->image, "none") && strcmp(request->image, "none:latest")) {
|
||
|
|
+ if (strcmp(request->image, "none") != 0 && strcmp(request->image, "none:latest") != 0) {
|
||
|
|
*image_name = util_strdup_s(request->image);
|
||
|
|
}
|
||
|
|
|
||
|
|
diff --git a/src/daemon/executor/container_cb/execution_network.c b/src/daemon/executor/container_cb/execution_network.c
|
||
|
|
index d10e9d16..6ca79a8c 100644
|
||
|
|
--- a/src/daemon/executor/container_cb/execution_network.c
|
||
|
|
+++ b/src/daemon/executor/container_cb/execution_network.c
|
||
|
|
@@ -1074,4 +1074,4 @@ int init_container_network_confs(const char *id, const char *rootpath, const hos
|
||
|
|
|
||
|
|
out:
|
||
|
|
return ret;
|
||
|
|
-}
|
||
|
|
\ No newline at end of file
|
||
|
|
+}
|
||
|
|
diff --git a/src/daemon/executor/container_cb/list.c b/src/daemon/executor/container_cb/list.c
|
||
|
|
index 67fef06e..90f4a548 100644
|
||
|
|
--- a/src/daemon/executor/container_cb/list.c
|
||
|
|
+++ b/src/daemon/executor/container_cb/list.c
|
||
|
|
@@ -173,8 +173,7 @@ static int insert_matched_id(char **ids, map_t *matches, void *value, size_t ids
|
||
|
|
for (i = 0; i < ids_len; i++) {
|
||
|
|
container_t *cont = containers_store_get_by_prefix(ids[i]);
|
||
|
|
if (cont != NULL) {
|
||
|
|
- bool inserted;
|
||
|
|
- inserted = map_insert(matches, cont->common_config->id, value);
|
||
|
|
+ bool inserted = map_insert(matches, cont->common_config->id, value);
|
||
|
|
container_unref(cont);
|
||
|
|
if (!inserted) {
|
||
|
|
ERROR("Insert map failed: %s", ids[i]);
|
||
|
|
@@ -328,8 +327,6 @@ static void dup_container_labels(const map_t *map_labels, const container_config
|
||
|
|
ERROR("Failed to dup container %s labels", common_config->id);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
-
|
||
|
|
- return;
|
||
|
|
}
|
||
|
|
|
||
|
|
static void dup_container_annotations(const container_config_v2_common_config *common_config,
|
||
|
|
@@ -345,8 +342,6 @@ static void dup_container_annotations(const container_config_v2_common_config *c
|
||
|
|
if (ret != 0) {
|
||
|
|
ERROR("Failed to dup container %s annotations", common_config->id);
|
||
|
|
}
|
||
|
|
-
|
||
|
|
- return;
|
||
|
|
}
|
||
|
|
|
||
|
|
static void dup_container_created_time(const container_config_v2_common_config *common_config,
|
||
|
|
@@ -356,8 +351,6 @@ static void dup_container_created_time(const container_config_v2_common_config *
|
||
|
|
util_to_unix_nanos_from_str(common_config->created, &isuladinfo->created) != 0) {
|
||
|
|
ERROR("Failed to dup container %s created time", common_config->id);
|
||
|
|
}
|
||
|
|
-
|
||
|
|
- return;
|
||
|
|
}
|
||
|
|
|
||
|
|
static void dup_container_image_ref(const container_config_v2_common_config *common_config,
|
||
|
|
@@ -368,8 +361,6 @@ static void dup_container_image_ref(const container_config_v2_common_config *com
|
||
|
|
}
|
||
|
|
|
||
|
|
isuladinfo->image_ref = util_strdup_s(common_config->config->image_ref);
|
||
|
|
-
|
||
|
|
- return;
|
||
|
|
}
|
||
|
|
|
||
|
|
static int convert_common_config_info(const map_t *map_labels, const container_config_v2_common_config *common_config,
|
||
|
|
--
|
||
|
|
2.20.1
|
||
|
|
|