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().

Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
This commit is contained in:
Michal Schmidt 2014-11-28 11:16:51 -05:00 committed by Anthony G. Basile
parent e72e57a66f
commit 146b012e50
6 changed files with 11 additions and 11 deletions

View File

@ -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;
}

View File

@ -216,7 +216,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) {

View File

@ -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);

View File

@ -1690,7 +1690,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);
}
@ -2711,7 +2711,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;
}

View File

@ -615,7 +615,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;
}
@ -648,7 +648,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;
}
}

View File

@ -989,7 +989,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;
}
@ -1161,7 +1161,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;
}
@ -1245,7 +1245,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;