]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
coredump: rename set_iovec_field_free() into set_iovec_string_field_free()
authorFranck Bui <fbui@suse.com>
Fri, 21 Jun 2019 12:48:02 +0000 (14:48 +0200)
committerFranck Bui <fbui@suse.com>
Thu, 27 Jun 2019 17:01:28 +0000 (19:01 +0200)
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().

src/basic/io-util.c
src/basic/io-util.h
src/coredump/coredump.c

index 575398fbe6b31865bd50e99196c91f13c8ea6b31..9394e54bc5d5a345fbaac4da748c20aa4645e495 100644 (file)
@@ -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;
+}
index 792a64ad5ed3beb6e640c78fda34f8e58a4bdaa9..d1fb7e78d205b2a14893011a0ef726b9e1f788e6 100644 (file)
@@ -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);
index 0261739a11df27b75222aacf6ec789ec56e16f10..4cd08724fdc38c89fef15eb7ddbb7be5906ace6e 100644 (file)
@@ -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)