[CRIU] [PATCH] files: Fix compilation errors
Pavel Begunkov
asml.silence at gmail.com
Mon Jun 19 14:18:34 MSK 2017
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
More information about the CRIU
mailing list