struct iovec_wrapper *iovw_new(void);
struct iovec_wrapper *iovw_free(struct iovec_wrapper *iovw);
struct iovec_wrapper *iovw_free_free(struct iovec_wrapper *iovw);
+
+DEFINE_TRIVIAL_CLEANUP_FUNC(struct iovec_wrapper*, iovw_free_free);
+
void iovw_free_contents(struct iovec_wrapper *iovw, bool free_vectors);
int iovw_put(struct iovec_wrapper *iovw, void *data, size_t len);
}
static int process_kernel(int argc, char* argv[]) {
+ _cleanup_(iovw_free_freep) struct iovec_wrapper *iovw = NULL;
Context context = {};
- struct iovec_wrapper *iovw;
int r;
/* When we're invoked by the kernel, stdout/stderr are closed which is dangerous because the fds
/* Collect all process metadata passed by the kernel through argv[] */
r = gather_pid_metadata_from_argv(iovw, &context, argc - 1, argv + 1);
if (r < 0)
- goto finish;
+ return r;
/* Collect the rest of the process metadata retrieved from the runtime */
r = gather_pid_metadata(iovw, &context);
if (r < 0)
- goto finish;
+ return r;
if (!context.is_journald)
/* OK, now we know it's not the journal, hence we can make use of it now. */
}
if (context.is_journald || context.is_pid1)
- r = submit_coredump(&context, iovw, STDIN_FILENO);
- else
- r = send_iovec(iovw, STDIN_FILENO);
+ return submit_coredump(&context, iovw, STDIN_FILENO);
- finish:
- iovw = iovw_free_free(iovw);
- return r;
+ return send_iovec(iovw, STDIN_FILENO);
}
static int process_backtrace(int argc, char *argv[]) {