summaryrefslogtreecommitdiff
path: root/src/journal/coredumpctl.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-04-22 23:12:15 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-04-24 00:25:04 -0400
commitef42202ac8ed27e7ff1fc90ef8bc2590046dff25 (patch)
treeb1646eeb8ef5070337ae701ffb4abf0e398640ad /src/journal/coredumpctl.c
parentc79bb9e4e2e5b96b2ae2c432bf8b0ff9674fce60 (diff)
Add set_consume which always takes ownership
Freeing in error path is the common pattern with set_put().
Diffstat (limited to 'src/journal/coredumpctl.c')
-rw-r--r--src/journal/coredumpctl.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/src/journal/coredumpctl.c b/src/journal/coredumpctl.c
index 0bbfff2ecd..5652c2f91a 100644
--- a/src/journal/coredumpctl.c
+++ b/src/journal/coredumpctl.c
@@ -68,10 +68,9 @@ static Set *new_matches(void) {
return NULL;
}
- r = set_put(set, tmp);
+ r = set_consume(set, tmp);
if (r < 0) {
log_error("failed to add to set: %s", strerror(-r));
- free(tmp);
set_free(set);
return NULL;
}
@@ -125,18 +124,17 @@ static int add_match(Set *set, const char *match) {
if (!pattern)
goto fail;
- r = set_put(set, pattern);
+ log_debug("Adding pattern: %s", pattern);
+ r = set_consume(set, pattern);
if (r < 0) {
- log_error("failed to add pattern '%s': %s",
+ log_error("Failed to add pattern '%s': %s",
pattern, strerror(-r));
goto fail;
}
- log_debug("Added pattern: %s", pattern);
return 0;
fail:
- free(pattern);
- log_error("failed to add match: %s", strerror(-r));
+ log_error("Failed to add match: %s", strerror(-r));
return r;
}