From patchwork Mon Dec 25 22:14:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rosen Penev X-Patchwork-Id: 852880 X-Patchwork-Delegate: blogic@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=65.50.211.133; helo=bombadil.infradead.org; envelope-from=lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="QJ3m2bEz"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Vh15e1Tc"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3z5D3C4W91z9ryv for ; Tue, 26 Dec 2017 09:16:07 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Subject:Message-Id: Date:To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=6YDoHCgtgXXy/rNOZ5eFVk5EWFKKfOrfcR96GDMQ/9Y=; b=QJ3m2bEzLAdgBJ rgVWgyYb/KVjJT/GmTR8IM6/n8HSVnIfTrmNPbcYrrQxmS412q10C31NEyVm1j1IJbEosfwwvhA0K PHsK99wXB1nkgMIwh3A8dQicuQ5pYeMhGkVbGHMORuHnoGNX6CM+xI0WvjEgrQkah2vus4w/7nDY0 jUlyk+8P0u/Jjp5wVGc3E72+3lj95Kdly0ksKm7z7eb5h9Bf7O2d3qfyKC5LlRtBUQ6GwAZMN9zA1 YBI72E8B+q0hEwqfaYvTdRlgsOnsBwPGiMjqlA36o8DJ8KOpT6lF/sZTIdS1ai/fp2Etk/In95eL1 hPiv/H+JCoaoAXdtnQuA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eTb2H-0001Av-AF; Mon, 25 Dec 2017 22:15:53 +0000 Received: from mail-pl0-x244.google.com ([2607:f8b0:400e:c01::244]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eTb1I-0008Be-Sq for lede-dev@lists.infradead.org; Mon, 25 Dec 2017 22:14:55 +0000 Received: by mail-pl0-x244.google.com with SMTP id i6so17032714plt.13 for ; Mon, 25 Dec 2017 14:14:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=93CaPwss/2aNnRDZLj0gn2af27SMy1nkuuIpfSS5qqs=; b=Vh15e1Tcr0afdTAOnfdmdUaMaskFjJDLqnQv5Rnw366845iT13ak3LgFXlEAKgmkvo TX1cq8SnMfjVe5wqKrXzMjPe0nOSSG/0+TtMiUb0QnqCS4M3DY2lB4qRiJcS1LxmcGna 4jSkTv+JOGIllKpHmli9Q3urvGCB2ICpboY8F2WRg7RIBjzSf2CE4U1fgVMtWUweu/JH 9GZh1edsbjRvsukYKvDc8X6h9r3atrstuEf74pJoOZctYZA+GVZ+o1TBufsCm8V9v441 mnKsnhb+NAUIjzAAIGIXBvWVZTewr1Q4emr3EW0wthW0XW2V2xYxTrefuBXxHJmPuykJ e9DQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=93CaPwss/2aNnRDZLj0gn2af27SMy1nkuuIpfSS5qqs=; b=jVJA1Xwh6eBMBR2lJgSQXQo83tUrngsXxVUyCgdWNP+2ufH5Lje/bzgXzbBUMo1sEm zVrxqsWtbSeAmQCYE9m0O3FklyFF5UmlT3uDLCz1nm6ElYtoWiybQEqWFC/Pr/AQUJ6p 0Lvfc3KTBeO8xiORMdZPaMwtZlkDQRDWjp0qKm1aw6yDeYoOziWSoHLWL/e9Trf8RUcs AhguWM+WTD6gwqz8mVJ8mtpj2Cua2pdRifetxAWLT0YspzNbzXFExP9Cpv7y1HNGfKoU 6E5HYqHUzOhJ4nUkGgOZcYPlX4tgC4zDFL4vVL7QNEgAGEVn/dPiZPSI0zEy/Wb5Rs1U Sqkw== X-Gm-Message-State: AKGB3mIdUIGHkd5seRud11Pp/hNuOIB5B1ujEVEc0rdbbuTaot/X8no/ SErbYtx74J+yKQhhVfLNBZzyvS/v X-Google-Smtp-Source: ACJfBovgTt+9V740UckZJM3oC76RBLBTaFv7KzWctYgeOWiH3nj7psrSLHF0F3+3EK/RUhmx46HVHw== X-Received: by 10.159.242.203 with SMTP id x11mr23913904plw.162.1514240079456; Mon, 25 Dec 2017 14:14:39 -0800 (PST) Received: from DESKTOP-CEH0M93.lan ([2001:470:1f05:c3e:98da:65ff:24e5:ee50]) by smtp.gmail.com with ESMTPSA id e8sm62309775pfk.6.2017.12.25.14.14.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 25 Dec 2017 14:14:38 -0800 (PST) From: Rosen Penev To: lede-dev@lists.infradead.org Date: Mon, 25 Dec 2017 14:14:44 -0800 Message-Id: <1514240086-3654-1-git-send-email-rosenp@gmail.com> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171225_141452_987379_0234A4B5 X-CRM114-Status: GOOD ( 11.71 ) X-Spam-Score: -2.0 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [2607:f8b0:400e:c01:0:0:0:244 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (rosenp[at]gmail.com) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain Subject: [LEDE-DEV] [PATCH 1/3] procd: Replace strerror(errno) with %m. X-BeenThere: lede-dev@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Rosen Penev MIME-Version: 1.0 Sender: "Lede-dev" Errors-To: lede-dev-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Saves 1496 bytes from compiled size under glibc. No functional difference. Signed-off-by: Rosen Penev --- initd/zram.c | 8 ++++---- jail/capabilities.c | 2 +- jail/fs.c | 2 +- jail/jail.c | 32 ++++++++++++++++---------------- jail/seccomp.c | 4 ++-- plug/hotplug.c | 6 +++--- plug/udevtrigger.c | 4 ++-- service/instance.c | 24 ++++++++++++------------ trace/trace.c | 8 ++++---- upgraded/upgraded.c | 6 +++--- utils/utils.c | 4 ++-- watchdog.c | 6 +++--- 12 files changed, 53 insertions(+), 53 deletions(-) diff --git a/initd/zram.c b/initd/zram.c index 0e78195..09e513b 100644 --- a/initd/zram.c +++ b/initd/zram.c @@ -30,7 +30,7 @@ proc_meminfo(void) fp = fopen("/proc/meminfo", "r"); if (fp == NULL) { - ERROR("Can't open /proc/meminfo: %s\n", strerror(errno)); + ERROR("Can't open /proc/meminfo: %m\n"); return errno; } @@ -98,7 +98,7 @@ mount_zram_on_tmp(void) zramsize = proc_meminfo() / 2; fp = fopen("/sys/block/zram0/disksize", "r+"); if (fp == NULL) { - ERROR("Can't open /sys/block/zram0/disksize: %s\n", strerror(errno)); + ERROR("Can't open /sys/block/zram0/disksize: %m\n"); return errno; } fprintf(fp, "%ld", KB(zramsize)); @@ -118,7 +118,7 @@ mount_zram_on_tmp(void) ret = mount("/dev/zram0", "/tmp", "ext4", MS_NOSUID | MS_NODEV | MS_NOATIME, "errors=continue,noquota"); if (ret < 0) { - ERROR("Can't mount /dev/zram0 on /tmp: %s\n", strerror(errno)); + ERROR("Can't mount /dev/zram0 on /tmp: %m\n"); return errno; } @@ -126,7 +126,7 @@ mount_zram_on_tmp(void) ret = chmod("/tmp", 01777); if (ret < 0) { - ERROR("Can't set /tmp mode to 1777: %s\n", strerror(errno)); + ERROR("Can't set /tmp mode to 1777: %m\n"); return errno; } diff --git a/jail/capabilities.c b/jail/capabilities.c index b5ea965..76e06a6 100644 --- a/jail/capabilities.c +++ b/jail/capabilities.c @@ -104,7 +104,7 @@ int drop_capabilities(const char *file) if ( (capdrop & (1LLU << cap)) == 0) { DEBUG("dropping capability %s (%d)\n", capabilities_names[cap], cap); if (prctl(PR_CAPBSET_DROP, cap, 0, 0, 0)) { - ERROR("prctl(PR_CAPBSET_DROP, %d) failed: %s\n", cap, strerror(errno)); + ERROR("prctl(PR_CAPBSET_DROP, %d) failed: %m\n", cap); return errno; } } else { diff --git a/jail/fs.c b/jail/fs.c index c4cdcc9..81e6c61 100644 --- a/jail/fs.c +++ b/jail/fs.c @@ -135,7 +135,7 @@ int add_path_and_deps(const char *path, int readonly, int error, int lib) struct stat s; if (fstat(fd, &s) == -1) { - ERROR("fstat(%s) failed: %s\n", path, strerror(errno)); + ERROR("fstat(%s) failed: %m\n", path); ret = error; goto out; } diff --git a/jail/jail.c b/jail/jail.c index 9d7483c..54e7841 100644 --- a/jail/jail.c +++ b/jail/jail.c @@ -77,7 +77,7 @@ static int mkdir_p(char *dir, mode_t mask) return 0; if (ret) - ERROR("mkdir(%s, %d) failed: %s\n", dir, mask, strerror(errno)); + ERROR("mkdir(%s, %d) failed: %m\n", dir, mask); return ret; } @@ -89,7 +89,7 @@ int mount_bind(const char *root, const char *path, int readonly, int error) int fd; if (stat(path, &s)) { - ERROR("stat(%s) failed: %s\n", path, strerror(errno)); + ERROR("stat(%s) failed: %m\n", path); return error; } @@ -101,19 +101,19 @@ int mount_bind(const char *root, const char *path, int readonly, int error) snprintf(new, sizeof(new), "%s%s", root, path); fd = creat(new, 0644); if (fd == -1) { - ERROR("creat(%s) failed: %s\n", new, strerror(errno)); + ERROR("creat(%s) failed: %m\n", new); return -1; } close(fd); } if (mount(path, new, NULL, MS_BIND, NULL)) { - ERROR("failed to mount -B %s %s: %s\n", path, new, strerror(errno)); + ERROR("failed to mount -B %s %s: %m\n", path, new); return -1; } if (readonly && mount(NULL, new, NULL, MS_BIND | MS_REMOUNT | MS_RDONLY, NULL)) { - ERROR("failed to remount ro %s: %s\n", new, strerror(errno)); + ERROR("failed to remount ro %s: %m\n", new); return -1; } @@ -126,23 +126,23 @@ static int build_jail_fs(void) { char jail_root[] = "/tmp/ujail-XXXXXX"; if (mkdtemp(jail_root) == NULL) { - ERROR("mkdtemp(%s) failed: %s\n", jail_root, strerror(errno)); + ERROR("mkdtemp(%s) failed: %m\n", jail_root); return -1; } /* oldroot can't be MS_SHARED else pivot_root() fails */ if (mount("none", "/", NULL, MS_REC|MS_PRIVATE, NULL)) { - ERROR("private mount failed %s\n", strerror(errno)); + ERROR("private mount failed %m\n"); return -1; } if (mount("tmpfs", jail_root, "tmpfs", MS_NOATIME, "mode=0755")) { - ERROR("tmpfs mount failed %s\n", strerror(errno)); + ERROR("tmpfs mount failed %m\n"); return -1; } if (chdir(jail_root)) { - ERROR("chdir(%s) (jail_root) failed: %s\n", jail_root, strerror(errno)); + ERROR("chdir(%s) (jail_root) failed: %m\n", jail_root); return -1; } @@ -156,11 +156,11 @@ static int build_jail_fs(void) mkdir(dirbuf, 0755); if (pivot_root(jail_root, dirbuf) == -1) { - ERROR("pivot_root(%s, %s) failed: %s\n", jail_root, dirbuf, strerror(errno)); + ERROR("pivot_root(%s, %s) failed: %m\n", jail_root, dirbuf); return -1; } if (chdir("/")) { - ERROR("chdir(/) (after pivot_root) failed: %s\n", strerror(errno)); + ERROR("chdir(/) (after pivot_root) failed: %m\n"); return -1; } @@ -241,13 +241,13 @@ static int exec_jail(void *_notused) exit(EXIT_FAILURE); if (opts.no_new_privs && prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0)) { - ERROR("prctl(PR_SET_NO_NEW_PRIVS) failed: %s\n", strerror(errno)); + ERROR("prctl(PR_SET_NO_NEW_PRIVS) failed: %m\n"); exit(EXIT_FAILURE); } if (opts.namespace && opts.hostname && strlen(opts.hostname) > 0 && sethostname(opts.hostname, strlen(opts.hostname))) { - ERROR("sethostname(%s) failed: %s\n", opts.hostname, strerror(errno)); + ERROR("sethostname(%s) failed: %m\n", opts.hostname); exit(EXIT_FAILURE); } @@ -263,7 +263,7 @@ static int exec_jail(void *_notused) INFO("exec-ing %s\n", *opts.jail_argv); execve(*opts.jail_argv, opts.jail_argv, envp); /* we get there only if execve fails */ - ERROR("failed to execve %s: %s\n", *opts.jail_argv, strerror(errno)); + ERROR("failed to execve %s: %m\n", *opts.jail_argv); exit(EXIT_FAILURE); } @@ -314,7 +314,7 @@ int main(int argc, char **argv) int ch, i; if (uid) { - ERROR("not root, aborting: %s\n", strerror(errno)); + ERROR("not root, aborting: %m\n"); return EXIT_FAILURE; } @@ -449,7 +449,7 @@ int main(int argc, char **argv) /* fork child process */ return exec_jail(NULL); } else { - ERROR("failed to clone/fork: %s\n", strerror(errno)); + ERROR("failed to clone/fork: %m\n"); return EXIT_FAILURE; } } diff --git a/jail/seccomp.c b/jail/seccomp.c index eeb5781..fae08f9 100644 --- a/jail/seccomp.c +++ b/jail/seccomp.c @@ -125,7 +125,7 @@ int install_syscall_filter(const char *argv, const char *file) set_filter(&filter[idx], BPF_RET + BPF_K, 0, 0, SECCOMP_RET_KILL); if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0)) { - ERROR("%s: prctl(PR_SET_NO_NEW_PRIVS) failed: %s\n", argv, strerror(errno)); + ERROR("%s: prctl(PR_SET_NO_NEW_PRIVS) failed: %m\n", argv); return errno; } @@ -133,7 +133,7 @@ int install_syscall_filter(const char *argv, const char *file) prog.filter = filter; if (prctl(PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &prog)) { - ERROR("%s: prctl(PR_SET_SECCOMP) failed: %s\n", argv, strerror(errno)); + ERROR("%s: prctl(PR_SET_SECCOMP) failed: %m\n", argv); return errno; } return 0; diff --git a/plug/hotplug.c b/plug/hotplug.c index 9fc1938..bfc3626 100644 --- a/plug/hotplug.c +++ b/plug/hotplug.c @@ -591,16 +591,16 @@ void hotplug(char *rules) nls.nl_groups = -1; if ((hotplug_fd.fd = socket(PF_NETLINK, SOCK_DGRAM | SOCK_CLOEXEC, NETLINK_KOBJECT_UEVENT)) == -1) { - ERROR("Failed to open hotplug socket: %s\n", strerror(errno)); + ERROR("Failed to open hotplug socket: %m\n"); exit(1); } if (bind(hotplug_fd.fd, (void *)&nls, sizeof(struct sockaddr_nl))) { - ERROR("Failed to bind hotplug socket: %s\n", strerror(errno)); + ERROR("Failed to bind hotplug socket: %m\n"); exit(1); } if (setsockopt(hotplug_fd.fd, SOL_SOCKET, SO_RCVBUFFORCE, &nlbufsize, sizeof(nlbufsize))) - ERROR("Failed to resize receive buffer: %s\n", strerror(errno)); + ERROR("Failed to resize receive buffer: %m\n"); json_script_init(&jctx); queue_proc.cb = queue_proc_cb; diff --git a/plug/udevtrigger.c b/plug/udevtrigger.c index 6bb3453..f87a95e 100644 --- a/plug/udevtrigger.c +++ b/plug/udevtrigger.c @@ -94,12 +94,12 @@ static void trigger_uevent(const char *devpath) fd = open(filename, O_WRONLY); if (fd < 0) { - dbg("error on opening %s: %s\n", filename, strerror(errno)); + dbg("error on opening %s: %m\n", filename); return; } if (write(fd, "add", 3) < 0) - info("error on triggering %s: %s\n", filename, strerror(errno)); + info("error on triggering %s: %m\n", filename); close(fd); } diff --git a/service/instance.c b/service/instance.c index 35804de..25735ab 100644 --- a/service/instance.c +++ b/service/instance.c @@ -241,8 +241,8 @@ instance_removepid(struct service_instance *in) { if (!in->pidfile) return 0; if (unlink(in->pidfile)) { - ERROR("Failed to removed pidfile: %s: %d - %s\n", - in->pidfile, errno, strerror(errno)); + ERROR("Failed to removed pidfile: %s: %d - %m\n", + in->pidfile, errno); return 1; } return 0; @@ -258,19 +258,19 @@ instance_writepid(struct service_instance *in) } _pidfile = fopen(in->pidfile, "w"); if (_pidfile == NULL) { - ERROR("failed to open pidfile for writing: %s: %d (%s)", - in->pidfile, errno, strerror(errno)); + ERROR("failed to open pidfile for writing: %s: %d (%m)", + in->pidfile, errno); return 1; } if (fprintf(_pidfile, "%d\n", in->proc.pid) < 0) { - ERROR("failed to write pidfile: %s: %d (%s)", - in->pidfile, errno, strerror(errno)); + ERROR("failed to write pidfile: %s: %d (%m)", + in->pidfile, errno); fclose(_pidfile); return 2; } if (fclose(_pidfile)) { - ERROR("failed to close pidfile: %s: %d (%s)", - in->pidfile, errno, strerror(errno)); + ERROR("failed to close pidfile: %s: %d (%m)", + in->pidfile, errno); return 3; } @@ -353,11 +353,11 @@ instance_run(struct service_instance *in, int _stdout, int _stderr) } if (in->gid && setgid(in->gid)) { - ERROR("failed to set group id %d: %d (%s)\n", in->gid, errno, strerror(errno)); + ERROR("failed to set group id %d: %d (%m)\n", in->gid, errno); exit(127); } if (in->uid && setuid(in->uid)) { - ERROR("failed to set user id %d: %d (%s)\n", in->uid, errno, strerror(errno)); + ERROR("failed to set user id %d: %d (%m)\n", in->uid, errno); exit(127); } @@ -407,14 +407,14 @@ instance_start(struct service_instance *in) instance_free_stdio(in); if (in->_stdout.fd.fd > -2) { if (pipe(opipe)) { - ULOG_WARN("pipe() failed: %d (%s)\n", errno, strerror(errno)); + ULOG_WARN("pipe() failed: %d (%m)\n", errno); opipe[0] = opipe[1] = -1; } } if (in->_stderr.fd.fd > -2) { if (pipe(epipe)) { - ULOG_WARN("pipe() failed: %d (%s)\n", errno, strerror(errno)); + ULOG_WARN("pipe() failed: %d (%m)\n", errno); epipe[0] = epipe[1] = -1; } } diff --git a/trace/trace.c b/trace/trace.c index 76b6b7f..b156e2a 100644 --- a/trace/trace.c +++ b/trace/trace.c @@ -326,7 +326,7 @@ int main(int argc, char **argv, char **envp) memcpy(&_envp[newenv], envp, envc * sizeof(char *)); ret = execve(_argv[0], _argv, _envp); - ULOG_ERR("failed to exec %s: %s\n", _argv[0], strerror(errno)); + ULOG_ERR("failed to exec %s: %m\n", _argv[0]); free(_argv); free(_envp); @@ -357,11 +357,11 @@ int main(int argc, char **argv, char **envp) break; } if (ptrace(PTRACE_SEIZE, child, 0, ptrace_options) == -1) { - ULOG_ERR("PTRACE_SEIZE: %s\n", strerror(errno)); + ULOG_ERR("PTRACE_SEIZE: %m\n"); return -1; } if (ptrace(ptrace_restart, child, 0, SIGCONT) == -1) { - ULOG_ERR("ptrace_restart: %s\n", strerror(errno)); + ULOG_ERR("ptrace_restart: %m\n"); return -1; } @@ -377,7 +377,7 @@ int main(int argc, char **argv, char **envp) case UTRACE: if (!json) if (asprintf(&json, "/tmp/%s.%u.json", basename(*argv), child) < 0) - ULOG_ERR("failed to allocate output path: %s\n", strerror(errno)); + ULOG_ERR("failed to allocate output path: %m\n"); break; case SECCOMP_TRACE: if (!violation_count) diff --git a/upgraded/upgraded.c b/upgraded/upgraded.c index 220da79..0b82f20 100644 --- a/upgraded/upgraded.c +++ b/upgraded/upgraded.c @@ -74,17 +74,17 @@ int main(int argc, char **argv) int fd = open("/", O_DIRECTORY|O_PATH); if (fd < 0) { - fprintf(stderr, "unable to open prefix directory: %s\n", strerror(errno)); + fprintf(stderr, "unable to open prefix directory: %m\n"); return 1; } if (chroot(".") < 0) { - fprintf(stderr, "failed to chroot: %s\n", strerror(errno)); + fprintf(stderr, "failed to chroot: %m\n"); return 1; } if (fchdir(fd) == -1) { - fprintf(stderr, "failed to chdir to prefix directory: %s\n", strerror(errno)); + fprintf(stderr, "failed to chdir to prefix directory: %m\n"); return 1; } close(fd); diff --git a/utils/utils.c b/utils/utils.c index e239eda..57c82eb 100644 --- a/utils/utils.c +++ b/utils/utils.c @@ -203,8 +203,8 @@ int patch_stdio(const char *device) for (fd = STDIN_FILENO; fd <= STDERR_FILENO; fd++) { if (patch_fd(device, fd, fd ? O_WRONLY : O_RDONLY)) { - ERROR("Failed to redirect %s to %s: %d (%s)\n", - fdname[fd], device, errno, strerror(errno)); + ERROR("Failed to redirect %s to %s: %d (%m)\n", + fdname[fd], device, errno); rv = -1; } } diff --git a/watchdog.c b/watchdog.c index 97c8337..ec10ba6 100644 --- a/watchdog.c +++ b/watchdog.c @@ -37,7 +37,7 @@ void watchdog_ping(void) { DEBUG(4, "Ping\n"); if (wdt_fd >= 0 && write(wdt_fd, "X", 1) < 0) - ERROR("WDT failed to write: %s\n", strerror(errno)); + ERROR("WDT failed to write: %m\n"); } static void watchdog_timeout_cb(struct uloop_timeout *t) @@ -76,10 +76,10 @@ static void watchdog_close(void) return; if (write(wdt_fd, "V", 1) < 0) - ERROR("WDT failed to write release: %s\n", strerror(errno)); + ERROR("WDT failed to write release: %m\n"); if (close(wdt_fd) == -1) - ERROR("WDT failed to close watchdog: %s\n", strerror(errno)); + ERROR("WDT failed to close watchdog: %m\n"); wdt_fd = -1; }