summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFranck Bui <fbui@suse.com>2019-06-21 14:48:02 +0200
committerFranck Bui <fbui@suse.com>2019-06-27 19:01:28 +0200
commit30a0554ebdacdf32fbfe88449ea07a0a39ca40c5 (patch)
treef4a80dd4fb46c2c8b053b5a511f74e8e9d0e2712 /src
parent47cf786c0a13fccd777c334bed4b1e7b02f18d42 (diff)
downloadsystemd-30a0554ebdacdf32fbfe88449ea07a0a39ca40c5.tar.gz
systemd-30a0554ebdacdf32fbfe88449ea07a0a39ca40c5.tar.bz2
systemd-30a0554ebdacdf32fbfe88449ea07a0a39ca40c5.zip
coredump: rename set_iovec_field_free() into set_iovec_string_field_free()
It's more in line with its counterpart set_iovec_string_field(). Also move the definition to io-util next to set_iovec_string_field().
Diffstat (limited to 'src')
-rw-r--r--src/basic/io-util.c8
-rw-r--r--src/basic/io-util.h1
-rw-r--r--src/coredump/coredump.c38
3 files changed, 24 insertions, 23 deletions
diff --git a/src/basic/io-util.c b/src/basic/io-util.c
index 575398fbe6..9394e54bc5 100644
--- a/src/basic/io-util.c
+++ b/src/basic/io-util.c
@@ -262,3 +262,11 @@ char* set_iovec_string_field(struct iovec *iovec, size_t *n_iovec, const char *f
iovec[(*n_iovec)++] = IOVEC_MAKE_STRING(x);
return x;
}
+
+char* set_iovec_string_field_free(struct iovec *iovec, size_t *n_iovec, const char *field, char *value) {
+ char *x;
+
+ x = set_iovec_string_field(iovec, n_iovec, field, value);
+ free(value);
+ return x;
+}
diff --git a/src/basic/io-util.h b/src/basic/io-util.h
index 792a64ad5e..d1fb7e78d2 100644
--- a/src/basic/io-util.h
+++ b/src/basic/io-util.h
@@ -73,3 +73,4 @@ static inline bool FILE_SIZE_VALID_OR_INFINITY(uint64_t l) {
#define IOVEC_MAKE_STRING(string) (struct iovec) IOVEC_INIT_STRING(string)
char* set_iovec_string_field(struct iovec *iovec, size_t *n_iovec, const char *field, const char *value);
+char* set_iovec_string_field_free(struct iovec *iovec, size_t *n_iovec, const char *field, char *value);
diff --git a/src/coredump/coredump.c b/src/coredump/coredump.c
index 0261739a11..4cd08724fd 100644
--- a/src/coredump/coredump.c
+++ b/src/coredump/coredump.c
@@ -1050,14 +1050,6 @@ static int send_iovec(const struct iovec iovec[], size_t n_iovec, int input_fd)
return 0;
}
-static char* set_iovec_field_free(struct iovec *iovec, size_t *n_iovec, const char *field, char *value) {
- char *x;
-
- x = set_iovec_string_field(iovec, n_iovec, field, value);
- free(value);
- return x;
-}
-
static int gather_pid_metadata(char *context[_CONTEXT_MAX], struct iovec *iovec, size_t *n_iovec) {
/* We need 27 empty slots in iovec!
@@ -1100,7 +1092,7 @@ static int gather_pid_metadata(char *context[_CONTEXT_MAX], struct iovec *iovec,
}
if (cg_pid_get_user_unit(pid, &t) >= 0)
- set_iovec_field_free(iovec, n_iovec, "COREDUMP_USER_UNIT=", t);
+ set_iovec_string_field_free(iovec, n_iovec, "COREDUMP_USER_UNIT=", t);
/* The next few are mandatory */
if (!set_iovec_string_field(iovec, n_iovec, "COREDUMP_PID=", context[CONTEXT_PID]))
@@ -1129,7 +1121,7 @@ static int gather_pid_metadata(char *context[_CONTEXT_MAX], struct iovec *iovec,
return log_oom();
if (sd_pid_get_session(pid, &t) >= 0)
- set_iovec_field_free(iovec, n_iovec, "COREDUMP_SESSION=", t);
+ set_iovec_string_field_free(iovec, n_iovec, "COREDUMP_SESSION=", t);
if (sd_pid_get_owner_uid(pid, &owner_uid) >= 0) {
r = asprintf(&t, "COREDUMP_OWNER_UID=" UID_FMT, owner_uid);
@@ -1138,55 +1130,55 @@ static int gather_pid_metadata(char *context[_CONTEXT_MAX], struct iovec *iovec,
}
if (sd_pid_get_slice(pid, &t) >= 0)
- set_iovec_field_free(iovec, n_iovec, "COREDUMP_SLICE=", t);
+ set_iovec_string_field_free(iovec, n_iovec, "COREDUMP_SLICE=", t);
if (get_process_cmdline(pid, SIZE_MAX, 0, &t) >= 0)
- set_iovec_field_free(iovec, n_iovec, "COREDUMP_CMDLINE=", t);
+ set_iovec_string_field_free(iovec, n_iovec, "COREDUMP_CMDLINE=", t);
if (cg_pid_get_path_shifted(pid, NULL, &t) >= 0)
- set_iovec_field_free(iovec, n_iovec, "COREDUMP_CGROUP=", t);
+ set_iovec_string_field_free(iovec, n_iovec, "COREDUMP_CGROUP=", t);
if (compose_open_fds(pid, &t) >= 0)
- set_iovec_field_free(iovec, n_iovec, "COREDUMP_OPEN_FDS=", t);
+ set_iovec_string_field_free(iovec, n_iovec, "COREDUMP_OPEN_FDS=", t);
p = procfs_file_alloca(pid, "status");
if (read_full_file(p, &t, NULL) >= 0)
- set_iovec_field_free(iovec, n_iovec, "COREDUMP_PROC_STATUS=", t);
+ set_iovec_string_field_free(iovec, n_iovec, "COREDUMP_PROC_STATUS=", t);
p = procfs_file_alloca(pid, "maps");
if (read_full_file(p, &t, NULL) >= 0)
- set_iovec_field_free(iovec, n_iovec, "COREDUMP_PROC_MAPS=", t);
+ set_iovec_string_field_free(iovec, n_iovec, "COREDUMP_PROC_MAPS=", t);
p = procfs_file_alloca(pid, "limits");
if (read_full_file(p, &t, NULL) >= 0)
- set_iovec_field_free(iovec, n_iovec, "COREDUMP_PROC_LIMITS=", t);
+ set_iovec_string_field_free(iovec, n_iovec, "COREDUMP_PROC_LIMITS=", t);
p = procfs_file_alloca(pid, "cgroup");
if (read_full_file(p, &t, NULL) >=0)
- set_iovec_field_free(iovec, n_iovec, "COREDUMP_PROC_CGROUP=", t);
+ set_iovec_string_field_free(iovec, n_iovec, "COREDUMP_PROC_CGROUP=", t);
p = procfs_file_alloca(pid, "mountinfo");
if (read_full_file(p, &t, NULL) >=0)
- set_iovec_field_free(iovec, n_iovec, "COREDUMP_PROC_MOUNTINFO=", t);
+ set_iovec_string_field_free(iovec, n_iovec, "COREDUMP_PROC_MOUNTINFO=", t);
if (get_process_cwd(pid, &t) >= 0)
- set_iovec_field_free(iovec, n_iovec, "COREDUMP_CWD=", t);
+ set_iovec_string_field_free(iovec, n_iovec, "COREDUMP_CWD=", t);
if (get_process_root(pid, &t) >= 0) {
bool proc_self_root_is_slash;
proc_self_root_is_slash = strcmp(t, "/") == 0;
- set_iovec_field_free(iovec, n_iovec, "COREDUMP_ROOT=", t);
+ set_iovec_string_field_free(iovec, n_iovec, "COREDUMP_ROOT=", t);
/* If the process' root is "/", then there is a chance it has
* mounted own root and hence being containerized. */
if (proc_self_root_is_slash && get_process_container_parent_cmdline(pid, &t) > 0)
- set_iovec_field_free(iovec, n_iovec, "COREDUMP_CONTAINER_CMDLINE=", t);
+ set_iovec_string_field_free(iovec, n_iovec, "COREDUMP_CONTAINER_CMDLINE=", t);
}
if (get_process_environ(pid, &t) >= 0)
- set_iovec_field_free(iovec, n_iovec, "COREDUMP_ENVIRON=", t);
+ set_iovec_string_field_free(iovec, n_iovec, "COREDUMP_ENVIRON=", t);
t = strjoin("COREDUMP_TIMESTAMP=", context[CONTEXT_TIMESTAMP], "000000");
if (t)