[CRIU] [PATCH 9/9] parse_pid_stat(): minor optimization

Andrew Vagin avagin at odin.com
Wed Oct 7 04:32:04 PDT 2015


On Wed, Oct 07, 2015 at 02:44:24AM -0700, Kir Kolyshkin wrote:
> Signed-off-by: Kir Kolyshkin <kir at openvz.org>
> ---
>  proc_parse.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/proc_parse.c b/proc_parse.c
> index 3910590..965c7cb 100644
> --- a/proc_parse.c
> +++ b/proc_parse.c
> @@ -622,12 +622,11 @@ int parse_pid_stat(pid_t pid, struct proc_pid_stat *s)
>  		return -1;
>  
>  	n = read(fd, buf, BUF_SIZE);
> +	close(fd);

close overwrites errno

>  	if (n < 1) {
>  		pr_err("stat for %d is corrupted\n", pid);

We need to use pr_perror here

> -		close(fd);
>  		return -1;
>  	}
> -	close(fd);
>  
>  	memset(s, 0, sizeof(*s));
>  
> -- 
> 2.4.3
> 
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu


More information about the CRIU mailing list