From 981b033510716e71967b0e5d23623ec9f69a7e2e Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Mon, 25 Mar 2024 23:10:52 +0800 Subject: [PATCH 1/2] basic/string-table: remove unnecessary brackets --- src/basic/string-table.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/basic/string-table.h b/src/basic/string-table.h index 3be70dfade..d1d90df786 100644 --- a/src/basic/string-table.h +++ b/src/basic/string-table.h @@ -47,10 +47,8 @@ ssize_t string_table_lookup(const char * const *table, size_t len, const char *k s = strdup(name##_table[i]); \ if (!s) \ return -ENOMEM; \ - } else { \ - if (asprintf(&s, "%i", i) < 0) \ - return -ENOMEM; \ - } \ + } else if (asprintf(&s, "%i", i) < 0) \ + return -ENOMEM; \ *str = s; \ return 0; \ } From d44233503f29ad6f79914c8e6137fc2d260d9f89 Mon Sep 17 00:00:00 2001 From: Mike Yuan Date: Mon, 25 Mar 2024 23:11:27 +0800 Subject: [PATCH 2/2] journalctl: explicitly check < 0 for error --- src/journal/journalctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c index 15f3f0e025..898e08774a 100644 --- a/src/journal/journalctl.c +++ b/src/journal/journalctl.c @@ -344,7 +344,7 @@ static int help_facilities(void) { for (int i = 0; i < LOG_NFACILITIES; i++) { _cleanup_free_ char *t = NULL; - if (log_facility_unshifted_to_string_alloc(i, &t)) + if (log_facility_unshifted_to_string_alloc(i, &t) < 0) return log_oom(); puts(t); }