X Tutup
Skip to content

Commit 755bde3

Browse files
committed
udev,update-done: more log_xyz_errno() conversions
1 parent 1797280 commit 755bde3

File tree

3 files changed

+20
-36
lines changed

3 files changed

+20
-36
lines changed

src/udev/net/link-config.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -342,14 +342,14 @@ int link_config_apply(link_config_ctx *ctx, link_config *config,
342342
r = ethtool_set_speed(&ctx->ethtool_fd, old_name, config->speed / 1024,
343343
config->duplex);
344344
if (r < 0)
345-
log_warning("Could not set speed or duplex of %s to %u Mbps (%s): %s",
346-
old_name, config->speed / 1024,
347-
duplex_to_string(config->duplex), strerror(-r));
345+
log_warning_errno(r, "Could not set speed or duplex of %s to %u Mbps (%s): %m",
346+
old_name, config->speed / 1024,
347+
duplex_to_string(config->duplex));
348348

349349
r = ethtool_set_wol(&ctx->ethtool_fd, old_name, config->wol);
350350
if (r < 0)
351-
log_warning("Could not set WakeOnLan of %s to %s: %s",
352-
old_name, wol_to_string(config->wol), strerror(-r));
351+
log_warning_errno(r, "Could not set WakeOnLan of %s to %s: %m",
352+
old_name, wol_to_string(config->wol));
353353

354354
ifindex = udev_device_get_ifindex(device);
355355
if (ifindex <= 0) {
@@ -422,8 +422,7 @@ int link_config_apply(link_config_ctx *ctx, link_config *config,
422422
r = rtnl_set_link_properties(&ctx->rtnl, ifindex, config->alias, mac,
423423
config->mtu);
424424
if (r < 0) {
425-
log_warning("Could not set Alias, MACAddress or MTU on %s: %s",
426-
old_name, strerror(-r));
425+
log_warning_errno(r, "Could not set Alias, MACAddress or MTU on %s: %m", old_name);
427426
return r;
428427
}
429428

src/udev/udev-event.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -776,8 +776,7 @@ static int rename_netif(struct udev_event *event) {
776776

777777
r = rtnl_set_link_name(&event->rtnl, udev_device_get_ifindex(dev), name);
778778
if (r < 0) {
779-
log_error("error changing net interface name '%s' to '%s': %s",
780-
oldname, name, strerror(-r));
779+
log_error_errno(r, "Error changing net interface name '%s' to '%s': %m", oldname, name);
781780
return r;
782781
}
783782

src/update-done/update-done.c

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,10 @@ static int apply_timestamp(const char *path, struct timespec *ts) {
4646

4747
if (utimensat(AT_FDCWD, path, twice, AT_SYMLINK_NOFOLLOW) < 0) {
4848

49-
if (errno == EROFS) {
50-
log_debug("Can't update timestamp file %s, file system is read-only.", path);
51-
return 0;
52-
}
49+
if (errno == EROFS)
50+
return log_debug("Can't update timestamp file %s, file system is read-only.", path);
5351

54-
log_error("Failed to update timestamp on %s: %m", path);
55-
return -errno;
52+
return log_error_errno(errno, "Failed to update timestamp on %s: %m", path);
5653
}
5754

5855
} else if (errno == ENOENT) {
@@ -62,39 +59,28 @@ static int apply_timestamp(const char *path, struct timespec *ts) {
6259
/* The timestamp file doesn't exist yet? Then let's create it. */
6360

6461
r = mac_selinux_create_file_prepare(path, S_IFREG);
65-
if (r < 0) {
66-
log_error("Failed to set SELinux context for %s: %s",
67-
path, strerror(-r));
68-
return r;
69-
}
62+
if (r < 0)
63+
return log_error_errno(r, "Failed to set SELinux context for %s: %m", path);
7064

7165
fd = open(path, O_CREAT|O_EXCL|O_WRONLY|O_TRUNC|O_CLOEXEC|O_NOCTTY|O_NOFOLLOW, 0644);
7266
mac_selinux_create_file_clear();
7367

7468
if (fd < 0) {
69+
if (errno == EROFS)
70+
return log_debug("Can't create timestamp file %s, file system is read-only.", path);
7571

76-
if (errno == EROFS) {
77-
log_debug("Can't create timestamp file %s, file system is read-only.", path);
78-
return 0;
79-
}
80-
81-
log_error("Failed to create timestamp file %s: %m", path);
82-
return -errno;
72+
return log_error_errno(errno, "Failed to create timestamp file %s: %m", path);
8373
}
8474

8575
(void) loop_write(fd, MESSAGE, strlen(MESSAGE), false);
8676

8777
twice[0] = *ts;
8878
twice[1] = *ts;
8979

90-
if (futimens(fd, twice) < 0) {
91-
log_error("Failed to update timestamp on %s: %m", path);
92-
return -errno;
93-
}
94-
} else {
95-
log_error("Failed to stat() timestamp file %s: %m", path);
96-
return -errno;
97-
}
80+
if (futimens(fd, twice) < 0)
81+
return log_error_errno(errno, "Failed to update timestamp on %s: %m", path);
82+
} else
83+
log_error_errno(errno, "Failed to stat() timestamp file %s: %m", path);
9884

9985
return 0;
10086
}
@@ -108,7 +94,7 @@ int main(int argc, char *argv[]) {
10894
log_open();
10995

11096
if (stat("/usr", &st) < 0) {
111-
log_error("Failed to stat /usr: %m");
97+
log_error_errno(errno, "Failed to stat /usr: %m");
11298
return EXIT_FAILURE;
11399
}
114100

0 commit comments

Comments
 (0)
X Tutup