Whamcloud - gitweb
Fix gcc -Wall issues in e2fsck sources
[tools/e2fsprogs.git] / e2fsck / swapfs.c
index 8e9a134..fb7270c 100644 (file)
@@ -110,9 +110,10 @@ static void swap_inode_blocks(e2fsck_t ctx, ext2_ino_t ino, char *block_buf,
 static void swap_inodes(e2fsck_t ctx)
 {
        ext2_filsys fs = ctx->fs;
-       int                     i, group;
+       dgrp_t                  group;
+       unsigned int            i;
        ext2_ino_t              ino = 1;
-       char                    *buf, *block_buf;
+       char                    *buf = NULL, *block_buf = NULL;
        errcode_t               retval;
        struct ext2_inode *     inode;
 
@@ -124,7 +125,7 @@ static void swap_inodes(e2fsck_t ctx)
                com_err("swap_inodes", retval,
                        _("while allocating inode buffer"));
                ctx->flags |= E2F_FLAG_ABORT;
-               return;
+               goto errout;
        }
        block_buf = (char *) e2fsck_allocate_memory(ctx, fs->blocksize * 4,
                                                    "block interate buffer");
@@ -137,7 +138,7 @@ static void swap_inodes(e2fsck_t ctx)
                                _("while reading inode table (group %d)"),
                                group);
                        ctx->flags |= E2F_FLAG_ABORT;
-                       return;
+                       goto errout;
                }
                inode = (struct ext2_inode *) buf;
                for (i=0; i < fs->super->s_inodes_per_group;
@@ -162,7 +163,7 @@ static void swap_inodes(e2fsck_t ctx)
                                swap_inode_blocks(ctx, ino, block_buf, inode);
 
                        if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
-                               return;
+                               goto errout;
                        
                        if (fs->flags & EXT2_FLAG_SWAP_BYTES_WRITE)
                                ext2fs_swap_inode(fs, inode, inode, 1);
@@ -175,12 +176,16 @@ static void swap_inodes(e2fsck_t ctx)
                                _("while writing inode table (group %d)"),
                                group);
                        ctx->flags |= E2F_FLAG_ABORT;
-                       return;
+                       goto errout;
                }
        }
-       ext2fs_free_mem(&buf);
-       ext2fs_free_mem(&block_buf);
+errout:
+       if (buf)
+               ext2fs_free_mem(&buf);
+       if (block_buf)
+               ext2fs_free_mem(&block_buf);
        e2fsck_use_inode_shortcuts(ctx, 0);
+       ext2fs_flush_icache(fs);
 }
 
 #if defined(__powerpc__) && defined(EXT2FS_ENABLE_SWAPFS)