[CRIU] [PATCH 2/2] compel/test: compilation fixes

Kir Kolyshkin kolyshkin at gmail.com
Sat Sep 30 10:47:42 MSK 2017


Signed-off-by: Kir Kolyshkin <kolyshkin at gmail.com>
---
 compel/test/fdspy/spy.c   |  6 ++++--
 compel/test/rsys/spy.c    | 11 +++++++----
 compel/test/rsys/victim.c |  3 ++-
 3 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/compel/test/fdspy/spy.c b/compel/test/fdspy/spy.c
index 258e3ab7..2fc0079f 100644
--- a/compel/test/fdspy/spy.c
+++ b/compel/test/fdspy/spy.c
@@ -101,8 +101,10 @@ static int check_pipe_ends(int wfd, int rfd)
 	}
 
 	printf("Check pipe ends are connected\n");
-	write(wfd, "1", 2);
-	read(rfd, aux, sizeof(aux));
+	if (write(wfd, "1", 2) != 2)
+		return 1;
+	if (read(rfd, aux, sizeof(aux)) != sizeof(aux))
+		return 1;
 	if (aux[0] != '1' || aux[1] != '\0') {
 		fprintf(stderr, "Pipe connectivity lost\n");
 		return 0;
diff --git a/compel/test/rsys/spy.c b/compel/test/rsys/spy.c
index f5c999d5..040c74c7 100644
--- a/compel/test/rsys/spy.c
+++ b/compel/test/rsys/spy.c
@@ -63,7 +63,8 @@ static inline int chk(int fd, int val)
 {
 	int v = 0;
 
-	read(fd, &v, sizeof(v));
+	if (read(fd, &v, sizeof(v)) != sizeof(v))
+		return -1;
 	printf("%d, want %d\n", v, val);
 	return v == val;
 }
@@ -77,7 +78,7 @@ int main(int argc, char **argv)
 	 */
 	if (pipe(p_in) || pipe(p_out) || pipe(p_err)) {
 		perror("Can't make pipe");
-		return -1;
+		return 1;
 	}
 
 	pid = vfork();
@@ -96,7 +97,8 @@ int main(int argc, char **argv)
 	 * Kick the victim once
 	 */
 	i = 0;
-	write(p_in[1], &i, sizeof(i));
+	if (write(p_in[1], &i, sizeof(i)) != sizeof(i))
+		return 1;
 
 	printf("Checking the victim session to be %d\n", sid);
 	pass = chk(p_out[0], sid);
@@ -114,7 +116,8 @@ int main(int argc, char **argv)
 	/*
 	 * Kick the victim again so it tells new session
 	 */
-	write(p_in[1], &i, sizeof(i));
+	if (write(p_in[1], &i, sizeof(i)) != sizeof(i))
+		return 1;
 
 	/*
 	 * Stop the victim and check the intrusion went well
diff --git a/compel/test/rsys/victim.c b/compel/test/rsys/victim.c
index 2f1943d0..fa6f1667 100644
--- a/compel/test/rsys/victim.c
+++ b/compel/test/rsys/victim.c
@@ -9,7 +9,8 @@ int main(int argc, char **argv)
 			break;
 
 		i = getsid(0);
-		write(1, &i, sizeof(i));
+		if (write(1, &i, sizeof(i)) != sizeof(i))
+			return 1;
 	}
 
 	return 0;
-- 
2.14.1



More information about the CRIU mailing list