]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
journal-gateway: use journal_add_match_pair() and add_match_boot_id()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Thu, 21 Mar 2024 20:26:02 +0000 (05:26 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 25 Mar 2024 12:39:37 +0000 (21:39 +0900)
src/journal-remote/journal-gatewayd.c

index d88436018c7b076be36f5015546859886231e93b..c7472538581d183fef76a025faba3d596eb78848 100644 (file)
@@ -22,6 +22,7 @@
 #include "fileio.h"
 #include "glob-util.h"
 #include "hostname-util.h"
+#include "journal-internal.h"
 #include "journal-remote.h"
 #include "log.h"
 #include "logs-show.h"
@@ -460,7 +461,6 @@ static mhd_result request_parse_arguments_iterator(
                 const char *value) {
 
         RequestMeta *m = ASSERT_PTR(cls);
-        _cleanup_free_ char *p = NULL;
         int r;
 
         if (isempty(key)) {
@@ -512,7 +512,6 @@ static mhd_result request_parse_arguments_iterator(
                 }
 
                 if (r) {
-                        char match[9 + 32 + 1] = "_BOOT_ID=";
                         sd_id128_t bid;
 
                         r = sd_id128_get_boot(&bid);
@@ -521,8 +520,7 @@ static mhd_result request_parse_arguments_iterator(
                                 return MHD_NO;
                         }
 
-                        sd_id128_to_string(bid, match + 9);
-                        r = sd_journal_add_match(m->journal, match, sizeof(match)-1);
+                        r = add_match_boot_id(m->journal, bid);
                         if (r < 0) {
                                 m->argument_parse_error = r;
                                 return MHD_NO;
@@ -532,13 +530,7 @@ static mhd_result request_parse_arguments_iterator(
                 return MHD_YES;
         }
 
-        p = strjoin(key, "=", strempty(value));
-        if (!p) {
-                m->argument_parse_error = log_oom();
-                return MHD_NO;
-        }
-
-        r = sd_journal_add_match(m->journal, p, 0);
+        r = journal_add_match_pair(m->journal, key, strempty(value));
         if (r < 0) {
                 m->argument_parse_error = r;
                 return MHD_NO;