markfasheh / duperemove

Tools for deduping file systems
GNU General Public License v2.0
816 stars 81 forks source link

warning: ‘end...’ may be used uninitialized in this function [-Wmaybe-uninitialized] #177

Closed mawelo closed 6 years ago

mawelo commented 7 years ago

Hello, I got the following compiler warnings:

find_dupes.c:216:21: warning: ‘end[1]’ may be used uninitialized in this function [-Wmaybe-uninitialized]                                                                                      struct file_block *end[2];                                                                                                                                                                                      ^                                                                                                                                                                       find_dupes.c:216:21: warning: ‘end[0]’ may be used uninitialized in this function [-Wmaybe-uninitialized]  

used compiler version:

c++ (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I made the following changes therefor and maybe this is acceptable for you:

git diff 
diff --git a/find_dupes.c b/find_dupes.c
index 4d4dc9f..a6e3352 100644
--- a/find_dupes.c
+++ b/find_dupes.c
@@ -213,11 +213,11 @@ static int walk_dupe_block(struct filerec *orig_file,
        struct file_block *orig = orig_file_block;
        struct file_block *block = walk_file_block;
        struct file_block *start[2] = { orig, block };
-       struct file_block *end[2];
-       struct running_checksum *csum;
+       struct file_block *end[2]= { NULL, NULL };
+       struct running_checksum *csum=NULL;
        unsigned char match_id[DIGEST_LEN_MAX] = {0, };
-       uint64_t orig_blkno, walk_blkno;
-       struct rb_node *node;
+       uint64_t orig_blkno=0, walk_blkno=0;
+       struct rb_node *node=NULL;

        if (block_seen(*walk_best_off, block) ||
            block_seen(*orig_best_off, orig))

Best Regards Martin

markfasheh commented 6 years ago

Fixed in master, thanks!