Commit 3c9290d2 authored by Pavel Begunkov's avatar Pavel Begunkov Committed by Andrei Vagin

files: Fix compilation errors

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: 's avatarPavel Begunkov <asml.silence@gmail.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent e42c7695
......@@ -1440,7 +1440,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';
......@@ -1575,7 +1576,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];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment