summaryrefslogtreecommitdiff
path: root/src/udev
diff options
context:
space:
mode:
authorMichal Schmidt <mschmidt@redhat.com>2014-11-28 11:58:34 +0100
committerMichal Schmidt <mschmidt@redhat.com>2014-11-28 12:04:41 +0100
commit0a1beeb64207eaa88ab9236787b1cbc2f704ae14 (patch)
tree50117277be2e2078d0373b944a30b4f09bb94443 /src/udev
parentb4d23205f238e06aaa31264628e20669e714acad (diff)
treewide: auto-convert the simple cases to log_*_errno()
As a followup to 086891e5c1 "log: add an "error" parameter to all low-level logging calls and intrdouce log_error_errno() as log calls that take error numbers", use sed to convert the simple cases to use the new macros: find . -name '*.[ch]' | xargs sed -r -i -e \ 's/log_(debug|info|notice|warning|error|emergency)\("(.*)%s"(.*), strerror\(-([a-zA-Z_]+)\)\);/log_\1_errno(-\4, "\2%m"\3);/' Multi-line log_*() invocations are not covered. And we also should add log_unit_*_errno().
Diffstat (limited to 'src/udev')
-rw-r--r--src/udev/net/ethtool-util.c6
-rw-r--r--src/udev/net/link-config.c4
-rw-r--r--src/udev/udev-builtin-keyboard.c2
-rw-r--r--src/udev/udev-builtin-net_setup_link.c4
-rw-r--r--src/udev/udev-builtin-uaccess.c4
-rw-r--r--src/udev/udev-ctrl.c2
-rw-r--r--src/udev/udev-node.c4
-rw-r--r--src/udev/udev-rules.c4
-rw-r--r--src/udev/udevadm-hwdb.c4
-rw-r--r--src/udev/udevd.c6
10 files changed, 20 insertions, 20 deletions
diff --git a/src/udev/net/ethtool-util.c b/src/udev/net/ethtool-util.c
index 54cb928091..e46d4d3d7c 100644
--- a/src/udev/net/ethtool-util.c
+++ b/src/udev/net/ethtool-util.c
@@ -76,7 +76,7 @@ int ethtool_get_driver(int *fd, const char *ifname, char **ret) {
if (*fd < 0) {
r = ethtool_connect(fd);
if (r < 0) {
- log_warning("link_config: could not connect to ethtool: %s", strerror(-r));
+ log_warning_errno(-r, "link_config: could not connect to ethtool: %m");
return r;
}
}
@@ -112,7 +112,7 @@ int ethtool_set_speed(int *fd, const char *ifname, unsigned int speed, Duplex du
if (*fd < 0) {
r = ethtool_connect(fd);
if (r < 0) {
- log_warning("link_config: could not connect to ethtool: %s", strerror(-r));
+ log_warning_errno(-r, "link_config: could not connect to ethtool: %m");
return r;
}
}
@@ -172,7 +172,7 @@ int ethtool_set_wol(int *fd, const char *ifname, WakeOnLan wol) {
if (*fd < 0) {
r = ethtool_connect(fd);
if (r < 0) {
- log_warning("link_config: could not connect to ethtool: %s", strerror(-r));
+ log_warning_errno(-r, "link_config: could not connect to ethtool: %m");
return r;
}
}
diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c
index 5aefb7d415..97e260baed 100644
--- a/src/udev/net/link-config.c
+++ b/src/udev/net/link-config.c
@@ -175,7 +175,7 @@ static bool enable_name_policy(void) {
r = proc_cmdline(&line);
if (r < 0) {
- log_warning("Failed to read /proc/cmdline, ignoring: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to read /proc/cmdline, ignoring: %m");
return true;
}
@@ -203,7 +203,7 @@ int link_config_load(link_config_ctx *ctx) {
r = conf_files_list_strv(&files, ".link", NULL, link_dirs);
if (r < 0) {
- log_error("failed to enumerate link files: %s", strerror(-r));
+ log_error_errno(-r, "failed to enumerate link files: %m");
return r;
}
diff --git a/src/udev/udev-builtin-keyboard.c b/src/udev/udev-builtin-keyboard.c
index d6b7dbbac0..6628ac873f 100644
--- a/src/udev/udev-builtin-keyboard.c
+++ b/src/udev/udev-builtin-keyboard.c
@@ -62,7 +62,7 @@ static int install_force_release(struct udev_device *dev, const unsigned int *re
log_debug("keyboard: updating force-release list with '%s'", codes);
ret = udev_device_set_sysattr_value(atkbd, "force_release", codes);
if (ret < 0)
- log_error("Error writing force-release attribute: %s", strerror(-ret));
+ log_error_errno(-ret, "Error writing force-release attribute: %m");
return ret;
}
diff --git a/src/udev/udev-builtin-net_setup_link.c b/src/udev/udev-builtin-net_setup_link.c
index 14351de6a6..a1934f463e 100644
--- a/src/udev/udev-builtin-net_setup_link.c
+++ b/src/udev/udev-builtin-net_setup_link.c
@@ -46,14 +46,14 @@ static int builtin_net_setup_link(struct udev_device *dev, int argc, char **argv
log_debug("No matching link configuration found.");
return EXIT_SUCCESS;
} else {
- log_error("Could not get link config: %s", strerror(-r));
+ log_error_errno(-r, "Could not get link config: %m");
return EXIT_FAILURE;
}
}
r = link_config_apply(ctx, link, dev, &name);
if (r < 0) {
- log_error("Could not apply link config to %s: %s", udev_device_get_sysname(dev), strerror(-r));
+ log_error_errno(-r, "Could not apply link config to %s: %m", udev_device_get_sysname(dev));
return EXIT_FAILURE;
}
diff --git a/src/udev/udev-builtin-uaccess.c b/src/udev/udev-builtin-uaccess.c
index 6964fb5529..ecd320a588 100644
--- a/src/udev/udev-builtin-uaccess.c
+++ b/src/udev/udev-builtin-uaccess.c
@@ -63,7 +63,7 @@ static int builtin_uaccess(struct udev_device *dev, int argc, char *argv[], bool
r = devnode_acl(path, true, false, 0, true, uid);
if (r < 0) {
- log_error("Failed to apply ACL on %s: %s", path, strerror(-r));
+ log_error_errno(-r, "Failed to apply ACL on %s: %m", path);
goto finish;
}
@@ -77,7 +77,7 @@ finish:
/* Better be safe than sorry and reset ACL */
k = devnode_acl(path, true, false, 0, false, 0);
if (k < 0) {
- log_error("Failed to apply ACL on %s: %s", path, strerror(-k));
+ log_error_errno(-k, "Failed to apply ACL on %s: %m", path);
if (r >= 0)
r = k;
}
diff --git a/src/udev/udev-ctrl.c b/src/udev/udev-ctrl.c
index 98fd3a9acf..d6cc9b493a 100644
--- a/src/udev/udev-ctrl.c
+++ b/src/udev/udev-ctrl.c
@@ -194,7 +194,7 @@ struct udev_ctrl_connection *udev_ctrl_get_connection(struct udev_ctrl *uctrl) {
/* check peer credential of connection */
r = getpeercred(conn->sock, &ucred);
if (r < 0) {
- log_error("unable to receive credentials of ctrl connection: %s", strerror(-r));
+ log_error_errno(-r, "unable to receive credentials of ctrl connection: %m");
goto err;
}
if (ucred.uid > 0) {
diff --git a/src/udev/udev-node.c b/src/udev/udev-node.c
index 030e459198..f105fa28e2 100644
--- a/src/udev/udev-node.c
+++ b/src/udev/udev-node.c
@@ -304,7 +304,7 @@ static int node_permissions_apply(struct udev_device *dev, bool apply,
r = mac_selinux_apply(devnode, label);
if (r < 0)
- log_error("SECLABEL: failed to set SELinux label '%s': %s", label, strerror(-r));
+ log_error_errno(-r, "SECLABEL: failed to set SELinux label '%s': %m", label);
else
log_debug("SECLABEL: set SELinux label '%s'", label);
@@ -313,7 +313,7 @@ static int node_permissions_apply(struct udev_device *dev, bool apply,
r = mac_smack_apply(devnode, label);
if (r < 0)
- log_error("SECLABEL: failed to set SMACK label '%s': %s", label, strerror(-r));
+ log_error_errno(-r, "SECLABEL: failed to set SMACK label '%s': %m", label);
else
log_debug("SECLABEL: set SMACK label '%s'", label);
diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c
index 093d68cf0c..07c1f11033 100644
--- a/src/udev/udev-rules.c
+++ b/src/udev/udev-rules.c
@@ -1685,7 +1685,7 @@ struct udev_rules *udev_rules_new(struct udev *udev, int resolve_names) {
r = conf_files_list_strv(&files, ".rules", NULL, rules_dirs);
if (r < 0) {
- log_error("failed to enumerate rules files: %s", strerror(-r));
+ log_error_errno(-r, "failed to enumerate rules files: %m");
return udev_rules_unref(rules);
}
@@ -2653,7 +2653,7 @@ int udev_rules_apply_static_dev_perms(struct udev_rules *rules) {
strscpyl(tags_dir, sizeof(tags_dir), "/run/udev/static_node-tags/", *t, "/", NULL);
r = mkdir_p(tags_dir, 0755);
if (r < 0) {
- log_error("failed to create %s: %s", tags_dir, strerror(-r));
+ log_error_errno(-r, "failed to create %s: %m", tags_dir);
return r;
}
diff --git a/src/udev/udevadm-hwdb.c b/src/udev/udevadm-hwdb.c
index 3ca755e2ed..9a32fa8c6f 100644
--- a/src/udev/udevadm-hwdb.c
+++ b/src/udev/udevadm-hwdb.c
@@ -618,7 +618,7 @@ static int adm_hwdb(struct udev *udev, int argc, char *argv[]) {
err = conf_files_list_strv(&files, ".hwdb", root, conf_file_dirs);
if (err < 0) {
- log_error("failed to enumerate hwdb files: %s", strerror(-err));
+ log_error_errno(-err, "failed to enumerate hwdb files: %m");
rc = EXIT_FAILURE;
goto out;
}
@@ -652,7 +652,7 @@ static int adm_hwdb(struct udev *udev, int argc, char *argv[]) {
mkdir_parents(hwdb_bin, 0755);
err = trie_store(trie, hwdb_bin);
if (err < 0) {
- log_error("Failure writing database %s: %s", hwdb_bin, strerror(-err));
+ log_error_errno(-err, "Failure writing database %s: %m", hwdb_bin);
rc = EXIT_FAILURE;
}
}
diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index 3c3de76f34..99b033b050 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -962,7 +962,7 @@ static void kernel_cmdline_options(struct udev *udev) {
r = proc_cmdline(&line);
if (r < 0) {
- log_warning("Failed to read /proc/cmdline, ignoring: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to read /proc/cmdline, ignoring: %m");
return;
}
@@ -1135,7 +1135,7 @@ int main(int argc, char *argv[]) {
r = mac_selinux_init("/dev");
if (r < 0) {
- log_error("could not initialize labelling: %s", strerror(-r));
+ log_error_errno(-r, "could not initialize labelling: %m");
goto exit;
}
@@ -1239,7 +1239,7 @@ int main(int argc, char *argv[]) {
rc = udev_rules_apply_static_dev_perms(rules);
if (rc < 0)
- log_error("failed to apply permissions on static device nodes - %s", strerror(-rc));
+ log_error_errno(-rc, "failed to apply permissions on static device nodes - %m");
if (arg_daemonize) {
pid_t pid;