From 32a1575fbd8807bad2570af0d631a0263f0eb765 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 1 Mar 2017 15:46:54 +0100 Subject: coredump: normalize generation/parsing of COREDUMP_TRUNCATED= Given that this is a field primarily processed by computers, and not so much by humans, assign "1" instead of "yes". Also, use parse_boolean() as we usually do for parsing it again. This makes things more alike udev options (as one example), such as SYSTEMD_READY where we also spit out "1" and "0", and parse with parse_boolean(). --- src/coredump/coredumpctl.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/coredump/coredumpctl.c') diff --git a/src/coredump/coredumpctl.c b/src/coredump/coredumpctl.c index 3e9a00bbcf..bffb3d458f 100644 --- a/src/coredump/coredumpctl.c +++ b/src/coredump/coredumpctl.c @@ -414,7 +414,7 @@ static int print_list(FILE* file, sd_journal *j, int had_legend) { else present = "-"; - if (STR_IN_SET(present, "present", "journal") && streq_ptr(truncated, "yes")) + if (STR_IN_SET(present, "present", "journal") && truncated && parse_boolean(truncated) > 0) present = "truncated"; fprintf(file, "%-*s %*s %*s %*s %*s %-*s %s\n", @@ -583,8 +583,10 @@ static int print_info(FILE *file, sd_journal *j, bool need_space) { fprintf(file, " Hostname: %s\n", hostname); if (filename) { - bool inacc = access(filename, R_OK) < 0; - bool trunc = streq_ptr(truncated, "yes"); + bool inacc, trunc; + + inacc = access(filename, R_OK) < 0; + trunc = truncated && parse_boolean(truncated) > 0; if (inacc || trunc) fprintf(file, " Storage: %s%s (%s%s%s)%s\n", -- cgit v1.2.3-54-g00ecf From 501551e80315b1e50391dbc958bc2c8dcda7cf98 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 1 Mar 2017 16:00:47 +0100 Subject: coredump: define a macro for a "short bus call timeout" I think it would be a good idea to move such fixed, picked values out of the main sources into the head of a file, to make sure they are ultimately tunables. --- src/coredump/coredumpctl.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/coredump/coredumpctl.c') diff --git a/src/coredump/coredumpctl.c b/src/coredump/coredumpctl.c index bffb3d458f..114a13fc78 100644 --- a/src/coredump/coredumpctl.c +++ b/src/coredump/coredumpctl.c @@ -51,6 +51,8 @@ #include "user-util.h" #include "util.h" +#define SHORT_BUS_CALL_TIMEOUT_USEC (3 * USEC_PER_SEC) + static usec_t arg_since = USEC_INFINITY, arg_until = USEC_INFINITY; static enum { @@ -992,7 +994,7 @@ static int check_units_active(void) { if (r < 0) return bus_log_create_error(r); - r = sd_bus_call(bus, m, 3 * USEC_PER_SEC, &error, &reply); + r = sd_bus_call(bus, m, SHORT_BUS_CALL_TIMEOUT_USEC, &error, &reply); if (r < 0) return log_error_errno(r, "Failed to check if any systemd-coredump@.service units are running: %s", bus_error_message(&error, r)); -- cgit v1.2.3-54-g00ecf