summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Yuan <me@yhndnzj.com>2025-01-11 16:52:05 +0100
committerMike Yuan <me@yhndnzj.com>2025-01-13 16:24:44 +0100
commitab33edb05b7d4c90fb80f46aa6b951c505048798 (patch)
tree5e9f81f09ad49b3fc1bd1f55c39d4453b330c8ac
parenttmpfiles: move two commands to the right --help sections (diff)
downloadsystemd-ab33edb05b7d4c90fb80f46aa6b951c505048798.tar.xz
systemd-ab33edb05b7d4c90fb80f46aa6b951c505048798.zip
shared/bus-util: move bus_message_read_id128() to bus-message-util
-rw-r--r--src/core/dbus-manager.c1
-rw-r--r--src/hostname/hostnamectl.c1
-rw-r--r--src/machine/machinectl.c1
-rw-r--r--src/machine/machined-dbus.c1
-rw-r--r--src/run/run.c1
-rw-r--r--src/shared/bus-map-properties.c1
-rw-r--r--src/shared/bus-message-util.c29
-rw-r--r--src/shared/bus-message-util.h2
-rw-r--r--src/shared/bus-util.c28
-rw-r--r--src/shared/bus-util.h2
10 files changed, 37 insertions, 30 deletions
diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c
index 99e3ea12ac..4b61002eac 100644
--- a/src/core/dbus-manager.c
+++ b/src/core/dbus-manager.c
@@ -12,6 +12,7 @@
#include "bus-common-errors.h"
#include "bus-get-properties.h"
#include "bus-log-control-api.h"
+#include "bus-message-util.h"
#include "bus-util.h"
#include "chase.h"
#include "confidential-virt.h"
diff --git a/src/hostname/hostnamectl.c b/src/hostname/hostnamectl.c
index cd4f86af80..2d1334f654 100644
--- a/src/hostname/hostnamectl.c
+++ b/src/hostname/hostnamectl.c
@@ -18,6 +18,7 @@
#include "bus-error.h"
#include "bus-locator.h"
#include "bus-map-properties.h"
+#include "bus-message-util.h"
#include "format-table.h"
#include "hostname-setup.h"
#include "hostname-util.h"
diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c
index 39d3f3aed8..91bef1a5e9 100644
--- a/src/machine/machinectl.c
+++ b/src/machine/machinectl.c
@@ -21,6 +21,7 @@
#include "bus-error.h"
#include "bus-locator.h"
#include "bus-map-properties.h"
+#include "bus-message-util.h"
#include "bus-print-properties.h"
#include "bus-unit-procs.h"
#include "bus-unit-util.h"
diff --git a/src/machine/machined-dbus.c b/src/machine/machined-dbus.c
index fc50d3f147..e50ed7e0df 100644
--- a/src/machine/machined-dbus.c
+++ b/src/machine/machined-dbus.c
@@ -10,6 +10,7 @@
#include "bus-common-errors.h"
#include "bus-get-properties.h"
#include "bus-locator.h"
+#include "bus-message-util.h"
#include "bus-polkit.h"
#include "cgroup-util.h"
#include "discover-image.h"
diff --git a/src/run/run.c b/src/run/run.c
index 28953a6514..4a7a5d939c 100644
--- a/src/run/run.c
+++ b/src/run/run.c
@@ -15,6 +15,7 @@
#include "bus-error.h"
#include "bus-locator.h"
#include "bus-map-properties.h"
+#include "bus-message-util.h"
#include "bus-unit-util.h"
#include "bus-wait-for-jobs.h"
#include "calendarspec.h"
diff --git a/src/shared/bus-map-properties.c b/src/shared/bus-map-properties.c
index a6cd752894..18d83c336f 100644
--- a/src/shared/bus-map-properties.c
+++ b/src/shared/bus-map-properties.c
@@ -5,6 +5,7 @@
#include "bus-util.h"
#include "strv.h"
#include "bus-message.h"
+#include "bus-message-util.h"
int bus_map_id128(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata) {
sd_id128_t *p = userdata;
diff --git a/src/shared/bus-message-util.c b/src/shared/bus-message-util.c
index d8c483ef62..e93be9b3c5 100644
--- a/src/shared/bus-message-util.c
+++ b/src/shared/bus-message-util.c
@@ -7,6 +7,35 @@
#include "copy.h"
#include "resolve-util.h"
+int bus_message_read_id128(sd_bus_message *m, sd_id128_t *ret) {
+ const void *a;
+ size_t sz;
+ int r;
+
+ assert(m);
+
+ r = sd_bus_message_read_array(m, 'y', &a, &sz);
+ if (r < 0)
+ return r;
+
+ switch (sz) {
+
+ case 0:
+ if (ret)
+ *ret = SD_ID128_NULL;
+ return 0;
+
+ case sizeof(sd_id128_t):
+ if (ret)
+ memcpy(ret, a, sz);
+ return !memeqzero(a, sz); /* This mimics sd_id128_is_null(), but ret may be NULL,
+ * and a may be misaligned, so use memeqzero() here. */
+
+ default:
+ return -EINVAL;
+ }
+}
+
int bus_message_read_ifindex(sd_bus_message *message, sd_bus_error *error, int *ret) {
int ifindex, r;
diff --git a/src/shared/bus-message-util.h b/src/shared/bus-message-util.h
index 50025766c2..698960561c 100644
--- a/src/shared/bus-message-util.h
+++ b/src/shared/bus-message-util.h
@@ -6,6 +6,8 @@
#include "in-addr-util.h"
#include "socket-netlink.h"
+int bus_message_read_id128(sd_bus_message *m, sd_id128_t *ret);
+
int bus_message_read_ifindex(sd_bus_message *message, sd_bus_error *error, int *ret);
int bus_message_read_family(sd_bus_message *message, sd_bus_error *error, int *ret);
int bus_message_read_in_addr_auto(sd_bus_message *message, sd_bus_error *error, int *ret_family, union in_addr_union *ret_addr);
diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c
index e38433ddc0..d6189deb18 100644
--- a/src/shared/bus-util.c
+++ b/src/shared/bus-util.c
@@ -953,34 +953,6 @@ int bus_query_sender_pidref(
return bus_creds_get_pidref(creds, ret);
}
-int bus_message_read_id128(sd_bus_message *m, sd_id128_t *ret) {
- const void *a;
- size_t sz;
- int r;
-
- assert(m);
-
- r = sd_bus_message_read_array(m, 'y', &a, &sz);
- if (r < 0)
- return r;
-
- switch (sz) {
- case 0:
- if (ret)
- *ret = SD_ID128_NULL;
- return 0;
-
- case sizeof(sd_id128_t):
- if (ret)
- memcpy(ret, a, sz);
- return !memeqzero(a, sz); /* This mimics sd_id128_is_null(), but ret may be NULL,
- * and a may be misaligned, so use memeqzero() here. */
-
- default:
- return -EINVAL;
- }
-}
-
static const char* const bus_transport_table[] = {
[BUS_TRANSPORT_LOCAL] = "local",
[BUS_TRANSPORT_REMOTE] = "remote",
diff --git a/src/shared/bus-util.h b/src/shared/bus-util.h
index 95b9adb7b1..b08635fd36 100644
--- a/src/shared/bus-util.h
+++ b/src/shared/bus-util.h
@@ -87,6 +87,4 @@ int bus_property_get_string_set(sd_bus *bus, const char *path, const char *inter
int bus_creds_get_pidref(sd_bus_creds *c, PidRef *ret);
int bus_query_sender_pidref(sd_bus_message *m, PidRef *ret);
-int bus_message_read_id128(sd_bus_message *m, sd_id128_t *ret);
-
const char* bus_transport_to_string(BusTransport transport) _const_;