[CRIU] [PATCH 3/7] test/zdtm: Move assignment after return value check

Dmitry Safonov 0x7f454c46 at gmail.com
Mon Apr 29 17:50:17 MSK 2019


On Sun, 28 Apr 2019 at 19:45, Rikard Falkeborn
<rikard.falkeborn at gmail.com> wrote:
>
> 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>

Reviewed-by: Dmitry Safonov <0x7f454c46 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
>
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu



-- 
             Dmitry


More information about the CRIU mailing list