tree-wide usage of %m specifier instead of strerror(errno)
Also for log_error() except where a specific error is specified e.g. errno ? strerror(errno) : "Some user specified message"
This commit is contained in:
parent
34a6dc7dca
commit
f5f6d0e255
2
TODO
2
TODO
|
@ -824,8 +824,6 @@ Regularly:
|
|||
|
||||
* Use PR_SET_PROCTITLE_AREA if it becomes available in the kernel
|
||||
|
||||
* %m in printf() instead of strerror(errno);
|
||||
|
||||
* pahole
|
||||
|
||||
* set_put(), hashmap_put() return values check. i.e. == 0 doesn't free()!
|
||||
|
|
|
@ -304,7 +304,7 @@ static int open_dev_autofs(Manager *m) {
|
|||
|
||||
m->dev_autofs_fd = open("/dev/autofs", O_CLOEXEC|O_RDONLY);
|
||||
if (m->dev_autofs_fd < 0) {
|
||||
log_error("Failed to open /dev/autofs: %s", strerror(errno));
|
||||
log_error("Failed to open /dev/autofs: %m");
|
||||
return -errno;
|
||||
}
|
||||
|
||||
|
|
|
@ -131,7 +131,7 @@ _noreturn_ static void crash(int sig) {
|
|||
|
||||
pid = fork();
|
||||
if (pid < 0)
|
||||
log_error("Caught <%s>, cannot fork for core dump: %s", signal_to_string(sig), strerror(errno));
|
||||
log_error("Caught <%s>, cannot fork for core dump: %m", signal_to_string(sig));
|
||||
|
||||
else if (pid == 0) {
|
||||
struct rlimit rl = {};
|
||||
|
|
|
@ -307,7 +307,7 @@ static int enable_special_signals(Manager *m) {
|
|||
} else {
|
||||
/* Enable that we get SIGWINCH on kbrequest */
|
||||
if (ioctl(fd, KDSIGACCEPT, SIGWINCH) < 0)
|
||||
log_warning("Failed to enable kbrequest handling: %s", strerror(errno));
|
||||
log_warning("Failed to enable kbrequest handling: %m");
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -188,7 +188,7 @@ static int mount_one(const MountPoint *p, bool relabel) {
|
|||
p->type,
|
||||
p->flags,
|
||||
p->options) < 0) {
|
||||
log_full((p->mode & MNT_FATAL) ? LOG_ERR : LOG_DEBUG, "Failed to mount %s: %s", p->where, strerror(errno));
|
||||
log_full((p->mode & MNT_FATAL) ? LOG_ERR : LOG_DEBUG, "Failed to mount %s: %m", p->where);
|
||||
return (p->mode & MNT_FATAL) ? -errno : 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -3507,7 +3507,7 @@ static int service_enumerate(Manager *m) {
|
|||
d = opendir(path);
|
||||
if (!d) {
|
||||
if (errno != ENOENT)
|
||||
log_warning("opendir(%s) failed: %s", path, strerror(errno));
|
||||
log_warning("opendir(%s) failed: %m", path);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
@ -3540,7 +3540,7 @@ static int service_enumerate(Manager *m) {
|
|||
if (access(fpath, X_OK) < 0) {
|
||||
|
||||
if (errno != ENOENT)
|
||||
log_warning("access() failed on %s: %s", fpath, strerror(errno));
|
||||
log_warning("access() failed on %s: %m", fpath);
|
||||
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -217,7 +217,7 @@ static int fifo_process(Fifo *f) {
|
|||
if (errno == EAGAIN)
|
||||
return 0;
|
||||
|
||||
log_warning("Failed to read from fifo: %s", strerror(errno));
|
||||
log_warning("Failed to read from fifo: %m");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -278,7 +278,7 @@ static int server_init(Server *s, unsigned n_sockets) {
|
|||
s->epoll_fd = epoll_create1(EPOLL_CLOEXEC);
|
||||
if (s->epoll_fd < 0) {
|
||||
r = -errno;
|
||||
log_error("Failed to create epoll object: %s", strerror(errno));
|
||||
log_error("Failed to create epoll object: %m");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -305,8 +305,7 @@ static int server_init(Server *s, unsigned n_sockets) {
|
|||
f = new0(Fifo, 1);
|
||||
if (!f) {
|
||||
r = -ENOMEM;
|
||||
log_error("Failed to create fifo object: %s",
|
||||
strerror(errno));
|
||||
log_error("Failed to create fifo object: %m");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -318,8 +317,7 @@ static int server_init(Server *s, unsigned n_sockets) {
|
|||
if (epoll_ctl(s->epoll_fd, EPOLL_CTL_ADD, fd, &ev) < 0) {
|
||||
r = -errno;
|
||||
fifo_free(f);
|
||||
log_error("Failed to add fifo fd to epoll object: %s",
|
||||
strerror(errno));
|
||||
log_error("Failed to add fifo fd to epoll object: %m");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -416,7 +414,7 @@ int main(int argc, char *argv[]) {
|
|||
if (errno == EINTR)
|
||||
continue;
|
||||
|
||||
log_error("epoll_wait() failed: %s", strerror(errno));
|
||||
log_error("epoll_wait() failed: %m");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
|
|
@ -479,7 +479,7 @@ static int run_gdb(sd_journal *j) {
|
|||
|
||||
sz = write(fd, data, len);
|
||||
if (sz < 0) {
|
||||
log_error("Failed to write temporary file: %s", strerror(errno));
|
||||
log_error("Failed to write temporary file: %m");
|
||||
r = -errno;
|
||||
goto finish;
|
||||
}
|
||||
|
|
|
@ -100,12 +100,12 @@ void server_forward_console(
|
|||
|
||||
fd = open_terminal(tty, O_WRONLY|O_NOCTTY|O_CLOEXEC);
|
||||
if (fd < 0) {
|
||||
log_debug("Failed to open %s for logging: %s", tty, strerror(errno));
|
||||
log_debug("Failed to open %s for logging: %m", tty);
|
||||
goto finish;
|
||||
}
|
||||
|
||||
if (writev(fd, iovec, n) < 0)
|
||||
log_debug("Failed to write to %s for logging: %s", tty, strerror(errno));
|
||||
log_debug("Failed to write to %s for logging: %m", tty);
|
||||
|
||||
close_nointr_nofail(fd);
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ void server_forward_kmsg(
|
|||
IOVEC_SET_STRING(iovec[n++], "\n");
|
||||
|
||||
if (writev(s->dev_kmsg_fd, iovec, n) < 0)
|
||||
log_debug("Failed to write to /dev/kmsg for logging: %s", strerror(errno));
|
||||
log_debug("Failed to write to /dev/kmsg for logging: %m");
|
||||
|
||||
free(ident_buf);
|
||||
}
|
||||
|
|
|
@ -97,7 +97,7 @@ static int prepare(char *dir, char *filename)
|
|||
|
||||
fd = open(buf,O_RDWR|O_CREAT, S_IRUSR|S_IWUSR);
|
||||
if (fd < 0)
|
||||
fprintf(stderr, "Cannot open %s: %s\n", buf, strerror(errno));
|
||||
fprintf(stderr, "Cannot open %s: %m\n", buf);
|
||||
|
||||
if (lockf(fd,F_TLOCK,0) < 0) {
|
||||
if (debug)
|
||||
|
@ -109,7 +109,7 @@ static int prepare(char *dir, char *filename)
|
|||
fprintf(stderr, "Acquired lock on %s\n", buf);
|
||||
} else {
|
||||
if (debug)
|
||||
fprintf(stderr, "Could not get lock on %s: %s\n", buf, strerror(errno));
|
||||
fprintf(stderr, "Could not get lock on %s: %m\n", buf);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -404,7 +404,7 @@ int main(int argc, char **argv)
|
|||
us = argv[argi++];
|
||||
|
||||
if (signal(SIGALRM, sig_alrm) == SIG_ERR) {
|
||||
fprintf(stderr, "Cannot set SIGALRM: %s\n", strerror(errno));
|
||||
fprintf(stderr, "Cannot set SIGALRM: %m\n");
|
||||
ret = 2;
|
||||
goto exit;
|
||||
}
|
||||
|
|
|
@ -185,7 +185,7 @@ static int get_file_options(struct udev *udev,
|
|||
if (errno == ENOENT) {
|
||||
return 1;
|
||||
} else {
|
||||
log_error("can't open %s: %s\n", config_file, strerror(errno));
|
||||
log_error("can't open %s: %m\n", config_file);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -362,7 +362,7 @@ resend:
|
|||
dev_scsi->use_sg = 3;
|
||||
goto resend;
|
||||
}
|
||||
log_debug("%s: ioctl failed: %s\n", dev_scsi->kernel, strerror(errno));
|
||||
log_debug("%s: ioctl failed: %m\n", dev_scsi->kernel);
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@ -820,14 +820,12 @@ int scsi_std_inquiry(struct udev *udev,
|
|||
|
||||
fd = open(devname, O_RDONLY | O_NONBLOCK);
|
||||
if (fd < 0) {
|
||||
log_debug("scsi_id: cannot open %s: %s\n",
|
||||
devname, strerror(errno));
|
||||
log_debug("scsi_id: cannot open %s: %m\n", devname);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (fstat(fd, &statbuf) < 0) {
|
||||
log_debug("scsi_id: cannot stat %s: %s\n",
|
||||
devname, strerror(errno));
|
||||
log_debug("scsi_id: cannot stat %s: %m\n", devname);
|
||||
err = 2;
|
||||
goto out;
|
||||
}
|
||||
|
|
|
@ -2595,7 +2595,7 @@ int udev_rules_apply_static_dev_perms(struct udev_rules *rules)
|
|||
strscpyl(tag_symlink, sizeof(tag_symlink), tags_dir, unescaped_filename, NULL);
|
||||
r = symlink(device_node, tag_symlink);
|
||||
if (r < 0 && errno != EEXIST) {
|
||||
log_error("failed to create symlink %s -> %s: %s\n", tag_symlink, device_node, strerror(errno));
|
||||
log_error("failed to create symlink %s -> %s: %m\n", tag_symlink, device_node);
|
||||
return -errno;
|
||||
} else
|
||||
r = 0;
|
||||
|
|
Loading…
Reference in New Issue