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().
This commit is contained in:
Michal Schmidt
2014-11-28 12:04:41 +01:00
parent b4d23205f2
commit 0a1beeb642
173 changed files with 1001 additions and 1001 deletions
+9 -9
View File
@@ -668,7 +668,7 @@ static int create_item(Item *i) {
struct stat a, b;
if (r != -EEXIST) {
log_error("Failed to copy files to %s: %s", i->path, strerror(-r));
log_error_errno(-r, "Failed to copy files to %s: %m", i->path);
return -r;
}
@@ -711,7 +711,7 @@ static int create_item(Item *i) {
if (r < 0) {
if (r != -EEXIST) {
log_error("Failed to create directory %s: %s", i->path, strerror(-r));
log_error_errno(-r, "Failed to create directory %s: %m", i->path);
return r;
}
@@ -762,7 +762,7 @@ static int create_item(Item *i) {
}
if (r < 0) {
log_error("Failed to create fifo %s: %s", i->path, strerror(-r));
log_error_errno(-r, "Failed to create fifo %s: %m", i->path);
return r;
}
} else {
@@ -801,7 +801,7 @@ static int create_item(Item *i) {
mac_selinux_create_file_clear();
if (r < 0) {
log_error("symlink(%s, %s) failed: %s", i->argument, i->path, strerror(-r));
log_error_errno(-r, "symlink(%s, %s) failed: %m", i->argument, i->path);
return r;
}
} else {
@@ -863,7 +863,7 @@ static int create_item(Item *i) {
}
if (r < 0) {
log_error("Failed to create device node %s: %s", i->path, strerror(-r));
log_error_errno(-r, "Failed to create device node %s: %m", i->path);
return r;
}
} else {
@@ -939,7 +939,7 @@ static int remove_item_instance(Item *i, const char *instance) {
* instead of rm_rf() so that 'x' is honoured. */
r = rm_rf_dangerous(instance, false, i->type == RECURSIVE_REMOVE_PATH, false);
if (r < 0 && r != -ENOENT) {
log_error("rm_rf(%s): %s", instance, strerror(-r));
log_error_errno(-r, "rm_rf(%s): %m", instance);
return r;
}
@@ -1398,7 +1398,7 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) {
r = hashmap_put(h, i->path, i);
if (r < 0) {
log_error("Failed to insert item %s: %s", i->path, strerror(-r));
log_error_errno(-r, "Failed to insert item %s: %m", i->path);
return r;
}
@@ -1531,7 +1531,7 @@ static int read_config_file(const char *fn, bool ignore_enoent) {
if (ignore_enoent && r == -ENOENT)
return 0;
log_error("Failed to open '%s', ignoring: %s", fn, strerror(-r));
log_error_errno(-r, "Failed to open '%s', ignoring: %m", fn);
return r;
}
@@ -1629,7 +1629,7 @@ int main(int argc, char *argv[]) {
r = conf_files_list_nulstr(&files, ".conf", arg_root, conf_file_dirs);
if (r < 0) {
log_error("Failed to enumerate tmpfiles.d files: %s", strerror(-r));
log_error_errno(-r, "Failed to enumerate tmpfiles.d files: %m");
goto finish;
}