[lxc-devel] [PATCH 7/7] coverity: Check return value from open

Serge Hallyn serge.hallyn at ubuntu.com
Wed Feb 12 22:07:10 UTC 2014


Quoting Stéphane Graber (stgraber at ubuntu.com):
> Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>

Acked-by: Serge E. Hallyn <serge.hallyn at ubuntu.com>

> ---
>  src/tests/concurrent.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/src/tests/concurrent.c b/src/tests/concurrent.c
> index bcb5f2c..6d89990 100644
> --- a/src/tests/concurrent.c
> +++ b/src/tests/concurrent.c
> @@ -190,6 +190,11 @@ int main(int argc, char *argv[]) {
>      for (iter = 1; iter <= iterations; iter++) {
>          int fd;
>          fd = open("/", O_RDONLY);
> +        if (fd < 0) {
> +            fprintf(stderr, "Failed to open /\n");
> +            continue;
> +        }
> +
>          if (!quiet)
>              printf("\nIteration %d/%d maxfd:%d\n", iter, iterations, fd);
>          close(fd);
> -- 
> 1.9.rc1
> 
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel


More information about the lxc-devel mailing list