[CRIU] [PATCH 8/9] uffd.c: error logging nitpicks

Kir Kolyshkin kir at openvz.org
Mon Nov 7 13:37:52 PST 2016


In cases errno is being set, we need to use pr_perror() to print it.

In cases errno is not set, we should use pr_err().

pr_perror() doesn't need a colon or a newline. pr_err() needs a newline.

Cc: Adrian Reber <areber at redhat.com>
Cc: Mike Rapoport <rppt at linux.vnet.ibm.com>
Signed-off-by: Kir Kolyshkin <kir at openvz.org>
---
 criu/uffd.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/criu/uffd.c b/criu/uffd.c
index 2dea090..9b5cb08 100644
--- a/criu/uffd.c
+++ b/criu/uffd.c
@@ -158,7 +158,7 @@ static int send_uffd(int sendfd, int pid)
 	 * the FD for UFFD */
 	pr_debug("Sending PID %d\n", pid);
 	if (send(fd, &pid, sizeof(pid), 0) < 0) {
-		pr_perror("PID sending error:");
+		pr_perror("PID sending error");
 		goto out;
 	}
 
@@ -169,7 +169,7 @@ static int send_uffd(int sendfd, int pid)
 	}
 
 	if (send_fd(fd, NULL, 0, sendfd) < 0) {
-		pr_perror("send_fd error:");
+		pr_err("send_fd error\n");
 		goto out;
 	}
 
@@ -336,7 +336,10 @@ static int ud_open(int client, struct lazy_pages_info **_lpi)
 	 * the FD for UFFD */
 	ret = recv(client, &lpi->pid, sizeof(lpi->pid), 0);
 	if (ret != sizeof(lpi->pid)) {
-		pr_perror("PID recv error:");
+		if (ret < 0)
+			pr_perror("PID recv error");
+		else
+			pr_err("PID recv: short read\n");
 		goto out;
 	}
 	pr_debug("received PID: %d\n", lpi->pid);
@@ -348,7 +351,7 @@ static int ud_open(int client, struct lazy_pages_info **_lpi)
 
 	lpi->uffd = recv_fd(client);
 	if (lpi->uffd < 0) {
-		pr_perror("recv_fd error:");
+		pr_err("recv_fd error");
 		goto out;
 	}
 	pr_debug("lpi->uffd %d\n", lpi->uffd);
@@ -690,7 +693,10 @@ static int handle_user_fault(struct lazy_pages_info *lpi, void *dest)
 		return 1;
 
 	if (ret != sizeof(msg)) {
-		pr_perror("Can't read userfaultfd message");
+		if (ret < 0)
+			pr_perror("Can't read userfaultfd message");
+		else
+			pr_err("Can't read userfaultfd message: short read");
 		return -1;
 	}
 
@@ -871,7 +877,7 @@ static int prepare_uffds(int epollfd)
 	/* accept new client request */
 	len = sizeof(struct sockaddr_un);
 	if ((client = accept(listen, (struct sockaddr *) &saddr, &len)) < 0) {
-		pr_perror("server_accept error: %d", client);
+		pr_perror("server_accept error");
 		close(listen);
 		return -1;
 	}
-- 
2.7.4



More information about the CRIU mailing list