Whamcloud - gitweb
create_inode: remove backup definition of __func__
[tools/e2fsprogs.git] / misc / e4defrag.c
index a1224bb..3f949d0 100644 (file)
@@ -387,8 +387,10 @@ static int page_in_core(int fd, struct move_extent defrag_data,
        *page_num = 0;
        *page_num = (length + pagesize - 1) / pagesize;
        *vec = (unsigned char *)calloc(*page_num, 1);
-       if (*vec == NULL)
+       if (*vec == NULL) {
+               munmap(page, length);
                return -1;
+       }
 
        /* Get information on whether pages are in core */
        if (mincore(page, (size_t)length, *vec) == -1 ||
@@ -888,7 +890,9 @@ static int get_physical_count(struct fiemap_extent_list *physical_list_head)
 
        do {
                if ((ext_list_tmp->data.physical + ext_list_tmp->data.len)
-                               != ext_list_tmp->next->data.physical) {
+                               != ext_list_tmp->next->data.physical ||
+                   (ext_list_tmp->data.logical + ext_list_tmp->data.len)
+                               != ext_list_tmp->next->data.logical) {
                        /* This extent and next extent are not continuous. */
                        ret++;
                }
@@ -1797,10 +1801,10 @@ int main(int argc, char *argv[])
                        ret = ext2fs_open(dev_name, EXT2_FLAG_64BITS, 0,
                                          block_size, unix_io_manager, &fs);
                        if (ret) {
-                               if (mode_flag & DETAIL) {
-                                       perror("Can't get super block info");
-                                       PRINT_FILE_NAME(argv[i]);
-                               }
+                               if (mode_flag & DETAIL)
+                                       com_err(argv[1], ret,
+                                               "while trying to open file system: %s",
+                                               dev_name);
                                continue;
                        }
 
@@ -1808,7 +1812,7 @@ int main(int argc, char *argv[])
                        feature_incompat = fs->super->s_feature_incompat;
                        log_groups_per_flex = fs->super->s_log_groups_per_flex;
 
-                       ext2fs_close(fs);
+                       ext2fs_close_free(&fs);
                }
 
                switch (arg_type) {