[CRIU] [PATCH] files: Fix compilation errors

Andrei Vagin avagin at virtuozzo.com
Wed Jun 28 02:19:22 MSK 2017


Applied, thanks!

On Mon, Jun 19, 2017 at 02:18:34PM +0300, Pavel Begunkov wrote:
> 1: Signed underflow
> criu/files-reg.c: In function ‘open_path’:
> criu/files-reg.c:1299:14: error: iteration 2147483647
> invokes undefined behavior [-Werror=aggressive-loop-optimizations]
>   while (count--) {
>          ~~~~~^~
> 
> 2: Uninitialized variable
> criu/files-reg.c: In function ‘make_parent_dirs_if_need’:
> criu/files-reg.c:1354:13: warning: ‘count’ may be used uninitialized in
>   this function [-Wmaybe-uninitialized]
> 
> P.S. arch linux 4.7.5-1. gcc (GCC) 6.3.1 20170109
> 
> Signed-off-by: Pavel Begunkov <asml.silence at gmail.com>
> ---
>  criu/files-reg.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/criu/files-reg.c b/criu/files-reg.c
> index 7c81d182..dfc3f29a 100644
> --- a/criu/files-reg.c
> +++ b/criu/files-reg.c
> @@ -1296,7 +1296,8 @@ static void rm_parent_dirs(int mntns_root, char *path, int count)
>  	if (!count)
>  		return;
>  
> -	while (count--) {
> +	while (count > 0) {
> +		count -= 1;
>  		p = strrchr(path, '/');
>  		if (p)
>  			*p = '\0';
> @@ -1431,7 +1432,7 @@ out_root:
>  int open_path(struct file_desc *d,
>  		int(*open_cb)(int mntns_root, struct reg_file_info *, void *), void *arg)
>  {
> -	int tmp, mntns_root, level;
> +	int tmp, mntns_root, level = 0;
>  	struct reg_file_info *rfi;
>  	char *orig_path = NULL;
>  	char path[PATH_MAX];
> -- 
> 2.11.1
> 
> _______________________________________________
> CRIU mailing list
> CRIU at openvz.org
> https://lists.openvz.org/mailman/listinfo/criu


More information about the CRIU mailing list