network: use bus_error_message()

This commit is contained in:
Yu Watanabe 2020-11-24 15:58:04 +09:00
parent 0f82a2ab5c
commit f63e09ef75
2 changed files with 19 additions and 13 deletions

View File

@ -3,6 +3,7 @@
#include <netinet/in.h>
#include <linux/if_arp.h>
#include "bus-error.h"
#include "dhcp-internal.h"
#include "dhcp6-internal.h"
#include "escape.h"
@ -99,18 +100,20 @@ static int get_product_uuid_handler(sd_bus_message *m, void *userdata, sd_bus_er
e = sd_bus_message_get_error(m);
if (e) {
log_error_errno(sd_bus_error_get_errno(e),
"Could not get product UUID. Falling back to use machine-app-specific ID as DUID-UUID: %s",
e->message);
r = sd_bus_error_get_errno(e);
log_warning_errno(r, "Could not get product UUID. Falling back to use machine-app-specific ID as DUID-UUID: %s",
bus_error_message(e, r));
goto configure;
}
r = sd_bus_message_read_array(m, 'y', &a, &sz);
if (r < 0)
if (r < 0) {
log_warning_errno(r, "Failed to get product UUID. Falling back to use machine-app-specific ID as DUID-UUID: %m");
goto configure;
}
if (sz != sizeof(sd_id128_t)) {
log_error("Invalid product UUID. Falling back to use machine-app-specific ID as DUID-UUID.");
log_warning("Invalid product UUID. Falling back to use machine-app-specific ID as DUID-UUID.");
goto configure;
}

View File

@ -11,6 +11,7 @@
#include "sd-netlink.h"
#include "alloc-util.h"
#include "bus-error.h"
#include "bus-log-control-api.h"
#include "bus-polkit.h"
#include "bus-util.h"
@ -1157,15 +1158,16 @@ void manager_dirty(Manager *manager) {
}
static int set_hostname_handler(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) {
_unused_ Manager *manager = userdata;
const sd_bus_error *e;
int r;
assert(m);
assert(manager);
e = sd_bus_message_get_error(m);
if (e)
log_warning_errno(sd_bus_error_get_errno(e), "Could not set hostname: %s", e->message);
if (e) {
r = sd_bus_error_get_errno(e);
log_warning_errno(r, "Could not set hostname: %s", bus_error_message(e, r));
}
return 1;
}
@ -1203,15 +1205,16 @@ int manager_set_hostname(Manager *m, const char *hostname) {
}
static int set_timezone_handler(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) {
_unused_ Manager *manager = userdata;
const sd_bus_error *e;
int r;
assert(m);
assert(manager);
e = sd_bus_message_get_error(m);
if (e)
log_warning_errno(sd_bus_error_get_errno(e), "Could not set timezone: %s", e->message);
if (e) {
r = sd_bus_error_get_errno(e);
log_warning_errno(r, "Could not set timezone: %s", bus_error_message(e, r));
}
return 1;
}