[CRIU] [PATCH 2/5] zdtm: sanitize pr_perror() usage

Kir Kolyshkin kir at openvz.org
Wed Oct 21 16:06:13 PDT 2015


Log function pr_perror() automatically adds
 - numeric errno value
 - string errno value (aka strerror(errno), aka %m)
 - a newline

So, its callers don't have to do all these things.

While at it, also
 - fix or improve some message texts
 - replace fnprintf() with pr_perror()

Signed-off-by: Kir Kolyshkin <kir at openvz.org>
---
 test/zdtm/lib/tcp.c                      | 12 ++++++------
 test/zdtm/live/static/file_fown.c        |  2 +-
 test/zdtm/live/static/packet_sock.c      | 20 ++++++++++----------
 test/zdtm/live/static/packet_sock_mmap.c |  6 +++---
 test/zdtm/live/static/socket_aio.c       | 10 +++++-----
 test/zdtm/live/static/socket_listen.c    |  6 +++---
 test/zdtm/live/static/unhashed_proc.c    |  6 +++---
 test/zdtm/live/static/zombie00.c         |  2 +-
 test/zdtm/live/streaming/fifo_loop.c     | 14 +++++++-------
 test/zdtm/live/streaming/file_aio.c      | 15 +++++++--------
 test/zdtm/live/streaming/netlink00.c     |  4 ++--
 test/zdtm/live/streaming/pipe_loop00.c   |  6 +++---
 test/zdtm/live/streaming/pipe_shared00.c |  6 +++---
 test/zdtm/live/streaming/socket_loop00.c |  6 +++---
 test/zdtm/live/streaming/unix_sock.c     |  2 +-
 test/zdtm/live/transition/epoll.c        | 18 +++++++++---------
 test/zdtm/live/transition/file_read.c    |  6 +++---
 17 files changed, 70 insertions(+), 71 deletions(-)

diff --git a/test/zdtm/lib/tcp.c b/test/zdtm/lib/tcp.c
index b6a3062..4fb1902 100644
--- a/test/zdtm/lib/tcp.c
+++ b/test/zdtm/lib/tcp.c
@@ -27,7 +27,7 @@ int tcp_init_server(int family, int *port)
 
 	sock = socket(family, SOCK_STREAM, IPPROTO_TCP);
 	if (sock == -1) {
-		pr_perror("socket() failed %m");
+		pr_perror("socket() failed");
 		return -1;
 	}
 
@@ -54,12 +54,12 @@ int tcp_init_server(int family, int *port)
 	}
 
 	if (ret == -1) {
-		pr_perror("bind() failed %m");
+		pr_perror("bind() failed");
 		return -1;
 	}
 
 	if (listen(sock, 1) == -1) {
-		pr_perror("listen() failed %m");
+		pr_perror("listen() failed");
 		return -1;
 	}
 	return sock;
@@ -77,7 +77,7 @@ int tcp_accept_server(int sock)
 	sock2 = accept(sock,(struct sockaddr *) &maddr, &addrlen);
 
 	if (sock2 == -1) {
-		pr_perror("accept() failed %m");
+		pr_perror("accept() failed");
 		return -1;
 	}
 
@@ -93,7 +93,7 @@ int tcp_init_client(int family, char *servIP, unsigned short servPort)
 	union sockaddr_inet servAddr;
 
 	if ((sock = socket(family, SOCK_STREAM, IPPROTO_TCP)) < 0) {
-		pr_perror("can't create socket %m");
+		pr_perror("can't create socket");
 		return -1;
 	}
 	/* Construct the server address structure */
@@ -108,7 +108,7 @@ int tcp_init_client(int family, char *servIP, unsigned short servPort)
 		inet_pton(AF_INET6, servIP, &servAddr.v6.sin6_addr);
 	}
 	if (connect(sock, (struct sockaddr *) &servAddr, sizeof(servAddr)) < 0) {
-		pr_perror("can't connect to server %m");
+		pr_perror("can't connect to server");
 		return -1;
 	}
 	return sock;
diff --git a/test/zdtm/live/static/file_fown.c b/test/zdtm/live/static/file_fown.c
index 9b71507..c0732e7 100644
--- a/test/zdtm/live/static/file_fown.c
+++ b/test/zdtm/live/static/file_fown.c
@@ -132,7 +132,7 @@ int main(int argc, char *argv[])
 
 	pid = test_fork();
 	if (pid < 0) {
-		pr_perror("can't fork %m");
+		pr_perror("can't fork");
 		exit(1);
 	}
 
diff --git a/test/zdtm/live/static/packet_sock.c b/test/zdtm/live/static/packet_sock.c
index db1e159..66175d4 100644
--- a/test/zdtm/live/static/packet_sock.c
+++ b/test/zdtm/live/static/packet_sock.c
@@ -109,7 +109,7 @@ int main(int argc, char **argv)
 	addr.sll_family = AF_PACKET;
 	addr.sll_ifindex = 1; /* loopback should be 1 in all namespaces */
 	if (bind(sk2, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
-		pr_perror("Can't bind socket %m");
+		pr_perror("Can't bind socket");
 		return 1;
 	}
 
@@ -127,13 +127,13 @@ int main(int argc, char **argv)
 
 	ver = TPACKET_V2;
 	if (setsockopt(sk1, SOL_PACKET, PACKET_VERSION, &ver, sizeof(ver)) < 0) {
-		pr_perror("Can't set version %m");
+		pr_perror("Can't set version");
 		return 1;
 	}
 
 	yes = 1;
 	if (setsockopt(sk1, SOL_PACKET, PACKET_AUXDATA, &yes, sizeof(yes)) < 0) {
-		pr_perror("Can't set auxdata %m");
+		pr_perror("Can't set auxdata");
 		return 1;
 	}
 
@@ -143,25 +143,25 @@ int main(int argc, char **argv)
 	ring.tp_frame_size = 1024;
 	ring.tp_frame_nr = (ring.tp_block_size / ring.tp_frame_size) * ring.tp_block_nr;
 	if (setsockopt(sk1, SOL_PACKET, PACKET_RX_RING, &ring, sizeof(ring)) < 0) {
-		pr_perror("Can't set rx ring %m");
+		pr_perror("Can't set rx ring");
 		return 1;
 	}
 
 	rsv = SK_RESERVE;
 	if (setsockopt(sk2, SOL_PACKET, PACKET_RESERVE, &rsv, sizeof(rsv)) < 0) {
-		pr_perror("Can't set reserve %m");
+		pr_perror("Can't set reserve");
 		return 1;
 	}
 
 	yes = 1;
 	if (setsockopt(sk2, SOL_PACKET, PACKET_ORIGDEV, &yes, sizeof(yes)) < 0) {
-		pr_perror("Can't set origdev %m");
+		pr_perror("Can't set origdev");
 		return 1;
 	}
 
 	yes = DEF_FANOUT;
 	if (setsockopt(sk2, SOL_PACKET, PACKET_FANOUT, &yes, sizeof(yes)) < 0) {
-		pr_perror("Can't configure fanout %m");
+		pr_perror("Can't configure fanout");
 		return 1;
 	}
 
@@ -169,7 +169,7 @@ int main(int argc, char **argv)
 	mreq.mr_ifindex = 1;
 	mreq.mr_type = PACKET_MR_PROMISC;
 	if (setsockopt(sk1, SOL_PACKET, PACKET_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) < 0) {
-		pr_perror("Can't add promisc member %m");
+		pr_perror("Can't add promisc member");
 		return 1;
 	}
 
@@ -178,7 +178,7 @@ int main(int argc, char **argv)
 	mreq.mr_type = PACKET_MR_UNICAST;
 	mreq.mr_alen = LO_ADDR_LEN;
 	if (setsockopt(sk2, SOL_PACKET, PACKET_ADD_MEMBERSHIP, &mreq, sizeof(mreq)) < 0) {
-		pr_perror("Can't add ucast member %m");
+		pr_perror("Can't add ucast member");
 		return 1;
 	}
 
@@ -188,7 +188,7 @@ int main(int argc, char **argv)
 	ring.tp_frame_size = 1024;
 	ring.tp_frame_nr = (ring.tp_block_size / ring.tp_frame_size) * ring.tp_block_nr;
 	if (setsockopt(sk2, SOL_PACKET, PACKET_TX_RING, &ring, sizeof(ring)) < 0) {
-		pr_perror("Can't set tx ring %m");
+		pr_perror("Can't set tx ring");
 		return 1;
 	}
 
diff --git a/test/zdtm/live/static/packet_sock_mmap.c b/test/zdtm/live/static/packet_sock_mmap.c
index b1e94ad..99b6e2f 100644
--- a/test/zdtm/live/static/packet_sock_mmap.c
+++ b/test/zdtm/live/static/packet_sock_mmap.c
@@ -74,7 +74,7 @@ int main(int argc, char **argv)
 	ring.tp_frame_size = 1024;
 	ring.tp_frame_nr = (ring.tp_block_size / ring.tp_frame_size) * ring.tp_block_nr;
 	if (setsockopt(sk, SOL_PACKET, PACKET_RX_RING, &ring, sizeof(ring)) < 0) {
-		pr_perror("Can't set rx ring %m");
+		pr_perror("Can't set rx ring");
 		return 1;
 	}
 
@@ -84,13 +84,13 @@ int main(int argc, char **argv)
 	ring.tp_frame_size = 1024;
 	ring.tp_frame_nr = (ring.tp_block_size / ring.tp_frame_size) * ring.tp_block_nr;
 	if (setsockopt(sk, SOL_PACKET, PACKET_TX_RING, &ring, sizeof(ring)) < 0) {
-		pr_perror("Can't set tx ring %m");
+		pr_perror("Can't set tx ring");
 		return 1;
 	}
 
 	mem = mmap(NULL, 2 * PAGE_SIZE, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FILE, sk, 0);
 	if (mem == MAP_FAILED) {
-		pr_perror("Can't mmap socket %m");
+		pr_perror("Can't mmap socket");
 		return 1;
 	}
 
diff --git a/test/zdtm/live/static/socket_aio.c b/test/zdtm/live/static/socket_aio.c
index 50d326e..bbad397 100644
--- a/test/zdtm/live/static/socket_aio.c
+++ b/test/zdtm/live/static/socket_aio.c
@@ -42,7 +42,7 @@ int main(int argc, char **argv)
 
 	pid = test_fork();
 	if (pid < 0) {
-		pr_perror("fork failed. Return %d %m", pid);
+		pr_perror("fork failed");
 		return 1;
 	}
 
@@ -61,7 +61,7 @@ int main(int argc, char **argv)
 		aiocb.aio_nbytes = BUF_SIZE;
 		ret = aio_read(&aiocb);
 		if (ret < 0) {
-			pr_perror("aio_read failed %m");
+			pr_perror("aio_read failed");
 			return 1;
 		}
 
@@ -74,7 +74,7 @@ int main(int argc, char **argv)
 		res = 0;
 again:
 		if (aio_suspend(aioary, 1, NULL) < 0 && errno != EINTR) {
-			pr_perror("aio_suspend failed %m");
+			pr_perror("aio_suspend failed");
 			res = 1;
 		}
 
@@ -91,7 +91,7 @@ again:
 		}
 
 		if (aio_return(&aiocb) != BUF_SIZE) {
-			pr_perror("Error at aio_return() %m");
+			pr_perror("Error at aio_return()");
 			res = 1;
 		}
 
@@ -120,7 +120,7 @@ again:
 
 
 	if (wait(&status) < 0) {
-		pr_perror("wait failed %m");
+		pr_perror("wait failed");
 		goto error;
 	}
 
diff --git a/test/zdtm/live/static/socket_listen.c b/test/zdtm/live/static/socket_listen.c
index 70e27cc..c96c9d0 100644
--- a/test/zdtm/live/static/socket_listen.c
+++ b/test/zdtm/live/static/socket_listen.c
@@ -53,11 +53,11 @@ int main(int argc, char **argv)
 
 	sigemptyset(&sa.sa_mask);
 	if (sigaction(SIGCHLD, &sa, NULL))
-		fprintf(stderr, "Can't set SIGTERM handler: %m\n");
+		pr_perror("Can't set SIGCHLD handler");
 
 	pid = test_fork();
 	if (pid < 0) {
-		pr_perror("fork failed. Return %d %m", pid);
+		pr_perror("fork failed");
 		return 1;
 	}
 
@@ -100,7 +100,7 @@ int main(int argc, char **argv)
 
 
 	if (wait(&status) < 0) {
-		pr_perror("wait failed %m");
+		pr_perror("wait failed");
 		goto error;
 	}
 
diff --git a/test/zdtm/live/static/unhashed_proc.c b/test/zdtm/live/static/unhashed_proc.c
index 30b5e75..1fdc38f 100644
--- a/test/zdtm/live/static/unhashed_proc.c
+++ b/test/zdtm/live/static/unhashed_proc.c
@@ -21,7 +21,7 @@ int main(int argc, char ** argv)
 
 	pid = fork();
 	if (pid < 0) {
-		pr_perror("Fork failed %m");
+		pr_perror("fork failed");
 		exit(1);
 	} else if (!pid) {
 		pause();
@@ -32,7 +32,7 @@ int main(int argc, char ** argv)
 
 	if (chdir(cwd1) < 0) {
 		kill(pid, SIGKILL);
-		pr_perror("Chdir failed %m");
+		pr_perror("chdir failed");
 		exit(1);
 	}
 
@@ -49,7 +49,7 @@ int main(int argc, char ** argv)
 
 	len = readlink("/proc/self/cwd", cwd1, sizeof(cwd1));
 	if (len < 0) {
-		pr_perror("can't read cwd symlink %m");
+		pr_perror("can't read cwd symlink");
 		exit(1);
 	}
 	cwd1[len] = 0;
diff --git a/test/zdtm/live/static/zombie00.c b/test/zdtm/live/static/zombie00.c
index 9a35b92..8ee9c07 100644
--- a/test/zdtm/live/static/zombie00.c
+++ b/test/zdtm/live/static/zombie00.c
@@ -41,7 +41,7 @@ int main(int argc, char ** argv)
 	for (i = 0; i < NR_ZOMBIES; i++) {
 		zombie[i].pid = fork();
 		if (zombie[i].pid < 0) {
-			pr_perror("Fork failed %m");
+			pr_perror("fork failed");
 			exit(1);
 		}
 
diff --git a/test/zdtm/live/streaming/fifo_loop.c b/test/zdtm/live/streaming/fifo_loop.c
index abba802..5b6c113 100644
--- a/test/zdtm/live/streaming/fifo_loop.c
+++ b/test/zdtm/live/streaming/fifo_loop.c
@@ -49,20 +49,20 @@ int main(int argc, char **argv)
 			exit(1);
 		}
 		if (mkfifo(file_path, mode)) {
-			pr_perror("can't make fifo \"%s\"\n", file_path);
+			pr_perror("can't make fifo \"%s\"", file_path);
 			exit(1);
 		}
 	}
 
 	if (signal(SIGCHLD, inc_num_exited) == SIG_ERR) {
-		pr_perror("can't set SIGCHLD handler\n");
+		pr_perror("can't set SIGCHLD handler");
 		exit(1);
 	}
 
 	for (i = 1; i < num_procs; i++) {	/* i = 0 - parent */
 		pid = test_fork();
 		if (pid < 0) {
-			pr_perror("Can't fork\n");
+			pr_perror("Can't fork");
 			kill(0, SIGKILL);
 			exit(1);
 		}
@@ -70,7 +70,7 @@ int main(int argc, char **argv)
 			file_path = path[i - 1];
 			readfd = open(file_path, O_RDONLY);
 			if (readfd < 0) {
-				pr_perror("open(%s, O_RDONLY) Failed\n",
+				pr_perror("open(%s, O_RDONLY) failed",
 					file_path);
 				ret = errno;
 				return ret;
@@ -78,7 +78,7 @@ int main(int argc, char **argv)
 			file_path = path[i];
 			writefd = open(file_path, O_WRONLY);
 			if (writefd < 0) {
-				pr_perror("open(%s, O_WRONLY) Failed\n",
+				pr_perror("open(%s, O_WRONLY) failed",
 					file_path);
 				ret = errno;
 				return ret;
@@ -99,7 +99,7 @@ int main(int argc, char **argv)
 	file_path = path[0];
 	writefd = open(file_path, O_WRONLY);
 	if (writefd < 0) {
-		pr_perror("open(%s, O_WRONLY) Failed\n", file_path);
+		pr_perror("open(%s, O_WRONLY) failed", file_path);
 		kill(0, SIGKILL);
 		exit(1);
 	}
@@ -107,7 +107,7 @@ int main(int argc, char **argv)
 	file_path = path[i - 1];
 	readfd = open(file_path, O_RDONLY);
 	if (readfd < 0) {
-		pr_perror("open(%s, O_RDONLY) Failed\n", file_path);
+		pr_perror("open(%s, O_RDONLY) failed", file_path);
 		kill(0, SIGKILL);
 		exit(1);
 	}
diff --git a/test/zdtm/live/streaming/file_aio.c b/test/zdtm/live/streaming/file_aio.c
index 3743776..9eae8b8 100644
--- a/test/zdtm/live/streaming/file_aio.c
+++ b/test/zdtm/live/streaming/file_aio.c
@@ -27,15 +27,14 @@ int main(int argc, char **argv)
 
 	fd = mkstemp(tmpfname);
 	if (fd == -1) {
-		pr_perror("Error at open(): %s", strerror(errno));
+		pr_perror("mkstemp() failed");
 		exit(1);
 	}
 
 	unlink(tmpfname);
 
 	if (write(fd, buf, BUF_SIZE) != BUF_SIZE) {
-		pr_perror("Error at write(): %s",
-				strerror(errno));
+		pr_perror("Error at write()");
 		exit(1);
 	}
 
@@ -52,12 +51,12 @@ int main(int argc, char **argv)
 		if (ret < 0) {
 			if ((errno == EINTR) && (!test_go()))
 				break;
-			pr_perror("aio_read failed %m");
+			pr_perror("aio_read failed");
 			return 1;
 		}
 
 		if (ret < 0) {
-			pr_perror("aio_read failed %s\n", strerror(errno));
+			pr_perror("aio_read failed");
 			exit(1);
 		}
 		/* Wait for request completion */
@@ -68,7 +67,7 @@ again:
 			if ((errno == EINTR) && (! test_go()))
 				break;
 			if (errno != EINTR) {
-				pr_perror("aio_suspend failed %m");
+				pr_perror("aio_suspend failed");
 				return 1;
 			}
 		}
@@ -89,11 +88,11 @@ again:
 		if (ret < 0) {
 			if ((errno == EINTR) && (!test_go()))
 				break;
-			pr_perror("aio_return failed %m");
+			pr_perror("aio_return failed");
 			return 1;
 		}
 		if (ret != BUF_SIZE) {
-			pr_perror("Error at aio_return()\n");
+			pr_perror("Error at aio_return()");
 			exit(1);
 		}
 	}
diff --git a/test/zdtm/live/streaming/netlink00.c b/test/zdtm/live/streaming/netlink00.c
index 479d3b5..34e627e 100644
--- a/test/zdtm/live/streaming/netlink00.c
+++ b/test/zdtm/live/streaming/netlink00.c
@@ -74,7 +74,7 @@ int main(int argc, char *argv[])
 
 	fd = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
 	if (fd<0){
-		pr_perror("socket ");
+		pr_perror("socket");
 		goto out;
 	}
 	// setup local address & bind using
@@ -83,7 +83,7 @@ int main(int argc, char *argv[])
 	la.nl_family = AF_NETLINK;
 	la.nl_pid = getpid();
 	if (bind(fd, (struct sockaddr*) &la, sizeof(la))){
-		pr_perror("bind failed ");
+		pr_perror("bind failed");
 		goto out;
 	}
 	//Preperation:
diff --git a/test/zdtm/live/streaming/pipe_loop00.c b/test/zdtm/live/streaming/pipe_loop00.c
index d42b928..0f9bd2a 100644
--- a/test/zdtm/live/streaming/pipe_loop00.c
+++ b/test/zdtm/live/streaming/pipe_loop00.c
@@ -44,19 +44,19 @@ int main(int argc, char **argv)
 
 	for (i = 0; i < num_procs; i++)
 		if (pipe(pipes + i * 2)) {
-			pr_perror("Can't create pipes\n");
+			pr_perror("Can't create pipes");
 			exit(1);
 		}
 
 	if (signal(SIGCHLD, inc_num_exited) == SIG_ERR) {
-		pr_perror("can't set SIGCHLD handler\n");
+		pr_perror("can't set SIGCHLD handler");
 		exit(1);
 	}
 
 	for (i = 1; i < num_procs; i++) {	/* i = 0 - parent */
 		pid = test_fork();
 		if (pid < 0) {
-			pr_perror("Can't fork\n");
+			pr_perror("Can't fork");
 			kill(0, SIGKILL);
 			exit(1);
 		}
diff --git a/test/zdtm/live/streaming/pipe_shared00.c b/test/zdtm/live/streaming/pipe_shared00.c
index a28b1e5..44856ea 100644
--- a/test/zdtm/live/streaming/pipe_shared00.c
+++ b/test/zdtm/live/streaming/pipe_shared00.c
@@ -44,19 +44,19 @@ int main(int argc, char **argv)
 	}
 
 	if (pipe(pipes)) {
-		pr_perror("Can't create pipes\n");
+		pr_perror("Can't create pipes");
 		exit(1);
 	}
 
 	if (signal(SIGCHLD, inc_num_exited) == SIG_ERR) {
-		pr_perror("can't set SIGCHLD handler\n");
+		pr_perror("can't set SIGCHLD handler");
 		exit(1);
 	}
 
 	for (i = 1; i < num_procs; i++) {	/* i = 0 - parent */
 		pid = test_fork();
 		if (pid < 0) {
-			pr_perror("Can't fork\n");
+			pr_perror("can't fork");
 			kill(0, SIGKILL);
 			exit(1);
 		}
diff --git a/test/zdtm/live/streaming/socket_loop00.c b/test/zdtm/live/streaming/socket_loop00.c
index e20e234..2a6a6a8 100644
--- a/test/zdtm/live/streaming/socket_loop00.c
+++ b/test/zdtm/live/streaming/socket_loop00.c
@@ -45,19 +45,19 @@ int main(int argc, char **argv)
 
 	for (i = 0; i < num_procs; i++)
 		if (socketpair(AF_LOCAL, SOCK_STREAM, 0, socks + i * 2)) {
-			pr_perror("Can't create socks\n");
+			pr_perror("can't create sockets");
 			exit(1);
 		}
 
 	if (signal(SIGCHLD, inc_num_exited) == SIG_ERR) {
-		pr_perror("can't set SIGCHLD handler\n");
+		pr_perror("can't set SIGCHLD handler");
 		exit(1);
 	}
 
 	for (i = 1; i < num_procs; i++) {	/* i = 0 - parent */
 		pid = test_fork();
 		if (pid < 0) {
-			pr_perror("Can't fork\n");
+			pr_perror("Can't fork");
 			kill(0, SIGKILL);
 			exit(1);
 		}
diff --git a/test/zdtm/live/streaming/unix_sock.c b/test/zdtm/live/streaming/unix_sock.c
index 798da77..3d1c8c4 100644
--- a/test/zdtm/live/streaming/unix_sock.c
+++ b/test/zdtm/live/streaming/unix_sock.c
@@ -65,7 +65,7 @@ static int setup_srv_sock(void)
 	}
 
 	if (listen(sock, 1) < 0) {
-		pr_perror("can't listen on a socket \"%s\"\n", filename);
+		pr_perror("can't listen on a socket \"%s\"", filename);
 		goto err;
 	}
 
diff --git a/test/zdtm/live/transition/epoll.c b/test/zdtm/live/transition/epoll.c
index 5fd0628..b4c02b9 100644
--- a/test/zdtm/live/transition/epoll.c
+++ b/test/zdtm/live/transition/epoll.c
@@ -111,35 +111,35 @@ int main(int argc, char **argv)
 	}
 
 	if (signal(SIGUSR2, do_stop) == SIG_ERR) {
-		pr_perror("Can't setup handler\n");
+		pr_perror("Can't setup signal handler");
 		exit(1);
 	}
 
 	if ((efd = epoll_create(scale)) < 0) {
-		pr_perror("Can't create epoll\n");
+		pr_perror("Can't create epoll");
 		exit(1);
 	}
 
 	for (i = 0; i < scale; i++) {
 		if (pipe(fds[i]) < 0) {
-			pr_perror("Can't create pipe[%d]\n", i);
+			pr_perror("Can't create pipe[%d]", i);
 			killall();
 			exit(1);
 		}
 		if (fcntl(fds[i][0], F_SETFL, O_NONBLOCK) < 0) {
-			pr_perror("Can't set O_NONBLOCK flag on fd[%d]\n", i);
+			pr_perror("Can't set O_NONBLOCK flag on fd[%d]", i);
 			killall();
 			exit(1);
 		}
 		event.data.fd = fds[i][0];
 		if (epoll_ctl(efd, EPOLL_CTL_ADD, fds[i][0], &event) < 0) {
-			pr_perror("Can't add fd[%d]\n", i);
+			pr_perror("Can't add fd[%d]", i);
 			killall();
 			exit(1);
 		}
 
 		if ((rv = test_fork()) < 0) {
-			pr_perror("Can't fork[%d]\n", i);
+			pr_perror("Can't fork[%d]", i);
 			killall();
 			exit(1);
 		}
@@ -150,7 +150,7 @@ int main(int argc, char **argv)
 	}
 
 	if ((events = (struct epoll_event*) malloc (sizeof(struct epoll_event)*scale)) == NULL) {
-		pr_perror("Can't allocate memory\n");
+		pr_perror("Can't allocate memory");
 		killall();
 		exit(1);
 	}
@@ -159,14 +159,14 @@ int main(int argc, char **argv)
 
 	while (test_go()) {
 		if ((rv = epoll_wait(efd, events, scale, rand() % 999)) < 0 && errno != EINTR) {
-			pr_perror("epoll_wait error\n");
+			pr_perror("epoll_wait error");
 			killall();
 			exit(1);
 		}
 		for (i = 0; i < rv; i++) {
 			while (read(events[i].data.fd, buf, buf_size) > 0);
 			if (errno != EAGAIN && errno != 0 && errno) {
-				pr_perror("read error\n");
+				pr_perror("read error");
 				killall();
 				exit(1);
 			}
diff --git a/test/zdtm/live/transition/file_read.c b/test/zdtm/live/transition/file_read.c
index f7e6757..3f9d1e1 100644
--- a/test/zdtm/live/transition/file_read.c
+++ b/test/zdtm/live/transition/file_read.c
@@ -165,7 +165,7 @@ static void chew_some_file(int num)
 			sprintf(str, "standard_%s.%d", filename, num);
 			fd1 = open(str, O_WRONLY | O_CREAT | O_TRUNC, 0666);
 			if (write(fd1, buf, FILE_SIZE) != FILE_SIZE)
-				pr_perror("can't write %s\n", str);
+				pr_perror("can't write %s", str);
 			close(fd1);
 			goto out_exit;
 		}
@@ -192,14 +192,14 @@ int main(int argc, char **argv)
 	}
 
 	if (signal(SIGUSR2, do_stop) == SIG_ERR) {
-		pr_perror("Can't setup handler\n");
+		pr_perror("Can't setup signal handler");
 		exit(-1);
 	}
 
 	for (i = 0; i < scale; i++) {
 		rv = test_fork();
 		if (rv == -1) {
-			pr_perror("Can't fork\n");
+			pr_perror("Can't fork");
 			killall();
 			exit(-1);
 		}
-- 
2.4.3



More information about the CRIU mailing list