[lxc-devel] [lxc/master] Use %m instead of strerror(errno) where appropiate

0x0916 on Github lxc-bot at linuxcontainers.org
Fri Jun 23 11:10:04 UTC 2017


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 340 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170623/2285e102/attachment.bin>
-------------- next part --------------
From d4196adbee358aaf26bc251d992a954b6de0736c Mon Sep 17 00:00:00 2001
From: 0x0916 <w at laoqinren.net>
Date: Thu, 15 Jun 2017 17:13:36 +0800
Subject: [PATCH] Use %m instead of strerror(errno) where appropiate

Signed-off-by: 0x0916 <w at laoqinren.net>
---
 hooks/unmount-namespace.c      | 14 +++++++-------
 src/lxc/arguments.c            |  3 +--
 src/lxc/attach.c               | 28 +++++++++++++---------------
 src/lxc/bdev/bdev.c            |  2 +-
 src/lxc/bdev/lxcbtrfs.c        |  3 +--
 src/lxc/bdev/lxcoverlay.c      |  9 ++++-----
 src/lxc/caps.c                 |  6 +++---
 src/lxc/cgroups/cgfsng.c       |  2 +-
 src/lxc/cgroups/cgmanager.c    |  6 +++---
 src/lxc/commands.c             | 40 ++++++++++++++++++----------------------
 src/lxc/conf.c                 | 33 ++++++++++++++++-----------------
 src/lxc/console.c              |  4 ++--
 src/lxc/initutils.c            |  4 ++--
 src/lxc/log.c                  | 11 ++++-------
 src/lxc/log.h                  |  4 ++--
 src/lxc/lxc_monitord.c         | 10 +++++-----
 src/lxc/lxc_user_nic.c         | 29 +++++++++++++----------------
 src/lxc/lxclock.c              |  4 ++--
 src/lxc/monitor.c              | 12 ++++++------
 src/lxc/namespace.c            |  2 +-
 src/lxc/start.c                |  9 ++++-----
 src/lxc/tools/lxc_init.c       |  3 +--
 src/lxc/tools/lxc_unshare.c    |  8 ++++----
 src/lxc/tools/lxc_usernsexec.c |  4 ++--
 src/lxc/utils.c                |  6 +++---
 src/tests/attach.c             |  2 +-
 src/tests/cgpath.c             |  2 +-
 src/tests/console.c            |  2 +-
 src/tests/lxc-test-utils.c     |  4 ++--
 29 files changed, 124 insertions(+), 142 deletions(-)

diff --git a/hooks/unmount-namespace.c b/hooks/unmount-namespace.c
index 99b284481..a002bf2b8 100644
--- a/hooks/unmount-namespace.c
+++ b/hooks/unmount-namespace.c
@@ -191,22 +191,22 @@ int main(int argc, char **argv) {
 	 */
 	procfd = open("/proc", O_RDONLY | O_DIRECTORY | O_PATH);
 	if (procfd < 0) {
-		fprintf(stderr, "%s: failed to open /proc: %s\n", argv[0], strerror(errno));
+		fprintf(stderr, "%s: failed to open /proc: %m\n", argv[0]);
 		return 4;
 	}
 
 	/* Open the mount namespace and enter it. */
 	ctmntfd = open(mntns, O_RDONLY);
 	if (ctmntfd < 0) {
-		fprintf(stderr, "%s: failed to open mount namespace: %s\n",
-			argv[0], strerror(errno));
+		fprintf(stderr, "%s: failed to open mount namespace: %m\n",
+			argv[0]);
 		close(procfd);
 		return 5;
 	}
 
 	if (setns(ctmntfd, CLONE_NEWNS) != 0) {
-		fprintf(stderr, "%s: failed to attach to namespace: %s\n",
-			argv[0], strerror(errno));
+		fprintf(stderr, "%s: failed to attach to namespace: %m\n",
+			argv[0]);
 		close(ctmntfd);
 		close(procfd);
 		return 6;
@@ -215,8 +215,8 @@ int main(int argc, char **argv) {
 
 	/* Now read [[procfd]]/self/mounts */
 	if (!read_mounts(procfd, &mounts, &count)) {
-		fprintf(stderr, "%s: failed to read mountpoints: %s\n",
-			argv[0], strerror(errno));
+		fprintf(stderr, "%s: failed to read mountpoints: %m\n",
+			argv[0]);
 		close(procfd);
 		return 7;
 	}
diff --git a/src/lxc/arguments.c b/src/lxc/arguments.c
index 0d2b2031b..256b6239b 100644
--- a/src/lxc/arguments.c
+++ b/src/lxc/arguments.c
@@ -187,8 +187,7 @@ extern int lxc_arguments_parse(struct lxc_arguments *args,
 
 	ret = build_shortopts(args->options, shortopts, sizeof(shortopts));
 	if (ret < 0) {
-		lxc_error(args, "build_shortopts() failed : %s",
-			  strerror(errno));
+		lxc_error(args, "build_shortopts() failed : %m");
 		return ret;
 	}
 
diff --git a/src/lxc/attach.c b/src/lxc/attach.c
index eae494067..5ec483a7c 100644
--- a/src/lxc/attach.c
+++ b/src/lxc/attach.c
@@ -912,8 +912,7 @@ int lxc_attach(const char* name, const char* lxcpath, lxc_attach_exec_t exec_fun
 		status = 0;
 		ret = lxc_write_nointr(ipc_sockets[0], &status, sizeof(status));
 		if (ret <= 0) {
-			ERROR("Intended to send sequence number 0: %s.",
-			      strerror(errno));
+			ERROR("Intended to send sequence number 0: %m.");
 			goto on_error;
 		}
 
@@ -921,7 +920,7 @@ int lxc_attach(const char* name, const char* lxcpath, lxc_attach_exec_t exec_fun
 		ret = lxc_read_nointr_expect(ipc_sockets[0], &attached_pid, sizeof(attached_pid), NULL);
 		if (ret <= 0) {
 			if (ret != 0)
-				ERROR("Expected to receive pid: %s.", strerror(errno));
+				ERROR("Expected to receive pid: %m.");
 			goto on_error;
 		}
 
@@ -943,7 +942,7 @@ int lxc_attach(const char* name, const char* lxcpath, lxc_attach_exec_t exec_fun
 		status = 0;
 		ret = lxc_write_nointr(ipc_sockets[0], &status, sizeof(status));
 		if (ret <= 0) {
-			ERROR("Intended to send sequence number 0: %s.", strerror(errno));
+			ERROR("Intended to send sequence number 0: %m.");
 			goto on_error;
 		}
 
@@ -952,7 +951,7 @@ int lxc_attach(const char* name, const char* lxcpath, lxc_attach_exec_t exec_fun
 		ret = lxc_read_nointr_expect(ipc_sockets[0], &status, sizeof(status), &expected);
 		if (ret <= 0) {
 			if (ret != 0)
-				ERROR("Expected to receive sequence number 1: %s.", strerror(errno));
+				ERROR("Expected to receive sequence number 1: %m.");
 			goto on_error;
 		}
 
@@ -960,7 +959,7 @@ int lxc_attach(const char* name, const char* lxcpath, lxc_attach_exec_t exec_fun
 		status = 2;
 		ret = lxc_write_nointr(ipc_sockets[0], &status, sizeof(status));
 		if (ret <= 0) {
-			ERROR("Intended to send sequence number 2: %s.", strerror(errno));
+			ERROR("Intended to send sequence number 2: %m.");
 			goto on_error;
 		}
 
@@ -970,8 +969,7 @@ int lxc_attach(const char* name, const char* lxcpath, lxc_attach_exec_t exec_fun
 		expected = 3;
 		ret = lxc_read_nointr_expect(ipc_sockets[0], &status, sizeof(status), &expected);
 		if (ret <= 0) {
-			ERROR("Expected to receive sequence number 3: %s.",
-			      strerror(errno));
+			ERROR("Expected to receive sequence number 3: %m.");
 			goto on_error;
 		}
 
@@ -1034,7 +1032,7 @@ int lxc_attach(const char* name, const char* lxcpath, lxc_attach_exec_t exec_fun
 	status = -1;
 	ret = lxc_read_nointr_expect(ipc_sockets[1], &status, sizeof(status), &expected);
 	if (ret <= 0) {
-		ERROR("Expected to receive sequence number 0: %s.", strerror(errno));
+		ERROR("Expected to receive sequence number 0: %m.");
 		shutdown(ipc_sockets[1], SHUT_RDWR);
 		rexit(-1);
 	}
@@ -1095,7 +1093,7 @@ int lxc_attach(const char* name, const char* lxcpath, lxc_attach_exec_t exec_fun
 		 * CLONE_PARENT) so the parent won't be able to reap it and the
 		 * attached process will remain a zombie.
 		 */
-		ERROR("Intended to send pid %d: %s.", pid, strerror(errno));
+		ERROR("Intended to send pid %d: %m.", pid);
 		shutdown(ipc_sockets[1], SHUT_RDWR);
 		rexit(-1);
 	}
@@ -1129,7 +1127,7 @@ static int attach_child_main(void* data)
 	status = -1;
 	ret = lxc_read_nointr_expect(ipc_socket, &status, sizeof(status), &expected);
 	if (ret <= 0) {
-		ERROR("Expected to receive sequence number 0: %s.", strerror(errno));
+		ERROR("Expected to receive sequence number 0: %m.");
 		shutdown(ipc_socket, SHUT_RDWR);
 		rexit(-1);
 	}
@@ -1230,7 +1228,7 @@ static int attach_child_main(void* data)
 	status = 1;
 	ret = lxc_write_nointr(ipc_socket, &status, sizeof(status));
 	if (ret != sizeof(status)) {
-		ERROR("Intended to send sequence number 1: %s.", strerror(errno));
+		ERROR("Intended to send sequence number 1: %m.");
 		shutdown(ipc_socket, SHUT_RDWR);
 		rexit(-1);
 	}
@@ -1242,7 +1240,7 @@ static int attach_child_main(void* data)
 	status = -1;
 	ret = lxc_read_nointr_expect(ipc_socket, &status, sizeof(status), &expected);
 	if (ret <= 0) {
-		ERROR("Expected to receive sequence number 2: %s", strerror(errno));
+		ERROR("Expected to receive sequence number 2: %m");
 		shutdown(ipc_socket, SHUT_RDWR);
 		rexit(-1);
 	}
@@ -1265,7 +1263,7 @@ static int attach_child_main(void* data)
 	status = 3;
 	ret = lxc_write_nointr(ipc_socket, &status, sizeof(status));
 	if (ret <= 0) {
-		ERROR("Intended to send sequence number 3: %s.", strerror(errno));
+		ERROR("Intended to send sequence number 3: %m.");
 		shutdown(ipc_socket, SHUT_RDWR);
 		rexit(-1);
 	}
@@ -1275,7 +1273,7 @@ static int attach_child_main(void* data)
 		/* Receive fd for LSM security module. */
 		ret = lxc_abstract_unix_recv_fds(ipc_socket, &lsm_labelfd, 1, NULL, 0);
 		if (ret <= 0) {
-			ERROR("Expected to receive file descriptor: %s.", strerror(errno));
+			ERROR("Expected to receive file descriptor: %m.");
 			shutdown(ipc_socket, SHUT_RDWR);
 			rexit(-1);
 		}
diff --git a/src/lxc/bdev/bdev.c b/src/lxc/bdev/bdev.c
index 91eb42a0a..1a2665ff4 100644
--- a/src/lxc/bdev/bdev.c
+++ b/src/lxc/bdev/bdev.c
@@ -959,7 +959,7 @@ static int find_fstype_cb(char *buffer, void *data)
 	}
 
 	if (mount(cbarg->rootfs, cbarg->target, fstype, mntflags, mntdata)) {
-		DEBUG("mount failed with error: %s", strerror(errno));
+		DEBUG("mount failed with error: %m");
 		free(mntdata);
 		return 0;
 	}
diff --git a/src/lxc/bdev/lxcbtrfs.c b/src/lxc/bdev/lxcbtrfs.c
index 74edc6793..63c65c7a6 100644
--- a/src/lxc/bdev/lxcbtrfs.c
+++ b/src/lxc/bdev/lxcbtrfs.c
@@ -116,8 +116,7 @@ int btrfs_list_get_path_rootid(int fd, u64 *treeid)
 
 	ret = ioctl(fd, BTRFS_IOC_INO_LOOKUP, &args);
 	if (ret < 0) {
-		WARN("Warning: can't perform the search -%s\n",
-				strerror(errno));
+		WARN("Warning: can't perform the search -%m\n");
 		return ret;
 	}
 	*treeid = args.treeid;
diff --git a/src/lxc/bdev/lxcoverlay.c b/src/lxc/bdev/lxcoverlay.c
index 65daed8db..f5ef7d03e 100644
--- a/src/lxc/bdev/lxcoverlay.c
+++ b/src/lxc/bdev/lxcoverlay.c
@@ -417,17 +417,16 @@ int ovl_mount(struct bdev *bdev)
 				    MS_MGC_VAL | mntflags, options_work);
 	if (ret < 0) {
 		INFO("Overlayfs: Error mounting %s onto %s with options %s. "
-		     "Retrying without workdir: %s.",
-		     lower, bdev->dest, options_work, strerror(errno));
+		     "Retrying without workdir: %m.",
+		     lower, bdev->dest, options_work);
 
                 /* Assume we cannot use a workdir as we are on a version <= v21. */
 		ret = ovl_remount_on_enodev(lower, bdev->dest, ovl_name,
 					  MS_MGC_VAL | mntflags, options);
 		if (ret < 0)
 			SYSERROR("Overlayfs: Error mounting %s onto %s with "
-				 "options %s: %s.",
-				 lower, bdev->dest, options,
-				 strerror(errno));
+				 "options %s: %m.",
+				 lower, bdev->dest, options);
 		else
 			INFO("Overlayfs: Mounted %s onto %s with options %s.",
 			     lower, bdev->dest, options);
diff --git a/src/lxc/caps.c b/src/lxc/caps.c
index 195707fa4..ad89f0e6d 100644
--- a/src/lxc/caps.c
+++ b/src/lxc/caps.c
@@ -216,7 +216,7 @@ static bool lxc_cap_is_set(cap_t caps, cap_value_t cap, cap_flag_t flag)
 
 	ret = cap_get_flag(caps, cap, flag, &flagval);
 	if (ret < 0) {
-		ERROR("Failed to perform cap_get_flag(): %s.", strerror(errno));
+		ERROR("Failed to perform cap_get_flag(): %m.");
 		return false;
 	}
 
@@ -237,7 +237,7 @@ bool lxc_file_cap_is_set(const char *path, cap_value_t cap, cap_flag_t flag)
 		 * case errno will be set to ENODATA.
 		 */
 		if (errno != ENODATA)
-			ERROR("Failed to perform cap_get_file(): %s.\n", strerror(errno));
+			ERROR("Failed to perform cap_get_file(): %m.\n");
 		return false;
 	}
 
@@ -257,7 +257,7 @@ bool lxc_proc_cap_is_set(cap_value_t cap, cap_flag_t flag)
 
 	caps = cap_get_proc();
 	if (!caps) {
-		ERROR("Failed to perform cap_get_proc(): %s.\n", strerror(errno));
+		ERROR("Failed to perform cap_get_proc(): %m.\n");
 		return false;
 	}
 
diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c
index fd71c106d..884854001 100644
--- a/src/lxc/cgroups/cgfsng.c
+++ b/src/lxc/cgroups/cgfsng.c
@@ -1386,7 +1386,7 @@ static inline bool cgfsng_create(void *hdata)
 	for (i = 0; hierarchies[i]; i++) {
 		if (!create_path_for_hierarchy(hierarchies[i], cgname)) {
 			int j;
-			SYSERROR("Failed to create %s: %s", hierarchies[i]->fullcgpath, strerror(errno));
+			SYSERROR("Failed to create %s: %m", hierarchies[i]->fullcgpath);
 			free(hierarchies[i]->fullcgpath);
 			hierarchies[i]->fullcgpath = NULL;
 			for (j = 0; j < i; j++)
diff --git a/src/lxc/cgroups/cgmanager.c b/src/lxc/cgroups/cgmanager.c
index 6917d3c05..af2b6f212 100644
--- a/src/lxc/cgroups/cgmanager.c
+++ b/src/lxc/cgroups/cgmanager.c
@@ -387,7 +387,7 @@ static int do_chown_cgroup(const char *controller, const char *cgroup_path,
 	fds.events = POLLIN;
 	fds.revents = 0;
 	if (poll(&fds, 1, -1) <= 0) {
-		ERROR("Error getting go-ahead from server: %s", strerror(errno));
+		ERROR("Error getting go-ahead from server: %m");
 		goto out;
 	}
 	if (read(sv[0], &buf, 1) != 1) {
@@ -402,7 +402,7 @@ static int do_chown_cgroup(const char *controller, const char *cgroup_path,
 	fds.events = POLLIN;
 	fds.revents = 0;
 	if (poll(&fds, 1, -1) <= 0) {
-		ERROR("Error getting go-ahead from server: %s", strerror(errno));
+		ERROR("Error getting go-ahead from server: %m");
 		goto out;
 	}
 	if (read(sv[0], &buf, 1) != 1) {
@@ -417,7 +417,7 @@ static int do_chown_cgroup(const char *controller, const char *cgroup_path,
 	fds.events = POLLIN;
 	fds.revents = 0;
 	if (poll(&fds, 1, -1) <= 0) {
-		ERROR("Error getting go-ahead from server: %s", strerror(errno));
+		ERROR("Error getting go-ahead from server: %m");
 		goto out;
 	}
 	ret = read(sv[0], buf, 1);
diff --git a/src/lxc/commands.c b/src/lxc/commands.c
index 81f7ff799..bfc531229 100644
--- a/src/lxc/commands.c
+++ b/src/lxc/commands.c
@@ -176,8 +176,8 @@ static int lxc_cmd_rsp_recv(int sock, struct lxc_cmd_rr *cmd)
 
 	ret = lxc_abstract_unix_recv_fds(sock, &rspfd, 1, rsp, sizeof(*rsp));
 	if (ret < 0) {
-		WARN("Command %s failed to receive response: %s.",
-		     lxc_cmd_str(cmd->req.cmd), strerror(errno));
+		WARN("Command %s failed to receive response: %m.",
+		     lxc_cmd_str(cmd->req.cmd));
 		return -1;
 	}
 
@@ -221,8 +221,8 @@ static int lxc_cmd_rsp_recv(int sock, struct lxc_cmd_rr *cmd)
 	}
 	ret = recv(sock, rsp->data, rsp->datalen, 0);
 	if (ret != rsp->datalen) {
-		ERROR("Command %s failed to receive response data: %s.",
-		      lxc_cmd_str(cmd->req.cmd), strerror(errno));
+		ERROR("Command %s failed to receive response data: %m.",
+		      lxc_cmd_str(cmd->req.cmd));
 		if (ret >= 0)
 			ret = -1;
 	}
@@ -244,16 +244,15 @@ static int lxc_cmd_rsp_send(int fd, struct lxc_cmd_rsp *rsp)
 
 	ret = send(fd, rsp, sizeof(*rsp), 0);
 	if (ret != sizeof(*rsp)) {
-		ERROR("Failed to send command response %d: %s.", ret,
-		      strerror(errno));
+		ERROR("Failed to send command response %d: %m.", ret);
 		return -1;
 	}
 
 	if (rsp->datalen > 0) {
 		ret = send(fd, rsp->data, rsp->datalen, 0);
 		if (ret != rsp->datalen) {
-			WARN("Failed to send command response data %d: %s.",
-			     ret, strerror(errno));
+			WARN("Failed to send command response data %d: %m.",
+			     ret);
 			return -1;
 		}
 	}
@@ -308,14 +307,12 @@ static int lxc_cmd(const char *name, struct lxc_cmd_rr *cmd, int *stopped,
 	      lxc_cmd_str(cmd->req.cmd), offset);
 	if (sock < 0) {
 		if (errno == ECONNREFUSED) {
-			TRACE("command %s failed to connect to \"@%s\": %s",
-			      lxc_cmd_str(cmd->req.cmd), offset,
-			      strerror(errno));
+			TRACE("command %s failed to connect to \"@%s\": %m",
+			      lxc_cmd_str(cmd->req.cmd), offset);
 			*stopped = 1;
 		} else {
-			SYSERROR("command %s failed to connect to \"@%s\": %s",
-				 lxc_cmd_str(cmd->req.cmd), offset,
-				 strerror(errno));
+			SYSERROR("command %s failed to connect to \"@%s\": %m",
+				 lxc_cmd_str(cmd->req.cmd), offset);
 		}
 
 		return -1;
@@ -478,8 +475,8 @@ char *lxc_cmd_get_cgroup_path(const char *name, const char *lxcpath,
 
 	ret = lxc_cmd(name, &cmd, &stopped, lxcpath, NULL);
 	if (ret < 0) {
-		TRACE("command %s failed for container \"%s\": %s.",
-		      lxc_cmd_str(cmd.req.cmd), name, strerror(errno));
+		TRACE("command %s failed for container \"%s\": %m.",
+		      lxc_cmd_str(cmd.req.cmd), name);
 		return NULL;
 	}
 
@@ -899,8 +896,7 @@ int lxc_cmd_state_server(const char *name, const char *lxcpath,
 	state = lxc_getstate(name, lxcpath);
 	if (state < 0) {
 		process_unlock();
-		TRACE("failed to retrieve state of container: %s",
-		      strerror(errno));
+		TRACE("failed to retrieve state of container: %m");
 		return -1;
 	} else if (states[state]) {
 		process_unlock();
@@ -937,7 +933,7 @@ int lxc_cmd_state_server(const char *name, const char *lxcpath,
 	ret = lxc_cmd(name, &cmd, &stopped, lxcpath, NULL);
 	process_unlock();
 	if (ret < 0) {
-		ERROR("failed to execute command: %s", strerror(errno));
+		ERROR("failed to execute command: %m");
 		return -1;
 	}
 	/* We should now be guaranteed to get an answer from the state sending
@@ -955,7 +951,7 @@ int lxc_cmd_state_server(const char *name, const char *lxcpath,
 		if (errno == EINTR)
 			goto again;
 
-		ERROR("failed to receive message: %s", strerror(errno));
+		ERROR("failed to receive message: %m");
 		return -1;
 	}
 	if (ret == 0) {
@@ -1161,8 +1157,8 @@ int lxc_cmd_init(const char *name, struct lxc_handler *handler,
 
 	fd = lxc_abstract_unix_open(path, SOCK_STREAM, 0);
 	if (fd < 0) {
-		ERROR("Failed to create the command service point %s: %s.",
-		      offset, strerror(errno));
+		ERROR("Failed to create the command service point %s: %m.",
+		      offset);
 		if (errno == EADDRINUSE)
 			ERROR("Container \"%s\" appears to be already running!", name);
 		return -1;
diff --git a/src/lxc/conf.c b/src/lxc/conf.c
index 881a68829..50551b1b0 100644
--- a/src/lxc/conf.c
+++ b/src/lxc/conf.c
@@ -1450,7 +1450,7 @@ static int lxc_setup_dev_console(const struct lxc_rootfs *rootfs,
 	if (file_exists(path)) {
 		ret = lxc_unstack_mountpoint(path, false);
 		if (ret < 0) {
-			ERROR("failed to unmount \"%s\": %s", path, strerror(errno));
+			ERROR("failed to unmount \"%s\": %m", path);
 			return -ret;
 		} else {
 			DEBUG("cleared all (%d) mounts from \"%s\"", ret, path);
@@ -1555,13 +1555,13 @@ static int lxc_setup_ttydir_console(const struct lxc_rootfs *rootfs,
 		ret = safe_mount(path, lxcpath, "none", MS_MOVE, NULL, rootfs->mount);
 		if (ret < 0) {
 			if (errno != EINVAL) {
-				ERROR("failed to MS_MOVE \"%s\" to \"%s\": %s", path, lxcpath, strerror(errno));
+				ERROR("failed to MS_MOVE \"%s\" to \"%s\": %m", path, lxcpath);
 				return -errno;
 			}
 			/* path was not a mountpoint */
 			ret = rename(path, lxcpath);
 			if (ret < 0) {
-				ERROR("failed to rename \"%s\" to \"%s\": %s", path, lxcpath, strerror(errno));
+				ERROR("failed to rename \"%s\" to \"%s\": %m", path, lxcpath);
 				return -errno;
 			}
 			DEBUG("renamed \"%s\" to \"%s\"", path, lxcpath);
@@ -1572,7 +1572,7 @@ static int lxc_setup_ttydir_console(const struct lxc_rootfs *rootfs,
 		/* Clear all remaining bind-mounts. */
 		ret = lxc_unstack_mountpoint(path, false);
 		if (ret < 0) {
-			ERROR("failed to unmount \"%s\": %s", path, strerror(errno));
+			ERROR("failed to unmount \"%s\": %m", path);
 			return -ret;
 		} else {
 			DEBUG("cleared all (%d) mounts from \"%s\"", ret, path);
@@ -1581,7 +1581,7 @@ static int lxc_setup_ttydir_console(const struct lxc_rootfs *rootfs,
 		if (file_exists(path)) {
 			ret = lxc_unstack_mountpoint(path, false);
 			if (ret < 0) {
-				ERROR("failed to unmount \"%s\": %s", path, strerror(errno));
+				ERROR("failed to unmount \"%s\": %m", path);
 				return -ret;
 			} else {
 				DEBUG("cleared all (%d) mounts from \"%s\"", ret, path);
@@ -1754,8 +1754,8 @@ static int mount_entry(const char *fsname, const char *target,
 
 	if (safe_mount(fsname, target, fstype, mountflags & ~MS_REMOUNT, data, rootfs)) {
 		if (optional) {
-			INFO("failed to mount '%s' on '%s' (optional): %s", fsname,
-			     target, strerror(errno));
+			INFO("failed to mount '%s' on '%s' (optional): %m", fsname,
+			     target);
 			return 0;
 		}
 		else {
@@ -1801,8 +1801,8 @@ static int mount_entry(const char *fsname, const char *target,
 		if (mount(fsname, target, fstype,
 			  mountflags | MS_REMOUNT, data) < 0) {
 			if (optional) {
-				INFO("failed to mount '%s' on '%s' (optional): %s",
-					 fsname, target, strerror(errno));
+				INFO("failed to mount '%s' on '%s' (optional): %m",
+					 fsname, target);
 				return 0;
 			}
 			else {
@@ -2266,7 +2266,7 @@ static int setup_hw_addr(char *hwaddr, const char *ifname)
 
 	fd = socket(AF_INET, SOCK_DGRAM, 0);
 	if (fd < 0) {
-		ERROR("socket failure : %s", strerror(errno));
+		ERROR("socket failure : %m");
 		return -1;
 	}
 
@@ -2584,7 +2584,7 @@ int setup_resource_limits(struct lxc_list *limits, pid_t pid) {
 		}
 
 		if (prlimit(pid, resid, &lim->limit, NULL) != 0) {
-			ERROR("failed to set limit %s: %s", lim->resource, strerror(errno));
+			ERROR("failed to set limit %s: %m", lim->resource);
 			return -1;
 		}
 	}
@@ -3696,14 +3696,14 @@ int lxc_create_tty(const char *name, struct lxc_conf *conf)
 		ret = fcntl(pty_info->master, F_SETFD, FD_CLOEXEC);
 		if (ret < 0)
 			WARN("failed to set FD_CLOEXEC flag on master fd %d of "
-			     "pty device \"%s\": %s",
-			     pty_info->master, pty_info->name, strerror(errno));
+			     "pty device \"%s\": %m",
+			     pty_info->master, pty_info->name);
 
 		ret = fcntl(pty_info->slave, F_SETFD, FD_CLOEXEC);
 		if (ret < 0)
 			WARN("failed to set FD_CLOEXEC flag on slave fd %d of "
-			     "pty device \"%s\": %s",
-			     pty_info->slave, pty_info->name, strerror(errno));
+			     "pty device \"%s\": %m",
+			     pty_info->slave, pty_info->name);
 
 		pty_info->busy = 0;
 	}
@@ -4103,8 +4103,7 @@ static int lxc_send_ttys_to_parent(struct lxc_handler *handler)
 
 	ret = lxc_abstract_unix_send_fds(sock, ttyfds, num_ttyfds, NULL, 0);
 	if (ret < 0)
-		ERROR("failed to send %d ttys to parent: %s", conf->tty,
-		      strerror(errno));
+		ERROR("failed to send %d ttys to parent: %m", conf->tty);
 	else
 		TRACE("sent %d ttys to parent", conf->tty);
 
diff --git a/src/lxc/console.c b/src/lxc/console.c
index 666754d27..81cdcee4d 100755
--- a/src/lxc/console.c
+++ b/src/lxc/console.c
@@ -449,7 +449,7 @@ static int lxc_console_peer_default(struct lxc_console *console)
 
 	console->peer = lxc_unpriv(open(path, O_CLOEXEC | O_RDWR | O_CREAT | O_APPEND, 0600));
 	if (console->peer < 0) {
-		ERROR("failed to open \"%s\": %s", path, strerror(errno));
+		ERROR("failed to open \"%s\": %m", path);
 		return -ENOTTY;
 	}
 	DEBUG("using \"%s\" as peer tty device", path);
@@ -760,7 +760,7 @@ int lxc_console(struct lxc_container *c, int ttynum,
 err1:
 	if (istty) {
 		if (tcsetattr(stdinfd, TCSAFLUSH, &oldtios) < 0)
-			WARN("failed to reset terminal properties: %s.", strerror(errno));
+			WARN("failed to reset terminal properties: %m.");
 	}
 
 	return ret;
diff --git a/src/lxc/initutils.c b/src/lxc/initutils.c
index 8d9016cd0..d0770a258 100644
--- a/src/lxc/initutils.c
+++ b/src/lxc/initutils.c
@@ -30,10 +30,10 @@ static int mount_fs(const char *source, const char *target, const char *type)
 {
 	/* the umount may fail */
 	if (umount(target))
-		WARN("failed to unmount %s : %s", target, strerror(errno));
+		WARN("failed to unmount %s : %m", target);
 
 	if (mount(source, target, type, 0, NULL)) {
-		ERROR("failed to mount %s : %s", target, strerror(errno));
+		ERROR("failed to mount %s : %m", target);
 		return -1;
 	}
 
diff --git a/src/lxc/log.c b/src/lxc/log.c
index edbd785ef..eae5b48f0 100644
--- a/src/lxc/log.c
+++ b/src/lxc/log.c
@@ -377,8 +377,7 @@ static int log_open(const char *name)
 	fd = lxc_unpriv(open(name, O_CREAT | O_WRONLY |
 			     O_APPEND | O_CLOEXEC, 0666));
 	if (fd == -1) {
-		ERROR("failed to open log file \"%s\" : %s", name,
-		      strerror(errno));
+		ERROR("failed to open log file \"%s\" : %m", name);
 		return -1;
 	}
 
@@ -387,7 +386,7 @@ static int log_open(const char *name)
 
 	newfd = fcntl(fd, F_DUPFD_CLOEXEC, 3);
 	if (newfd == -1)
-		ERROR("failed to dup log fd %d : %s", fd, strerror(errno));
+		ERROR("failed to dup log fd %d : %m", fd);
 
 	close(fd);
 	return newfd;
@@ -489,8 +488,7 @@ static int __lxc_log_set_file(const char *fname, int create_dirs)
 	if (create_dirs)
 #endif
 	if (build_dir(fname)) {
-		ERROR("failed to create dir for log file \"%s\" : %s", fname,
-		      strerror(errno));
+		ERROR("failed to create dir for log file \"%s\" : %m", fname);
 		return -1;
 	}
 
@@ -654,8 +652,7 @@ extern int lxc_log_set_file(int *fd, const char *fname)
 	}
 
 	if (build_dir(fname)) {
-		ERROR("failed to create dir for log file \"%s\" : %s", fname,
-				strerror(errno));
+		ERROR("failed to create dir for log file \"%s\" : %m", fname);
 		return -1;
 	}
 
diff --git a/src/lxc/log.h b/src/lxc/log.h
index 960209777..c642f19b5 100644
--- a/src/lxc/log.h
+++ b/src/lxc/log.h
@@ -342,8 +342,8 @@ ATTR_UNUSED static inline void LXC_##LEVEL(struct lxc_log_locinfo* locinfo,	\
 
 
 
-#define SYSERROR(format, ...) do {				    	\
-	ERROR("%s - " format, strerror(errno), ##__VA_ARGS__);		\
+#define SYSERROR(format, ...) do {					\
+	ERROR("%m - " format, ##__VA_ARGS__);				\
 } while (0)
 
 extern int lxc_log_fd;
diff --git a/src/lxc/lxc_monitord.c b/src/lxc/lxc_monitord.c
index 456c4fc94..2eb3527b7 100644
--- a/src/lxc/lxc_monitord.c
+++ b/src/lxc/lxc_monitord.c
@@ -89,7 +89,7 @@ static int lxc_monitord_fifo_create(struct lxc_monitor *mon)
 
 	ret = mknod(fifo_path, S_IFIFO|S_IRUSR|S_IWUSR, 0);
 	if (ret < 0 && errno != EEXIST) {
-		INFO("Failed to mknod monitor fifo %s: %s.", fifo_path, strerror(errno));
+		INFO("Failed to mknod monitor fifo %s: %m.", fifo_path);
 		return -1;
 	}
 
@@ -239,7 +239,7 @@ static int lxc_monitord_sock_create(struct lxc_monitor *mon)
 
 	fd = lxc_abstract_unix_open(addr.sun_path, SOCK_STREAM, O_TRUNC);
 	if (fd < 0) {
-		ERROR("Failed to open unix socket: %s.", strerror(errno));
+		ERROR("Failed to open unix socket: %m.");
 		return -1;
 	}
 
@@ -298,15 +298,15 @@ static int lxc_monitord_fifo_handler(int fd, uint32_t events, void *data,
 
 	ret = read(fd, &msglxc, sizeof(msglxc));
 	if (ret != sizeof(msglxc)) {
-		SYSERROR("Reading from fifo failed: %s.", strerror(errno));
+		SYSERROR("Reading from fifo failed: %m.");
 		return 1;
 	}
 
 	for (i = 0; i < mon->clientfds_cnt; i++) {
 		ret = write(mon->clientfds[i], &msglxc, sizeof(msglxc));
 		if (ret < 0)
-			ERROR("Failed to send message to client file descriptor %d: %s.",
-			      mon->clientfds[i], strerror(errno));
+			ERROR("Failed to send message to client file descriptor %d: %m.",
+			      mon->clientfds[i]);
 	}
 
 	return 0;
diff --git a/src/lxc/lxc_user_nic.c b/src/lxc/lxc_user_nic.c
index c93b4cc70..0e2f1d203 100644
--- a/src/lxc/lxc_user_nic.c
+++ b/src/lxc/lxc_user_nic.c
@@ -73,7 +73,7 @@ static int open_and_lock(char *path)
 
 	fd = open(path, O_RDWR|O_CREAT, S_IWUSR | S_IRUSR);
 	if (fd < 0) {
-		usernic_error("Failed to open %s: %s.\n", path, strerror(errno));
+		usernic_error("Failed to open %s: %m.\n", path);
 		return -1;
 	}
 
@@ -82,7 +82,7 @@ static int open_and_lock(char *path)
 	lk.l_start = 0;
 	lk.l_len = 0;
 	if (fcntl(fd, F_SETLKW, &lk) < 0) {
-		usernic_error("Failed to lock %s: %s.\n", path, strerror(errno));
+		usernic_error("Failed to lock %s: %m.\n", path);
 		close(fd);
 		return -1;
 	}
@@ -279,7 +279,7 @@ static int get_alloted(char *me, char *intype, char *link, struct alloted_s **al
 
 	fin = fopen(LXC_USERNIC_CONF, "r");
 	if (!fin) {
-		usernic_error("Failed to open \"%s\": %s.\n", LXC_USERNIC_CONF, strerror(errno));
+		usernic_error("Failed to open \"%s\": %m.\n", LXC_USERNIC_CONF);
 		return -1;
 	}
 
@@ -786,8 +786,7 @@ static int rename_in_ns(int pid, char *oldname, char **newnamep)
 	fd = -1;
 	if (ret < 0) {
 		usernic_error("Failed to setns() to the network namespace of "
-			      "the container with PID %d: %s.\n",
-			      pid, strerror(errno));
+			      "the container with PID %d: %m.\n", pid);
 		goto do_partial_cleanup;
 	}
 
@@ -795,8 +794,7 @@ static int rename_in_ns(int pid, char *oldname, char **newnamep)
 	if (ret < 0) {
 		usernic_error("Failed to drop privilege by setting effective "
 			      "user id and real user id to %d, and saved user "
-			      "ID to 0: %s.\n",
-			      ruid, strerror(errno));
+			      "ID to 0: %m.\n", ruid);
 		// COMMENT(brauner): It's ok to jump to do_full_cleanup here
 		// since setresuid() will succeed when trying to set real,
 		// effective, and saved to values they currently have.
@@ -841,8 +839,8 @@ static int rename_in_ns(int pid, char *oldname, char **newnamep)
 	if (ret < 0) {
 		usernic_error("Failed to restore privilege by setting effective "
 			      "user id to %d, real user id to %d, and saved user "
-			      "ID to %d: %s.\n",
-			      ruid, euid, suid, strerror(errno));
+			      "ID to %d: %m.\n",
+			      ruid, euid, suid);
 		fret = -1;
 		// COMMENT(brauner): setns() should fail if setresuid() doesn't
 		// succeed but there's no harm in falling through; keeps the
@@ -852,8 +850,7 @@ static int rename_in_ns(int pid, char *oldname, char **newnamep)
 	ret = setns(ofd, CLONE_NEWNET);
 	if (ret < 0) {
 		usernic_error("Failed to setns() to original network namespace "
-			      "of PID %d: %s.\n",
-			      ofd, strerror(errno));
+			      "of PID %d: %m.\n", ofd);
 		fret = -1;
 	}
 
@@ -889,8 +886,8 @@ static bool may_access_netns(int pid)
 	if (ret < 0) {
 		usernic_error("Failed to drop privilege by setting effective "
 			      "user id and real user id to %d, and saved user "
-			      "ID to %d: %s.\n",
-			      ruid, euid, strerror(errno));
+			      "ID to %d: %m.\n",
+			      ruid, euid);
 		return false;
 	}
 
@@ -902,14 +899,14 @@ static bool may_access_netns(int pid)
 	may_access = true;
 	if (ret < 0)  {
 		may_access = false;
-		usernic_error("Uid %d may not access %s: %s\n", (int)ruid, s, strerror(errno));
+		usernic_error("Uid %d may not access %s: %m\n", (int)ruid, s);
 	}
 
 	ret = setresuid(ruid, euid, suid);
 	if (ret < 0) {
 		usernic_error("Failed to restore user id to %d, real user id "
-			      "to %d, and saved user ID to %d: %s.\n",
-			      ruid, euid, suid, strerror(errno));
+			      "to %d, and saved user ID to %d: %m.\n",
+			      ruid, euid, suid);
 		may_access = false;
 	}
 
diff --git a/src/lxc/lxclock.c b/src/lxc/lxclock.c
index e9e95f7a0..0db36e751 100644
--- a/src/lxc/lxclock.c
+++ b/src/lxc/lxclock.c
@@ -78,7 +78,7 @@ static void lock_mutex(pthread_mutex_t *l)
 	int ret;
 
 	if ((ret = pthread_mutex_lock(l)) != 0) {
-		fprintf(stderr, "pthread_mutex_lock returned:%d %s\n", ret, strerror(ret));
+		fprintf(stderr, "pthread_mutex_lock returned:%d %m\n", ret);
 		dump_stacktrace();
 		exit(1);
 	}
@@ -89,7 +89,7 @@ static void unlock_mutex(pthread_mutex_t *l)
 	int ret;
 
 	if ((ret = pthread_mutex_unlock(l)) != 0) {
-		fprintf(stderr, "pthread_mutex_unlock returned:%d %s\n", ret, strerror(ret));
+		fprintf(stderr, "pthread_mutex_unlock returned:%d %m\n", ret);
 		dump_stacktrace();
 		exit(1);
 	}
diff --git a/src/lxc/monitor.c b/src/lxc/monitor.c
index 1758402a9..bb319aba4 100644
--- a/src/lxc/monitor.c
+++ b/src/lxc/monitor.c
@@ -108,7 +108,7 @@ static void lxc_monitor_fifo_send(struct lxc_msg *msg, const char *lxcpath)
 		if (errno == ENXIO)
 			return;
 
-		WARN("Failed to open fifo to send message: %s.", strerror(errno));
+		WARN("Failed to open fifo to send message: %m.");
 		return;
 	}
 
@@ -217,7 +217,7 @@ int lxc_monitor_open(const char *lxcpath)
 
 	fd = socket(PF_UNIX, SOCK_STREAM, 0);
 	if (fd < 0) {
-		ERROR("Failed to create socket: %s.", strerror(errno));
+		ERROR("Failed to create socket: %m.");
 		return -errno;
 	}
 
@@ -226,7 +226,7 @@ int lxc_monitor_open(const char *lxcpath)
 	if (len >= sizeof(addr.sun_path) - 1) {
 		errno = ENAMETOOLONG;
 		ret = -errno;
-		ERROR("name of monitor socket too long (%zu bytes): %s", len, strerror(errno));
+		ERROR("name of monitor socket too long (%zu bytes): %m", len);
 		goto on_error;
 	}
 
@@ -234,13 +234,13 @@ int lxc_monitor_open(const char *lxcpath)
 		fd = lxc_abstract_unix_connect(addr.sun_path);
 		if (fd < 0 || errno != ECONNREFUSED)
 			break;
-		ERROR("Failed to connect to monitor socket. Retrying in %d ms: %s", backoff_ms[retry], strerror(errno));
+		ERROR("Failed to connect to monitor socket. Retrying in %d ms: %m", backoff_ms[retry]);
 		usleep(backoff_ms[retry] * 1000);
 	}
 
 	if (fd < 0) {
 		ret = -errno;
-		ERROR("Failed to connect to monitor socket: %s.", strerror(errno));
+		ERROR("Failed to connect to monitor socket: %m.");
 		goto on_error;
 	}
 	ret = 0;
@@ -272,7 +272,7 @@ int lxc_monitor_read_fdset(struct pollfd *fds, nfds_t nfds, struct lxc_msg *msg,
 			fds[i].revents = 0;
 			ret = recv(fds[i].fd, msg, sizeof(*msg), 0);
 			if (ret <= 0) {
-				SYSERROR("Failed to receive message. Did monitord die?: %s.", strerror(errno));
+				SYSERROR("Failed to receive message. Did monitord die?: %m.");
 				return -1;
 			}
 			return ret;
diff --git a/src/lxc/namespace.c b/src/lxc/namespace.c
index 3a5b3bef6..70e8ce813 100644
--- a/src/lxc/namespace.c
+++ b/src/lxc/namespace.c
@@ -64,7 +64,7 @@ pid_t lxc_clone(int (*fn)(void *), void *arg, int flags)
 	ret = clone(do_clone, stack  + stack_size, flags | SIGCHLD, &clone_arg);
 #endif
 	if (ret < 0)
-		ERROR("Failed to clone (%#x): %s.", flags, strerror(errno));
+		ERROR("Failed to clone (%#x): %m.", flags);
 
 	return ret;
 }
diff --git a/src/lxc/start.c b/src/lxc/start.c
index 11854f905..fc400580e 100644
--- a/src/lxc/start.c
+++ b/src/lxc/start.c
@@ -160,7 +160,7 @@ static bool preserve_ns(int ns_fd[LXC_NS_MAX], int clone_flags, pid_t pid)
 	if (errno == ENOENT)
 		SYSERROR("Kernel does not support attaching to %s namespaces.", ns_info[i].proc_name);
 	else
-		SYSERROR("Failed to open file descriptor for %s namespace: %s.", ns_info[i].proc_name, strerror(errno));
+		SYSERROR("Failed to open file descriptor for %s namespace: %m.", ns_info[i].proc_name);
 	close_ns(ns_fd);
 	return false;
 }
@@ -760,9 +760,9 @@ static int must_drop_cap_sys_boot(struct lxc_conf *conf)
 #endif
 	if (pid < 0) {
 		if (flags & CLONE_NEWUSER)
-			ERROR("Failed to clone (%#x): %s (includes CLONE_NEWUSER).", flags, strerror(errno));
+			ERROR("Failed to clone (%#x): %m (includes CLONE_NEWUSER).", flags);
 		else
-			ERROR("Failed to clone (%#x): %s.", flags, strerror(errno));
+			ERROR("Failed to clone (%#x): %m.", flags);
 		return -1;
 	}
 	if (wait(&status) < 0) {
@@ -1153,8 +1153,7 @@ static int lxc_recv_ttys_from_child(struct lxc_handler *handler)
 	free(ttyfds);
 
 	if (ret < 0)
-		ERROR("failed to receive %d ttys from child: %s", conf->tty,
-		      strerror(errno));
+		ERROR("failed to receive %d ttys from child: %m", conf->tty);
 	else
 		TRACE("received %d ttys from child", conf->tty);
 
diff --git a/src/lxc/tools/lxc_init.c b/src/lxc/tools/lxc_init.c
index 9c5490e4e..a239be296 100644
--- a/src/lxc/tools/lxc_init.c
+++ b/src/lxc/tools/lxc_init.c
@@ -243,8 +243,7 @@ int main(int argc, char *argv[])
 			if (errno == EINTR)
 				continue;
 
-			ERROR("failed to wait child : %s",
-			      strerror(errno));
+			ERROR("failed to wait child : %m");
 			goto out;
 		}
 
diff --git a/src/lxc/tools/lxc_unshare.c b/src/lxc/tools/lxc_unshare.c
index a0f943fd5..0c6018482 100644
--- a/src/lxc/tools/lxc_unshare.c
+++ b/src/lxc/tools/lxc_unshare.c
@@ -133,19 +133,19 @@ static int do_start(void *arg)
 
 	if ((flags & CLONE_NEWUTS) && want_hostname)
 		if (sethostname(want_hostname, strlen(want_hostname)) < 0) {
-			ERROR("failed to set hostname %s: %s", want_hostname, strerror(errno));
+			ERROR("failed to set hostname %s: %m", want_hostname);
 			exit(EXIT_FAILURE);
 		}
 
 	// Setuid is useful even without a new user id space
 	if (start_arg->setuid && setuid(uid)) {
-		ERROR("failed to set uid %d: %s", uid, strerror(errno));
+		ERROR("failed to set uid %d: %m", uid);
 		exit(EXIT_FAILURE);
 	}
 
 	execvp(args[0], args);
 
-	ERROR("failed to exec: '%s': %s", args[0], strerror(errno));
+	ERROR("failed to exec: '%s': %m", args[0]);
 	return 1;
 }
 
@@ -263,7 +263,7 @@ int main(int argc, char *argv[])
 	if (my_iflist) {
 		for (tmpif = my_iflist; tmpif; tmpif = tmpif->mi_next) {
 			if (lxc_netdev_move_by_name(tmpif->mi_ifname, pid, NULL) < 0)
-				fprintf(stderr,"Could not move interface %s into container %d: %s\n", tmpif->mi_ifname, pid, strerror(errno));
+				fprintf(stderr,"Could not move interface %s into container %d: %m\n", tmpif->mi_ifname, pid);
 		}
 	}
 
diff --git a/src/lxc/tools/lxc_usernsexec.c b/src/lxc/tools/lxc_usernsexec.c
index 7fd2acabb..35b4ae4b4 100644
--- a/src/lxc/tools/lxc_usernsexec.c
+++ b/src/lxc/tools/lxc_usernsexec.c
@@ -82,14 +82,14 @@ static void opentty(const char * tty, int which) {
 
 	fd = open(tty, O_RDWR | O_NONBLOCK);
 	if (fd == -1) {
-		printf("WARN: could not reopen tty: %s\n", strerror(errno));
+		printf("WARN: could not reopen tty: %m\n");
 		return;
 	}
 
 	flags = fcntl(fd, F_GETFL);
 	flags &= ~O_NONBLOCK;
 	if (fcntl(fd, F_SETFL, flags) < 0) {
-		printf("WARN: could not set fd flags: %s\n", strerror(errno));
+		printf("WARN: could not set fd flags: %m\n");
 		return;
 	}
 
diff --git a/src/lxc/utils.c b/src/lxc/utils.c
index 9d88076c5..0e46c3b92 100644
--- a/src/lxc/utils.c
+++ b/src/lxc/utils.c
@@ -982,7 +982,7 @@ int lxc_read_from_file(const char *filename, void* buf, size_t count)
 	}
 
 	if (ret < 0)
-		ERROR("read %s: %s", filename, strerror(errno));
+		ERROR("read %s: %m", filename);
 
 	saved_errno = errno;
 	close(fd);
@@ -1022,7 +1022,7 @@ int randseed(bool srand_it)
 	if (f) {
 		int ret = fread(&seed, sizeof(seed), 1, f);
 		if (ret != 1)
-			DEBUG("unable to fread /dev/urandom, %s, fallback to time+pid rand seed", strerror(errno));
+			DEBUG("unable to fread /dev/urandom, %m, fallback to time+pid rand seed");
 		fclose(f);
 	}
 
@@ -1504,7 +1504,7 @@ int setproctitle(char *title)
 	if (ret == 0)
 		strcpy((char*)arg_start, title);
 	else
-		INFO("setting cmdline failed - %s", strerror(errno));
+		INFO("setting cmdline failed - %m");
 
 	return ret;
 }
diff --git a/src/tests/attach.c b/src/tests/attach.c
index af03862da..d2655f3ee 100644
--- a/src/tests/attach.c
+++ b/src/tests/attach.c
@@ -309,7 +309,7 @@ static struct lxc_container *test_ct_create(const char *lxcpath,
 	if (lxcpath) {
 		ret = mkdir(lxcpath, 0755);
 		if (ret < 0 && errno != EEXIST) {
-			TSTERR("failed to mkdir %s %s", lxcpath, strerror(errno));
+			TSTERR("failed to mkdir %s %m", lxcpath);
 			goto out1;
 		}
 	}
diff --git a/src/tests/cgpath.c b/src/tests/cgpath.c
index fb755cdf1..5a7843e82 100644
--- a/src/tests/cgpath.c
+++ b/src/tests/cgpath.c
@@ -128,7 +128,7 @@ static int test_container(const char *lxcpath,
 	if (lxcpath) {
 		ret = mkdir(lxcpath, 0755);
 		if (ret < 0 && errno != EEXIST) {
-			TSTERR("failed to mkdir %s %s", lxcpath, strerror(errno));
+			TSTERR("failed to mkdir %s %m", lxcpath);
 			goto out1;
 		}
 	}
diff --git a/src/tests/console.c b/src/tests/console.c
index 351f47ae7..e3787bb71 100644
--- a/src/tests/console.c
+++ b/src/tests/console.c
@@ -125,7 +125,7 @@ static int test_console(const char *lxcpath,
 	if (lxcpath) {
 		ret = mkdir(lxcpath, 0755);
 		if (ret < 0 && errno != EEXIST) {
-			TSTERR("failed to mkdir %s %s", lxcpath, strerror(errno));
+			TSTERR("failed to mkdir %s %m", lxcpath);
 			goto out1;
 		}
 	}
diff --git a/src/tests/lxc-test-utils.c b/src/tests/lxc-test-utils.c
index 01d8cd6eb..1fb487d21 100644
--- a/src/tests/lxc-test-utils.c
+++ b/src/tests/lxc-test-utils.c
@@ -139,7 +139,7 @@ void test_detect_ramfs_rootfs(void)
 	}
 
 	if (mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, 0) < 0) {
-		lxc_error("Failed to remount / private: %s.\n", strerror(errno));
+		lxc_error("Failed to remount / private: %m.\n");
 		goto non_test_error;
 	}
 
@@ -216,7 +216,7 @@ void test_detect_ramfs_rootfs(void)
 
 	if (init_ns > 0) {
 		if (setns(init_ns, 0) < 0) {
-			lxc_error("Failed to switch back to initial mount namespace: %s.\n", strerror(errno));
+			lxc_error("Failed to switch back to initial mount namespace: %m.\n");
 			fret = EXIT_FAILURE;
 		}
 		close(init_ns);


More information about the lxc-devel mailing list