btrfs-progs: convert: move struct initialization to the init function
authorDavid Sterba <dsterba@suse.com>
Mon, 30 Jan 2017 12:41:36 +0000 (13:41 +0100)
committerDavid Sterba <dsterba@suse.com>
Wed, 8 Mar 2017 12:00:46 +0000 (13:00 +0100)
The context is zeroed in convert_open_fs after and overwrites the rbtree
initialization, which accidentally is the same (NULL).

Signed-off-by: David Sterba <dsterba@suse.com>
convert/main.c
convert/source-fs.c

index 5a2da31..b0d72d3 100644 (file)
@@ -1159,8 +1159,6 @@ static int convert_open_fs(const char *devname,
 {
        int i;
 
-       memset(cctx, 0, sizeof(*cctx));
-
        for (i = 0; i < ARRAY_SIZE(convert_operations); i++) {
                int ret = convert_operations[i]->open_fs(cctx, devname);
 
index f295277..e87b861 100644 (file)
@@ -40,6 +40,8 @@ static int intersect_with_sb(u64 bytenr, u64 num_bytes)
 
 void init_convert_context(struct btrfs_convert_context *cctx)
 {
+       memset(cctx, 0, sizeof(*cctx));
+
        cache_tree_init(&cctx->used);
        cache_tree_init(&cctx->data_chunks);
        cache_tree_init(&cctx->free);