[CRIU] [PATCH 3/7] test/zdtm: Move assignment after return value check
Rikard Falkeborn
rikard.falkeborn at gmail.com
Sun Apr 28 21:22:51 MSK 2019
If read() fails we can not use the return value as index. Move the use
of it to after the error check to avoid this.
Signed-off-by: Rikard Falkeborn <rikard.falkeborn at gmail.com>
---
test/zdtm/lib/ns.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/zdtm/lib/ns.c b/test/zdtm/lib/ns.c
index 6b4a7539..3099f749 100644
--- a/test/zdtm/lib/ns.c
+++ b/test/zdtm/lib/ns.c
@@ -325,11 +325,11 @@ int ns_init(int argc, char **argv)
exit(1);
}
ret = read(fd, buf, sizeof(buf) - 1);
- buf[ret] = '\0';
if (ret == -1) {
fprintf(stderr, "read() failed: %m\n");
exit(1);
}
+ buf[ret] = '\0';
pid = atoi(buf);
fprintf(stderr, "kill(%d, SIGTERM)\n", pid);
--
2.21.0
More information about the CRIU
mailing list