diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-10-22 19:28:31 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-10-24 23:03:49 +0200 |
commit | 0f4743651081b5367ab06f238827ddfd4da74e74 (patch) | |
tree | 43b072e7eb30af4c4c80fa451768ecd8eb14a1d9 /src/journal | |
parent | 85eca92e2061043d733991b386d8dc10fad0fc30 (diff) |
util-lib: get_current_dir_name() can return errors other than ENOMEM
get_current_dir_name() can return a variety of errors, not just ENOMEM,
hence don't blindly turn its errors to ENOMEM, but return correct errors
in path_make_absolute_cwd().
This trickles down into a couple of other functions, some of which
receive unrelated minor fixes too with this commit.
Diffstat (limited to 'src/journal')
-rw-r--r-- | src/journal/coredumpctl.c | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/src/journal/coredumpctl.c b/src/journal/coredumpctl.c index dde56008c1..97a721c114 100644 --- a/src/journal/coredumpctl.c +++ b/src/journal/coredumpctl.c @@ -84,37 +84,35 @@ static Set *new_matches(void) { } static int add_match(Set *set, const char *match) { - int r = -ENOMEM; - unsigned pid; - const char* prefix; - char *pattern = NULL; _cleanup_free_ char *p = NULL; + char *pattern = NULL; + const char* prefix; + pid_t pid; + int r; if (strchr(match, '=')) prefix = ""; else if (strchr(match, '/')) { - p = path_make_absolute_cwd(match); - if (!p) + r = path_make_absolute_cwd(match, &p); + if (r < 0) goto fail; - match = p; prefix = "COREDUMP_EXE="; - } - else if (safe_atou(match, &pid) == 0) + } else if (parse_pid(match, &pid) >= 0) prefix = "COREDUMP_PID="; else prefix = "COREDUMP_COMM="; pattern = strjoin(prefix, match, NULL); - if (!pattern) + if (!pattern) { + r = -ENOMEM; goto fail; + } log_debug("Adding pattern: %s", pattern); r = set_consume(set, pattern); - if (r < 0) { - log_error_errno(r, "Failed to add pattern: %m"); + if (r < 0) goto fail; - } return 0; fail: |