Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/checkpoint-restore/criu.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/compel
diff options
context:
space:
mode:
authorRadostin Stoyanov <rstoyanov@fedoraproject.org>2021-01-12 11:49:02 +0300
committerAndrei Vagin <avagin@gmail.com>2021-09-03 20:31:00 +0300
commit5364ca3da42579dbf1b1449c243a2c7243f7b765 (patch)
tree822e11f2076819de461ea26edff22259f8e7db95 /compel
parent8aba7ae9fa5f3d563500d2f76ecde16b02981b17 (diff)
compel/test: Fix warn_unused_result
gcc -O2 -g -Wall -Werror -I ../../../compel/include/uapi -o spy spy.c ../../../compel/libcompel.a spy.c: In function ‘check_pipe_ends’: spy.c:107:2: error: ignoring return value of ‘write’, declared with attribute warn_unused_result [-Werror=unused-result] 107 | write(wfd, "1", 2); | ^~~~~~~~~~~~~~~~~~ spy.c:108:2: error: ignoring return value of ‘read’, declared with attribute warn_unused_result [-Werror=unused-result] 108 | read(rfd, aux, sizeof(aux)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
Diffstat (limited to 'compel')
-rw-r--r--compel/test/fdspy/spy.c10
-rw-r--r--compel/test/rsys/spy.c14
-rw-r--r--compel/test/rsys/victim.c3
3 files changed, 21 insertions, 6 deletions
diff --git a/compel/test/fdspy/spy.c b/compel/test/fdspy/spy.c
index c6558f079..bbb9eb418 100644
--- a/compel/test/fdspy/spy.c
+++ b/compel/test/fdspy/spy.c
@@ -104,8 +104,14 @@ 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) {
+ fprintf(stderr, "write to pipe failed\n");
+ return -1;
+ }
+ if (read(rfd, aux, sizeof(aux)) != sizeof(aux)) {
+ fprintf(stderr, "read from pipe failed\n");
+ 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 6ccb2a502..dd89005f1 100644
--- a/compel/test/rsys/spy.c
+++ b/compel/test/rsys/spy.c
@@ -64,7 +64,9 @@ static inline int chk(int fd, int val)
{
int v = 0;
- read(fd, &v, sizeof(v));
+ if (read(fd, &v, sizeof(v)) != sizeof(v)) {
+ fprintf(stderr, "read failed\n");
+ }
printf("%d, want %d\n", v, val);
return v == val;
}
@@ -97,7 +99,10 @@ 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)) {
+ fprintf(stderr, "write to pipe failed\n");
+ return -1;
+ }
printf("Checking the victim session to be %d\n", sid);
pass = chk(p_out[0], sid);
@@ -115,7 +120,10 @@ 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)) {
+ fprintf(stderr, "write to pipe failed\n");
+ 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 2f1943d0c..85cb7cb89 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))
+ break;
}
return 0;