156 lines
5.9 KiB
Diff
156 lines
5.9 KiB
Diff
From 41aa94a5859755ed4ca181043dd442401fd068ea Mon Sep 17 00:00:00 2001
|
|
From: haozi007 <liuhao27@huawei.com>
|
|
Date: Tue, 5 Sep 2023 19:35:37 +0800
|
|
Subject: [PATCH 10/20] remove unnecessary strerror
|
|
|
|
Signed-off-by: haozi007 <liuhao27@huawei.com>
|
|
---
|
|
src/lcrcontainer_execute.c | 7 +++----
|
|
src/lcrcontainer_extend.c | 16 ++++++++--------
|
|
src/utils.c | 2 +-
|
|
third_party/log.c | 6 +++---
|
|
4 files changed, 15 insertions(+), 16 deletions(-)
|
|
|
|
diff --git a/src/lcrcontainer_execute.c b/src/lcrcontainer_execute.c
|
|
index b924254..6c1f9fc 100644
|
|
--- a/src/lcrcontainer_execute.c
|
|
+++ b/src/lcrcontainer_execute.c
|
|
@@ -71,8 +71,7 @@
|
|
do \
|
|
{ \
|
|
SYSERROR("Error updating cgroup %s to %s", (item), (value)); \
|
|
- lcr_set_error_message(LCR_ERR_RUNTIME, "Error updating cgroup %s to %s: %s", (item), (value), \
|
|
- strerror(errno)); \
|
|
+ lcr_set_error_message(LCR_ERR_RUNTIME, "Error updating cgroup %s to %s.", (item), (value)); \
|
|
} while (0)
|
|
|
|
static inline void add_array_elem(char **array, size_t total, size_t *pos, const char *elem)
|
|
@@ -908,7 +907,7 @@ static void execute_lxc_attach(const char *name, const char *path, const struct
|
|
|
|
execvp("lxc-attach", params);
|
|
|
|
- COMMAND_ERROR("Failed to exec lxc-attach: %s", strerror(errno));
|
|
+ CMD_SYSERROR("Failed to exec lxc-attach");
|
|
free(params);
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
@@ -1067,6 +1066,6 @@ void execute_lxc_start(const char *name, const char *path, const struct lcr_star
|
|
|
|
execvp("lxc-start", params);
|
|
|
|
- COMMAND_ERROR("Failed to exec lxc-start: %s.", strerror(errno));
|
|
+ CMD_SYSERROR("Failed to exec lxc-start.");
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
diff --git a/src/lcrcontainer_extend.c b/src/lcrcontainer_extend.c
|
|
index 645f159..321be8c 100644
|
|
--- a/src/lcrcontainer_extend.c
|
|
+++ b/src/lcrcontainer_extend.c
|
|
@@ -153,7 +153,7 @@ static int make_annotations(oci_runtime_spec *container, const struct lxc_contai
|
|
goto out;
|
|
}
|
|
if (lcr_util_ensure_path(&realpath, anno->values[fpos])) {
|
|
- ERROR("Invalid log path: %s, error: %s.", anno->values[fpos], strerror(errno));
|
|
+ SYSERROR("Invalid log path: %s.", anno->values[fpos]);
|
|
goto out;
|
|
}
|
|
ret = 0;
|
|
@@ -376,7 +376,7 @@ static int lcr_spec_write_seccomp_line(int fd, const char *seccomp)
|
|
}
|
|
line[nret] = '\n';
|
|
if (write(fd, line, len) == -1) {
|
|
- SYSERROR("Write failed");
|
|
+ SYSERROR("Write file failed");
|
|
goto cleanup;
|
|
}
|
|
ret = 0;
|
|
@@ -626,8 +626,8 @@ static int lcr_open_config_file(const char *bundle)
|
|
|
|
fd = lcr_util_open(real_config, O_CREAT | O_TRUNC | O_CLOEXEC | O_WRONLY, CONFIG_FILE_MODE);
|
|
if (fd == -1) {
|
|
- ERROR("Create file %s failed, %s", real_config, strerror(errno));
|
|
- lcr_set_error_message(LCR_ERR_RUNTIME, "Create file %s failed, %s", real_config, strerror(errno));
|
|
+ SYSERROR("Create file %s failed", real_config);
|
|
+ lcr_set_error_message(LCR_ERR_RUNTIME, "Create file %s failed", real_config);
|
|
goto out;
|
|
}
|
|
out:
|
|
@@ -738,7 +738,7 @@ static int lcr_spec_write_config(int fd, const struct lcr_list *lcr_conf)
|
|
|
|
line_encode[encode_len] = '\n';
|
|
if (write(fd, line_encode, encode_len + 1) == -1) {
|
|
- SYSERROR("Write failed");
|
|
+ SYSERROR("Write file failed");
|
|
goto cleanup;
|
|
}
|
|
free(line);
|
|
@@ -788,7 +788,7 @@ static char *lcr_get_bundle(const char *lcrpath, const char *name)
|
|
ERROR("Bundle %s does not exist", bundle);
|
|
break;
|
|
default:
|
|
- ERROR("Access %s failed: %s\n", bundle, strerror(errno));
|
|
+ SYSERROR("Access %s failed", bundle);
|
|
}
|
|
goto cleanup;
|
|
}
|
|
@@ -880,7 +880,7 @@ static int lcr_write_file(const char *path, const char *data, size_t len)
|
|
}
|
|
|
|
if (write(fd, data, len) == -1) {
|
|
- ERROR("write data to %s failed: %s", real_path, strerror(errno));
|
|
+ SYSERROR("write data to %s failed", real_path);
|
|
goto out_free;
|
|
}
|
|
|
|
@@ -908,7 +908,7 @@ static bool lcr_write_ocihooks(const char *path, const oci_runtime_spec_hooks *h
|
|
}
|
|
|
|
if (lcr_write_file(path, json_hooks, strlen(json_hooks)) == -1) {
|
|
- ERROR("write json hooks failed: %s", strerror(errno));
|
|
+ SYSERROR("write json hooks failed");
|
|
goto out_free;
|
|
}
|
|
|
|
diff --git a/src/utils.c b/src/utils.c
|
|
index d1271dd..df73985 100644
|
|
--- a/src/utils.c
|
|
+++ b/src/utils.c
|
|
@@ -1344,7 +1344,7 @@ int lcr_util_get_cgroup_version()
|
|
struct statfs fs = {0};
|
|
|
|
if (statfs(CGROUP_MOUNTPOINT, &fs) != 0) {
|
|
- ERROR("failed to statfs %s: %s", CGROUP_MOUNTPOINT, strerror(errno));
|
|
+ SYSERROR("failed to statfs %s.", CGROUP_MOUNTPOINT);
|
|
return -1;
|
|
}
|
|
|
|
diff --git a/third_party/log.c b/third_party/log.c
|
|
index c3c1981..9c8a873 100644
|
|
--- a/third_party/log.c
|
|
+++ b/third_party/log.c
|
|
@@ -312,18 +312,18 @@ static int open_fifo(const char *fifo_path)
|
|
|
|
nret = mknod(fifo_path, S_IFIFO | S_IRUSR | S_IWUSR, (dev_t)0);
|
|
if (nret && errno != EEXIST) {
|
|
- COMMAND_ERROR("Mknod failed: %s", strerror(errno));
|
|
+ CMD_SYSERROR("Mknod failed");
|
|
return nret;
|
|
}
|
|
|
|
fifo_fd = lcr_util_open(fifo_path, O_RDWR | O_NONBLOCK, 0);
|
|
if (fifo_fd == -1) {
|
|
- COMMAND_ERROR("Open fifo %s failed: %s", fifo_path, strerror(errno));
|
|
+ CMD_SYSERROR("Open fifo %s failed", fifo_path);
|
|
return -1;
|
|
}
|
|
|
|
if (fcntl(fifo_fd, F_SETPIPE_SZ, LOG_FIFO_SIZE) == -1) {
|
|
- COMMAND_ERROR("Set fifo buffer size failed: %s", strerror(errno));
|
|
+ CMD_SYSERROR("Set fifo buffer size failed");
|
|
close(fifo_fd);
|
|
return -1;
|
|
}
|
|
--
|
|
2.33.0
|
|
|