summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2024-03-21 21:33:08 +0100
committerYu Watanabe <watanabe.yu+github@gmail.com>2024-03-25 13:39:37 +0100
commit077f63264fe79142f50d5413f51193086dddb2d4 (patch)
tree008cc050e994a9c316e8a74ff9c3f4b44a27bdac /src
parentjournal-gateway: use journal_add_match_pair() and add_match_boot_id() (diff)
downloadsystemd-077f63264fe79142f50d5413f51193086dddb2d4.tar.xz
systemd-077f63264fe79142f50d5413f51193086dddb2d4.zip
networkctl: use journal_add_matchf() and journal_add_match_pair()
Diffstat (limited to 'src')
-rw-r--r--src/network/networkctl.c19
1 files changed, 5 insertions, 14 deletions
diff --git a/src/network/networkctl.c b/src/network/networkctl.c
index 117789c6e6..fab9ff465b 100644
--- a/src/network/networkctl.c
+++ b/src/network/networkctl.c
@@ -37,6 +37,7 @@
#include "glob-util.h"
#include "hwdb-util.h"
#include "ipvlan-util.h"
+#include "journal-internal.h"
#include "local-addresses.h"
#include "locale-util.h"
#include "logs-show.h"
@@ -1613,22 +1614,12 @@ static int show_logs(const LinkInfo *info) {
return log_error_errno(r, "Failed to add boot matches: %m");
if (info) {
- char m1[STRLEN("_KERNEL_DEVICE=n") + DECIMAL_STR_MAX(int)];
- const char *m2, *m3;
-
- /* kernel */
- xsprintf(m1, "_KERNEL_DEVICE=n%i", info->ifindex);
- /* networkd */
- m2 = strjoina("INTERFACE=", info->name);
- /* udevd */
- m3 = strjoina("DEVICE=", info->name);
-
- (void)(
- (r = sd_journal_add_match(j, m1, 0)) ||
+ (void) (
+ (r = journal_add_matchf(j, "_KERNEL_DEVICE=n%i", info->ifindex)) || /* kernel */
(r = sd_journal_add_disjunction(j)) ||
- (r = sd_journal_add_match(j, m2, 0)) ||
+ (r = journal_add_match_pair(j, "INTERFACE", info->name)) || /* networkd */
(r = sd_journal_add_disjunction(j)) ||
- (r = sd_journal_add_match(j, m3, 0))
+ (r = journal_add_match_pair(j, "DEVICE", info->name)) /* udevd */
);
if (r < 0)
return log_error_errno(r, "Failed to add link matches: %m");