summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/analyze/analyze.c2
-rw-r--r--src/hostname/hostnamectl.c58
-rw-r--r--src/locale/localectl.c20
-rw-r--r--src/login/loginctl.c97
-rw-r--r--src/machine/machinectl.c54
-rw-r--r--src/resolve/resolve-tool.c15
-rw-r--r--src/run/run.c1
-rw-r--r--src/shared/bus-util.c26
-rw-r--r--src/shared/bus-util.h6
-rw-r--r--src/systemctl/systemctl.c33
-rw-r--r--src/timedate/timedatectl.c21
11 files changed, 132 insertions, 201 deletions
diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c
index 1bed16e219..22f634ac5c 100644
--- a/src/analyze/analyze.c
+++ b/src/analyze/analyze.c
@@ -474,6 +474,7 @@ static int acquire_host_info(sd_bus *bus, struct host_info **hi) {
"/org/freedesktop/hostname1",
hostname_map,
&error,
+ NULL,
host);
if (r < 0)
log_debug_errno(r, "Failed to get host information from systemd-hostnamed: %s", bus_error_message(&error, r));
@@ -483,6 +484,7 @@ static int acquire_host_info(sd_bus *bus, struct host_info **hi) {
"/org/freedesktop/systemd1",
manager_map,
&error,
+ NULL,
host);
if (r < 0)
return log_error_errno(r, "Failed to get host information from systemd: %s", bus_error_message(&error, r));
diff --git a/src/hostname/hostnamectl.c b/src/hostname/hostnamectl.c
index c545caa4bf..baa48c7f71 100644
--- a/src/hostname/hostnamectl.c
+++ b/src/hostname/hostnamectl.c
@@ -44,19 +44,19 @@ static bool arg_pretty = false;
static bool arg_static = false;
typedef struct StatusInfo {
- char *hostname;
- char *static_hostname;
- char *pretty_hostname;
- char *icon_name;
- char *chassis;
- char *deployment;
- char *location;
- char *kernel_name;
- char *kernel_release;
- char *os_pretty_name;
- char *os_cpe_name;
- char *virtualization;
- char *architecture;
+ const char *hostname;
+ const char *static_hostname;
+ const char *pretty_hostname;
+ const char *icon_name;
+ const char *chassis;
+ const char *deployment;
+ const char *location;
+ const char *kernel_name;
+ const char *kernel_release;
+ const char *os_pretty_name;
+ const char *os_cpe_name;
+ const char *virtualization;
+ const char *architecture;
} StatusInfo;
static void print_status_info(StatusInfo *i) {
@@ -163,6 +163,7 @@ static int show_all_names(sd_bus *bus, sd_bus_error *error) {
{}
};
+ _cleanup_(sd_bus_message_unrefp) sd_bus_message *host_message = NULL, *manager_message = NULL;
int r;
r = bus_map_all_properties(bus,
@@ -170,34 +171,21 @@ static int show_all_names(sd_bus *bus, sd_bus_error *error) {
"/org/freedesktop/hostname1",
hostname_map,
error,
+ &host_message,
&info);
if (r < 0)
- goto fail;
+ return r;
- bus_map_all_properties(bus,
- "org.freedesktop.systemd1",
- "/org/freedesktop/systemd1",
- manager_map,
- error,
- &info);
+ r = bus_map_all_properties(bus,
+ "org.freedesktop.systemd1",
+ "/org/freedesktop/systemd1",
+ manager_map,
+ error,
+ &manager_message,
+ &info);
print_status_info(&info);
-fail:
- free(info.hostname);
- free(info.static_hostname);
- free(info.pretty_hostname);
- free(info.icon_name);
- free(info.chassis);
- free(info.deployment);
- free(info.location);
- free(info.kernel_name);
- free(info.kernel_release);
- free(info.os_pretty_name);
- free(info.os_cpe_name);
- free(info.virtualization);
- free(info.architecture);
-
return r;
}
diff --git a/src/locale/localectl.c b/src/locale/localectl.c
index f50d31a29b..550e97b3ed 100644
--- a/src/locale/localectl.c
+++ b/src/locale/localectl.c
@@ -50,23 +50,17 @@ static bool arg_convert = true;
typedef struct StatusInfo {
char **locale;
- char *vconsole_keymap;
- char *vconsole_keymap_toggle;
- char *x11_layout;
- char *x11_model;
- char *x11_variant;
- char *x11_options;
+ const char *vconsole_keymap;
+ const char *vconsole_keymap_toggle;
+ const char *x11_layout;
+ const char *x11_model;
+ const char *x11_variant;
+ const char *x11_options;
} StatusInfo;
static void status_info_clear(StatusInfo *info) {
if (info) {
strv_free(info->locale);
- free(info->vconsole_keymap);
- free(info->vconsole_keymap_toggle);
- free(info->x11_layout);
- free(info->x11_model);
- free(info->x11_variant);
- free(info->x11_options);
zero(*info);
}
}
@@ -158,6 +152,7 @@ static int show_status(int argc, char **argv, void *userdata) {
};
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
+ _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
sd_bus *bus = userdata;
int r;
@@ -168,6 +163,7 @@ static int show_status(int argc, char **argv, void *userdata) {
"/org/freedesktop/locale1",
map,
&error,
+ &m,
&info);
if (r < 0)
return log_error_errno(r, "Could not get properties: %s", bus_error_message(&error, r));
diff --git a/src/login/loginctl.c b/src/login/loginctl.c
index 2f53a2740d..403ba40c1c 100644
--- a/src/login/loginctl.c
+++ b/src/login/loginctl.c
@@ -307,77 +307,52 @@ static int show_unit_cgroup(sd_bus *bus, const char *interface, const char *unit
}
typedef struct SessionStatusInfo {
- char *id;
+ const char *id;
uid_t uid;
- char *name;
+ const char *name;
struct dual_timestamp timestamp;
unsigned int vtnr;
- char *seat;
- char *tty;
- char *display;
- int remote;
- char *remote_host;
- char *remote_user;
- char *service;
+ const char *seat;
+ const char *tty;
+ const char *display;
+ bool remote;
+ const char *remote_host;
+ const char *remote_user;
+ const char *service;
pid_t leader;
- char *type;
- char *class;
- char *state;
- char *scope;
- char *desktop;
+ const char *type;
+ const char *class;
+ const char *state;
+ const char *scope;
+ const char *desktop;
} SessionStatusInfo;
typedef struct UserStatusInfo {
uid_t uid;
- int linger;
- char *name;
+ bool linger;
+ const char *name;
struct dual_timestamp timestamp;
- char *state;
+ const char *state;
char **sessions;
- char *display;
- char *slice;
+ const char *display;
+ const char *slice;
} UserStatusInfo;
typedef struct SeatStatusInfo {
- char *id;
- char *active_session;
+ const char *id;
+ const char *active_session;
char **sessions;
} SeatStatusInfo;
-static void session_status_info_clear(SessionStatusInfo *info) {
- if (info) {
- free(info->id);
- free(info->name);
- free(info->seat);
- free(info->tty);
- free(info->display);
- free(info->remote_host);
- free(info->remote_user);
- free(info->service);
- free(info->type);
- free(info->class);
- free(info->state);
- free(info->scope);
- free(info->desktop);
- zero(*info);
- }
-}
-
static void user_status_info_clear(UserStatusInfo *info) {
if (info) {
- free(info->name);
- free(info->state);
strv_free(info->sessions);
- free(info->display);
- free(info->slice);
zero(*info);
}
}
static void seat_status_info_clear(SeatStatusInfo *info) {
if (info) {
- free(info->id);
- free(info->active_session);
strv_free(info->sessions);
zero(*info);
}
@@ -395,22 +370,9 @@ static int prop_map_first_of_struct(sd_bus *bus, const char *member, sd_bus_mess
if (r < 0)
return r;
- if (IN_SET(contents[0], 's', 'o')) {
- const char *s;
- char **p = (char **) userdata;
-
- r = sd_bus_message_read_basic(m, contents[0], &s);
- if (r < 0)
- return r;
-
- r = free_and_strdup(p, s);
- if (r < 0)
- return r;
- } else {
- r = sd_bus_message_read_basic(m, contents[0], userdata);
- if (r < 0)
- return r;
- }
+ r = sd_bus_message_read_basic(m, contents[0], userdata);
+ if (r < 0)
+ return r;
r = sd_bus_message_skip(m, contents+1);
if (r < 0)
@@ -471,12 +433,13 @@ static int print_session_status_info(sd_bus *bus, const char *path, bool *new_li
};
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
+ _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
char since1[FORMAT_TIMESTAMP_RELATIVE_MAX], *s1;
char since2[FORMAT_TIMESTAMP_MAX], *s2;
- _cleanup_(session_status_info_clear) SessionStatusInfo i = {};
+ SessionStatusInfo i = {};
int r;
- r = bus_map_all_properties(bus, "org.freedesktop.login1", path, map, &error, &i);
+ r = bus_map_all_properties(bus, "org.freedesktop.login1", path, map, &error, &m, &i);
if (r < 0)
return log_error_errno(r, "Could not get properties: %s", bus_error_message(&error, r));
@@ -601,12 +564,13 @@ static int print_user_status_info(sd_bus *bus, const char *path, bool *new_line)
};
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
+ _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
char since1[FORMAT_TIMESTAMP_RELATIVE_MAX], *s1;
char since2[FORMAT_TIMESTAMP_MAX], *s2;
_cleanup_(user_status_info_clear) UserStatusInfo i = {};
int r;
- r = bus_map_all_properties(bus, "org.freedesktop.login1", path, map, &error, &i);
+ r = bus_map_all_properties(bus, "org.freedesktop.login1", path, map, &error, &m, &i);
if (r < 0)
return log_error_errno(r, "Could not get properties: %s", bus_error_message(&error, r));
@@ -676,10 +640,11 @@ static int print_seat_status_info(sd_bus *bus, const char *path, bool *new_line)
};
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
+ _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
_cleanup_(seat_status_info_clear) SeatStatusInfo i = {};
int r;
- r = bus_map_all_properties(bus, "org.freedesktop.login1", path, map, &error, &i);
+ r = bus_map_all_properties(bus, "org.freedesktop.login1", path, map, &error, &m, &i);
if (r < 0)
return log_error_errno(r, "Could not get properties: %s", bus_error_message(&error, r));
diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c
index 9180ec4725..d4b8c15272 100644
--- a/src/machine/machinectl.c
+++ b/src/machine/machinectl.c
@@ -639,12 +639,12 @@ static int print_uid_shift(sd_bus *bus, const char *name) {
}
typedef struct MachineStatusInfo {
- char *name;
+ const char *name;
sd_id128_t id;
- char *class;
- char *service;
- char *unit;
- char *root_directory;
+ const char *class;
+ const char *service;
+ const char *unit;
+ const char *root_directory;
pid_t leader;
struct dual_timestamp timestamp;
int *netif;
@@ -653,11 +653,6 @@ typedef struct MachineStatusInfo {
static void machine_status_info_clear(MachineStatusInfo *info) {
if (info) {
- free(info->name);
- free(info->class);
- free(info->service);
- free(info->unit);
- free(info->root_directory);
free(info->netif);
zero(*info);
}
@@ -803,6 +798,7 @@ static int show_machine_info(const char *verb, sd_bus *bus, const char *path, bo
};
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
+ _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
_cleanup_(machine_status_info_clear) MachineStatusInfo info = {};
int r;
@@ -816,6 +812,7 @@ static int show_machine_info(const char *verb, sd_bus *bus, const char *path, bo
path,
map,
&error,
+ &m,
&info);
if (r < 0)
return log_error_errno(r, "Could not get properties: %s", bus_error_message(&error, r));
@@ -994,10 +991,10 @@ static int print_image_machine_info(sd_bus *bus, const char *name) {
}
typedef struct ImageStatusInfo {
- char *name;
- char *path;
- char *type;
- int read_only;
+ const char *name;
+ const char *path;
+ const char *type;
+ bool read_only;
usec_t crtime;
usec_t mtime;
uint64_t usage;
@@ -1006,16 +1003,6 @@ typedef struct ImageStatusInfo {
uint64_t limit_exclusive;
} ImageStatusInfo;
-static void image_status_info_clear(ImageStatusInfo *info) {
- if (!info)
- return;
-
- free(info->name);
- free(info->path);
- free(info->type);
- zero(*info);
-}
-
static void print_image_status_info(sd_bus *bus, ImageStatusInfo *i) {
char ts_relative[FORMAT_TIMESTAMP_RELATIVE_MAX], *s1;
char ts_absolute[FORMAT_TIMESTAMP_MAX], *s2;
@@ -1093,7 +1080,8 @@ static int show_image_info(sd_bus *bus, const char *path, bool *new_line) {
};
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
- _cleanup_(image_status_info_clear) ImageStatusInfo info = {};
+ _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
+ ImageStatusInfo info = {};
int r;
assert(bus);
@@ -1105,6 +1093,7 @@ static int show_image_info(sd_bus *bus, const char *path, bool *new_line) {
path,
map,
&error,
+ &m,
&info);
if (r < 0)
return log_error_errno(r, "Could not get properties: %s", bus_error_message(&error, r));
@@ -1119,20 +1108,11 @@ static int show_image_info(sd_bus *bus, const char *path, bool *new_line) {
}
typedef struct PoolStatusInfo {
- char *path;
+ const char *path;
uint64_t usage;
uint64_t limit;
} PoolStatusInfo;
-static void pool_status_info_clear(PoolStatusInfo *info) {
- if (info) {
- free(info->path);
- zero(*info);
- info->usage = -1;
- info->limit = -1;
- }
-}
-
static void print_pool_status_info(sd_bus *bus, PoolStatusInfo *i) {
char bs[FORMAT_BYTES_MAX], *s;
@@ -1157,12 +1137,13 @@ static int show_pool_info(sd_bus *bus) {
{}
};
- _cleanup_(pool_status_info_clear) PoolStatusInfo info = {
+ PoolStatusInfo info = {
.usage = (uint64_t) -1,
.limit = (uint64_t) -1,
};
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
+ _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
int r;
assert(bus);
@@ -1172,6 +1153,7 @@ static int show_pool_info(sd_bus *bus) {
"/org/freedesktop/machine1",
map,
&error,
+ &m,
&info);
if (r < 0)
return log_error_errno(r, "Could not get properties: %s", bus_error_message(&error, r));
diff --git a/src/resolve/resolve-tool.c b/src/resolve/resolve-tool.c
index d1395b2e2c..c757e59ecb 100644
--- a/src/resolve/resolve-tool.c
+++ b/src/resolve/resolve-tool.c
@@ -1185,13 +1185,13 @@ static int status_ifindex(sd_bus *bus, int ifindex, const char *name, bool *empt
struct link_info {
uint64_t scopes_mask;
- char *llmnr;
- char *mdns;
- char *dnssec;
+ const char *llmnr;
+ const char *mdns;
+ const char *dnssec;
char **dns;
char **domains;
char **ntas;
- int dnssec_supported;
+ bool dnssec_supported;
} link_info = {};
static const struct bus_properties_map property_map[] = {
@@ -1207,6 +1207,7 @@ static int status_ifindex(sd_bus *bus, int ifindex, const char *name, bool *empt
};
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
+ _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
_cleanup_free_ char *ifi = NULL, *p = NULL;
char ifname[IF_NAMESIZE] = "";
char **i;
@@ -1235,6 +1236,7 @@ static int status_ifindex(sd_bus *bus, int ifindex, const char *name, bool *empt
p,
property_map,
&error,
+ &m,
&link_info);
if (r < 0) {
log_error_errno(r, "Failed to get link data for %i: %s", ifindex, bus_error_message(&error, r));
@@ -1293,9 +1295,6 @@ static int status_ifindex(sd_bus *bus, int ifindex, const char *name, bool *empt
finish:
strv_free(link_info.dns);
strv_free(link_info.domains);
- free(link_info.llmnr);
- free(link_info.mdns);
- free(link_info.dnssec);
strv_free(link_info.ntas);
return r;
}
@@ -1428,6 +1427,7 @@ static int status_global(sd_bus *bus, bool *empty_line) {
};
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
+ _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
char **i;
int r;
@@ -1439,6 +1439,7 @@ static int status_global(sd_bus *bus, bool *empty_line) {
"/org/freedesktop/resolve1",
property_map,
&error,
+ &m,
&global_info);
if (r < 0) {
log_error_errno(r, "Failed to get global data: %s", bus_error_message(&error, r));
diff --git a/src/run/run.c b/src/run/run.c
index a30501169c..cfab3d6f97 100644
--- a/src/run/run.c
+++ b/src/run/run.c
@@ -876,6 +876,7 @@ static int run_context_update(RunContext *c, const char *path) {
path,
map,
&error,
+ NULL,
c);
if (r < 0) {
sd_event_exit(c->event, EXIT_FAILURE);
diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c
index 8699ed5ce2..2336338102 100644
--- a/src/shared/bus-util.c
+++ b/src/shared/bus-util.c
@@ -1020,7 +1020,7 @@ int bus_map_id128(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_err
return 0;
}
-static int map_basic(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata) {
+static int map_basic(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata, bool copy_string) {
char type;
int r;
@@ -1031,7 +1031,7 @@ static int map_basic(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_
switch (type) {
case SD_BUS_TYPE_STRING: {
- char **p = userdata;
+ const char **p = userdata;
const char *s;
r = sd_bus_message_read_basic(m, type, &s);
@@ -1041,7 +1041,11 @@ static int map_basic(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_
if (isempty(s))
s = NULL;
- return free_and_strdup(p, s);
+ if (copy_string)
+ return free_and_strdup((char **) userdata, s);
+
+ *p = s;
+ return 0;
}
case SD_BUS_TYPE_ARRAY: {
@@ -1111,6 +1115,7 @@ static int map_basic(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_
int bus_message_map_all_properties(
sd_bus_message *m,
const struct bus_properties_map *map,
+ bool copy_string,
sd_bus_error *error,
void *userdata) {
@@ -1153,7 +1158,7 @@ int bus_message_map_all_properties(
if (map[i].set)
r = prop->set(sd_bus_message_get_bus(m), member, m, error, v);
else
- r = map_basic(sd_bus_message_get_bus(m), member, m, error, v);
+ r = map_basic(sd_bus_message_get_bus(m), member, m, error, v, copy_string);
if (r < 0)
return r;
@@ -1179,6 +1184,7 @@ int bus_message_map_all_properties(
int bus_message_map_properties_changed(
sd_bus_message *m,
const struct bus_properties_map *map,
+ bool copy_string,
sd_bus_error *error,
void *userdata) {
@@ -1188,7 +1194,7 @@ int bus_message_map_properties_changed(
assert(m);
assert(map);
- r = bus_message_map_all_properties(m, map, error, userdata);
+ r = bus_message_map_all_properties(m, map, copy_string, error, userdata);
if (r < 0)
return r;
@@ -1219,6 +1225,7 @@ int bus_map_all_properties(
const char *path,
const struct bus_properties_map *map,
sd_bus_error *error,
+ sd_bus_message **reply,
void *userdata) {
_cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
@@ -1241,7 +1248,14 @@ int bus_map_all_properties(
if (r < 0)
return r;
- return bus_message_map_all_properties(m, map, error, userdata);
+ r = bus_message_map_all_properties(m, map, !reply, error, userdata);
+ if (r < 0)
+ return r;
+
+ if (reply)
+ *reply = sd_bus_message_ref(m);
+
+ return r;
}
int bus_connect_transport(BusTransport transport, const char *host, bool user, sd_bus **ret) {
diff --git a/src/shared/bus-util.h b/src/shared/bus-util.h
index 8103f0e9a7..5e1fe893f9 100644
--- a/src/shared/bus-util.h
+++ b/src/shared/bus-util.h
@@ -51,9 +51,9 @@ struct bus_properties_map {
int bus_map_id128(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata);
-int bus_message_map_all_properties(sd_bus_message *m, const struct bus_properties_map *map, sd_bus_error *error, void *userdata);
-int bus_message_map_properties_changed(sd_bus_message *m, const struct bus_properties_map *map, sd_bus_error *error, void *userdata);
-int bus_map_all_properties(sd_bus *bus, const char *destination, const char *path, const struct bus_properties_map *map, sd_bus_error *error, void *userdata);
+int bus_message_map_all_properties(sd_bus_message *m, const struct bus_properties_map *map, bool copy_string, sd_bus_error *error, void *userdata);
+int bus_message_map_properties_changed(sd_bus_message *m, const struct bus_properties_map *map, bool copy_string, sd_bus_error *error, void *userdata);
+int bus_map_all_properties(sd_bus *bus, const char *destination, const char *path, const struct bus_properties_map *map, sd_bus_error *error, sd_bus_message **reply, void *userdata);
int bus_async_unregister_and_exit(sd_event *e, sd_bus *bus, const char *name);
diff --git a/src/systemctl/systemctl.c b/src/systemctl/systemctl.c
index 5624d34b50..6f2074dbde 100644
--- a/src/systemctl/systemctl.c
+++ b/src/systemctl/systemctl.c
@@ -250,21 +250,6 @@ static void release_busses(void) {
busses[w] = sd_bus_flush_close_unref(busses[w]);
}
-static int map_string_no_copy(sd_bus *bus, const char *member, sd_bus_message *m, sd_bus_error *error, void *userdata) {
- char *s;
- const char **p = userdata;
- int r;
-
- r = sd_bus_message_read_basic(m, SD_BUS_TYPE_STRING, &s);
- if (r < 0)
- return r;
-
- if (!isempty(s))
- *p = s;
-
- return 0;
-}
-
static void ask_password_agent_open_if_enabled(void) {
/* Open the password agent as a child process if necessary */
@@ -1701,6 +1686,7 @@ static int list_dependencies_get_dependencies(sd_bus *bus, const char *name, cha
path,
map[arg_dependency],
&error,
+ NULL,
&info);
if (r < 0)
return log_error_errno(r, "Failed to get properties of %s: %s", name, bus_error_message(&error, r));
@@ -1905,7 +1891,7 @@ static int get_machine_properties(sd_bus *bus, struct machine_info *mi) {
bus = container;
}
- r = bus_map_all_properties(bus, "org.freedesktop.systemd1", "/org/freedesktop/systemd1", machine_info_property_map, NULL, mi);
+ r = bus_map_all_properties(bus, "org.freedesktop.systemd1", "/org/freedesktop/systemd1", machine_info_property_map, NULL, NULL, mi);
if (r < 0)
return r;
@@ -5119,8 +5105,8 @@ static int show_one(
bool *ellipsized) {
static const struct bus_properties_map property_map[] = {
- { "LoadState", "s", map_string_no_copy, offsetof(UnitStatusInfo, load_state) },
- { "ActiveState", "s", map_string_no_copy, offsetof(UnitStatusInfo, active_state) },
+ { "LoadState", "s", NULL, offsetof(UnitStatusInfo, load_state) },
+ { "ActiveState", "s", NULL, offsetof(UnitStatusInfo, active_state) },
{}
};
@@ -5159,7 +5145,7 @@ static int show_one(
return log_error_errno(r, "Failed to get properties: %s", bus_error_message(&error, r));
if (unit) {
- r = bus_message_map_all_properties(reply, property_map, &error, &info);
+ r = bus_message_map_all_properties(reply, property_map, false, &error, &info);
if (r < 0)
return log_error_errno(r, "Failed to map properties: %s", bus_error_message(&error, r));
@@ -5341,7 +5327,7 @@ static int show_system_status(sd_bus *bus) {
if (!hn)
return log_oom();
- r = bus_map_all_properties(bus, "org.freedesktop.systemd1", "/org/freedesktop/systemd1", machine_info_property_map, &error, &mi);
+ r = bus_map_all_properties(bus, "org.freedesktop.systemd1", "/org/freedesktop/systemd1", machine_info_property_map, &error, NULL, &mi);
if (r < 0)
return log_error_errno(r, "Failed to read server status: %s", bus_error_message(&error, r));
@@ -6256,10 +6242,11 @@ static int normalize_names(char **names, bool warn_if_path) {
static int unit_exists(LookupPaths *lp, const char *unit) {
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
+ _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
_cleanup_free_ char *path = NULL;
static const struct bus_properties_map property_map[] = {
- { "LoadState", "s", map_string_no_copy, offsetof(UnitStatusInfo, load_state) },
- { "ActiveState", "s", map_string_no_copy, offsetof(UnitStatusInfo, active_state)},
+ { "LoadState", "s", NULL, offsetof(UnitStatusInfo, load_state) },
+ { "ActiveState", "s", NULL, offsetof(UnitStatusInfo, active_state)},
{},
};
UnitStatusInfo info = {};
@@ -6277,7 +6264,7 @@ static int unit_exists(LookupPaths *lp, const char *unit) {
if (r < 0)
return r;
- r = bus_map_all_properties(bus, "org.freedesktop.systemd1", path, property_map, &error, &info);
+ r = bus_map_all_properties(bus, "org.freedesktop.systemd1", path, property_map, &error, &m, &info);
if (r < 0)
return log_error_errno(r, "Failed to get properties: %s", bus_error_message(&error, r));
diff --git a/src/timedate/timedatectl.c b/src/timedate/timedatectl.c
index d390e24e62..a9bb8aacde 100644
--- a/src/timedate/timedatectl.c
+++ b/src/timedate/timedatectl.c
@@ -44,23 +44,16 @@ static bool arg_adjust_system_clock = false;
typedef struct StatusInfo {
usec_t time;
- char *timezone;
+ const char *timezone;
usec_t rtc_time;
- int rtc_local;
+ bool rtc_local;
- int ntp_enabled;
- int ntp_capable;
- int ntp_synced;
+ bool ntp_enabled;
+ bool ntp_capable;
+ bool ntp_synced;
} StatusInfo;
-static void status_info_clear(StatusInfo *info) {
- if (info) {
- free(info->timezone);
- zero(*info);
- }
-}
-
static void print_status_info(const StatusInfo *i) {
char a[LINE_MAX];
struct tm tm;
@@ -145,7 +138,7 @@ static void print_status_info(const StatusInfo *i) {
}
static int show_status(int argc, char **argv, void *userdata) {
- _cleanup_(status_info_clear) StatusInfo info = {};
+ StatusInfo info = {};
static const struct bus_properties_map map[] = {
{ "Timezone", "s", NULL, offsetof(StatusInfo, timezone) },
{ "LocalRTC", "b", NULL, offsetof(StatusInfo, rtc_local) },
@@ -158,6 +151,7 @@ static int show_status(int argc, char **argv, void *userdata) {
};
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
+ _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL;
sd_bus *bus = userdata;
int r;
@@ -168,6 +162,7 @@ static int show_status(int argc, char **argv, void *userdata) {
"/org/freedesktop/timedate1",
map,
&error,
+ &m,
&info);
if (r < 0)
return log_error_errno(r, "Failed to query server: %s", bus_error_message(&error, r));