Cleanup various build warnings (signed vs unsigned, unused vars,...)
authorJP Abgrall <jpa@google.com>
Wed, 14 May 2014 00:02:55 +0000 (17:02 -0700)
committerJaegeuk Kim <jaegeuk.kim@samsung.com>
Wed, 14 May 2014 23:40:55 +0000 (08:40 +0900)
* removed unused includes.
* removed unused parameters.
* Fixed a bunch of warnings around:
    int i;
    if (i < some_uint) ...
  and
    u32 x;
    ...
    if (x < 0) return error;
* Protect BLKDISCARD usage if it is not available.

Change-Id: Iede035b1beb2df01c961589a69aff47a5258ecd2
Signed-off-by: JP Abgrall <jpa@google.com>
Signed-off-by: Jaegeuk Kim <jaegeuk.kim@samsung.com>
12 files changed:
fsck/fsck.c
fsck/fsck.h
fsck/main.c
fsck/mount.c
include/f2fs_fs.h
include/list.h
lib/libf2fs.c
lib/libf2fs_io.c
mkfs/f2fs_format.c
mkfs/f2fs_format_main.c
mkfs/f2fs_format_utils.c
tools/fibmap.c

index 20582c9..6e04ffa 100644 (file)
@@ -11,7 +11,7 @@
 #include "fsck.h"
 
 char *tree_mark;
-int tree_mark_size = 256;
+uint32_t tree_mark_size = 256;
 
 static int add_into_hard_link_list(struct f2fs_sb_info *sbi, u32 nid, u32 link_cnt)
 {
@@ -238,7 +238,6 @@ int fsck_chk_node_blk(struct f2fs_sb_info *sbi,
                case TYPE_INDIRECT_NODE:
                        ret = fsck_chk_idnode_blk(sbi,
                                        inode,
-                                       nid,
                                        ftype,
                                        node_blk,
                                        blk_cnt);
@@ -246,7 +245,6 @@ int fsck_chk_node_blk(struct f2fs_sb_info *sbi,
                case TYPE_DOUBLE_INDIRECT_NODE:
                        ret = fsck_chk_didnode_blk(sbi,
                                        inode,
-                                       nid,
                                        ftype,
                                        node_blk,
                                        blk_cnt);
@@ -273,7 +271,7 @@ int fsck_chk_inode_blk(struct f2fs_sb_info *sbi,
        enum NODE_TYPE ntype;
        u32 i_links = le32_to_cpu(node_blk->i.i_links);
        u64 i_blocks = le64_to_cpu(node_blk->i.i_blocks);
-       int idx = 0;
+       unsigned int idx = 0;
        int ret = 0;
 
        ASSERT(node_blk->footer.nid == node_blk->footer.ino);
@@ -340,7 +338,6 @@ int fsck_chk_inode_blk(struct f2fs_sb_info *sbi,
                if (le32_to_cpu(node_blk->i.i_addr[idx]) != 0) {
                        *blk_cnt = *blk_cnt + 1;
                        ret = fsck_chk_data_blk(sbi,
-                                       &node_blk->i,
                                        le32_to_cpu(node_blk->i.i_addr[idx]),
                                        &child_cnt,
                                        &child_files,
@@ -414,7 +411,6 @@ int fsck_chk_dnode_blk(struct f2fs_sb_info *sbi,
                        continue;
                *blk_cnt = *blk_cnt + 1;
                fsck_chk_data_blk(sbi,
-                               inode,
                                le32_to_cpu(node_blk->dn.addr[idx]),
                                &child_cnt,
                                &child_files,
@@ -430,7 +426,6 @@ int fsck_chk_dnode_blk(struct f2fs_sb_info *sbi,
 
 int fsck_chk_idnode_blk(struct f2fs_sb_info *sbi,
                struct f2fs_inode *inode,
-               u32 nid,
                enum FILE_TYPE ftype,
                struct f2fs_node *node_blk,
                u32 *blk_cnt)
@@ -454,7 +449,6 @@ int fsck_chk_idnode_blk(struct f2fs_sb_info *sbi,
 
 int fsck_chk_didnode_blk(struct f2fs_sb_info *sbi,
                struct f2fs_inode *inode,
-               u32 nid,
                enum FILE_TYPE ftype,
                struct f2fs_node *node_blk,
                u32 *blk_cnt)
@@ -482,7 +476,7 @@ static void print_dentry(__u32 depth, __u8 *name,
        int last_de = 0;
        int next_idx = 0;
        int name_len;
-       int i;
+       unsigned int i;
        int bit_offset;
 
        if (config.dbg_lv != -1)
@@ -516,7 +510,6 @@ static void print_dentry(__u32 depth, __u8 *name,
 }
 
 int fsck_chk_dentry_blk(struct f2fs_sb_info *sbi,
-               struct f2fs_inode *inode,
                u32 blk_addr,
                u32 *child_cnt,
                u32 *child_files,
@@ -600,7 +593,6 @@ int fsck_chk_dentry_blk(struct f2fs_sb_info *sbi,
 }
 
 int fsck_chk_data_blk(struct f2fs_sb_info *sbi,
-               struct f2fs_inode *inode,
                u32 blk_addr,
                u32 *child_cnt,
                u32 *child_files,
@@ -636,7 +628,6 @@ int fsck_chk_data_blk(struct f2fs_sb_info *sbi,
 
        if (ftype == F2FS_FT_DIR) {
                fsck_chk_dentry_blk(sbi,
-                               inode,
                                blk_addr,
                                child_cnt,
                                child_files,
@@ -743,7 +734,7 @@ int fsck_init(struct f2fs_sb_info *sbi)
 
 int fsck_verify(struct f2fs_sb_info *sbi)
 {
-       int i = 0;
+       unsigned int i = 0;
        int ret = 0;
        u32 nr_unref_nid = 0;
        struct f2fs_fsck *fsck = F2FS_FSCK(sbi);
index 8c98c93..e5a3841 100644 (file)
@@ -103,20 +103,17 @@ extern int fsck_chk_dnode_blk(struct f2fs_sb_info *sbi,
 
 extern int fsck_chk_idnode_blk(struct f2fs_sb_info *sbi,
                struct f2fs_inode *inode,
-               u32 nid,
                enum FILE_TYPE ftype,
                struct f2fs_node *node_blk,
                u32 *blk_cnt);
 
 extern int fsck_chk_didnode_blk(struct f2fs_sb_info *sbi,
                struct f2fs_inode *inode,
-               u32 nid,
                enum FILE_TYPE ftype,
                struct f2fs_node *node_blk,
                u32 *blk_cnt);
 
 extern int fsck_chk_data_blk(struct f2fs_sb_info *sbi,
-               struct f2fs_inode *inode,
                u32 blk_addr,
                u32 *child_cnt,
                u32 *child_files,
@@ -127,7 +124,6 @@ extern int fsck_chk_data_blk(struct f2fs_sb_info *sbi,
                u8 ver);
 
 extern int fsck_chk_dentry_blk(struct f2fs_sb_info *sbi,
-               struct f2fs_inode *inode,
                u32 blk_addr,
                u32 *child_cnt,
                u32 *child_files,
@@ -154,7 +150,7 @@ struct dump_option {
        int end_sit;
        int start_ssa;
        int end_ssa;
-       u32 blk_addr;
+       int32_t blk_addr;
 };
 
 extern void sit_dump(struct f2fs_sb_info *sbi, int start_sit, int end_sit);
index a0144fc..5aa3956 100644 (file)
@@ -12,7 +12,7 @@
 #include <libgen.h>
 
 struct f2fs_fsck gfsck = {
-       .sbi.fsck = &gfsck,
+       .sbi = { .fsck = &gfsck, },
 };
 
 void fsck_usage()
index e2f3ace..383a8ac 100644 (file)
@@ -12,7 +12,7 @@
 
 void print_inode_info(struct f2fs_inode *inode)
 {
-       int i = 0;
+       unsigned int i = 0;
        int namelen = le32_to_cpu(inode->i_namelen);
 
        DISP_u32(inode, i_mode);
@@ -470,7 +470,7 @@ int build_sit_info(struct f2fs_sb_info *sbi)
        return 0;
 }
 
-void reset_curseg(struct f2fs_sb_info *sbi, int type, int modified)
+void reset_curseg(struct f2fs_sb_info *sbi, int type)
 {
        struct curseg_info *curseg = CURSEG_I(sbi, type);
 
@@ -509,7 +509,7 @@ int read_compacted_summaries(struct f2fs_sb_info *sbi)
                segno = le32_to_cpu(ckpt->cur_data_segno[i]);
                blk_off = le16_to_cpu(ckpt->cur_data_blkoff[i]);
                curseg->next_segno = segno;
-               reset_curseg(sbi, i, 0);
+               reset_curseg(sbi, i);
                curseg->alloc_type = ckpt->alloc_type[i];
                curseg->next_blkoff = blk_off;
 
@@ -540,7 +540,7 @@ int restore_node_summary(struct f2fs_sb_info *sbi,
        struct f2fs_summary *sum_entry;
        void *page;
        block_t addr;
-       int i;
+       unsigned int i;
 
        page = malloc(PAGE_SIZE);
        if (!page)
@@ -602,7 +602,7 @@ int read_normal_summaries(struct f2fs_sb_info *sbi, int type)
        if (IS_NODESEG(type)) {
                if (is_set_ckpt_flags(ckpt, CP_UMOUNT_FLAG)) {
                        struct f2fs_summary *sum_entry = &sum_blk->entries[0];
-                       int i;
+                       unsigned int i;
                        for (i = 0; i < sbi->blocks_per_seg; i++, sum_entry++) {
                                /* do not change original value */
 #if 0
@@ -621,7 +621,7 @@ int read_normal_summaries(struct f2fs_sb_info *sbi, int type)
        curseg = CURSEG_I(sbi, type);
        memcpy(curseg->sum_blk, sum_blk, PAGE_CACHE_SIZE);
        curseg->next_segno = segno;
-       reset_curseg(sbi, type, 0);
+       reset_curseg(sbi, type);
        curseg->alloc_type = ckpt->alloc_type[type];
        curseg->next_blkoff = blk_off;
        free(sum_blk);
@@ -690,12 +690,12 @@ struct f2fs_sit_block *get_current_sit_page(struct f2fs_sb_info *sbi, unsigned i
 }
 
 void check_block_count(struct f2fs_sb_info *sbi,
-               int segno, struct f2fs_sit_entry *raw_sit)
+               unsigned int segno, struct f2fs_sit_entry *raw_sit)
 {
        struct f2fs_sm_info *sm_info = SM_I(sbi);
        unsigned int end_segno = sm_info->segment_count - 1;
        int valid_blocks = 0;
-       int i;
+       unsigned int i;
 
        /* check segment usage */
        ASSERT(GET_SIT_VBLOCKS(raw_sit) <= sbi->blocks_per_seg);
@@ -896,7 +896,8 @@ int build_sit_area_bitmap(struct f2fs_sb_info *sbi)
 {
        struct f2fs_fsck *fsck = F2FS_FSCK(sbi);
        struct f2fs_sm_info *sm_i = SM_I(sbi);
-       int segno = 0, j = 0;
+       unsigned int segno = 0;
+       int j = 0;
        char *ptr = NULL;
 
        u32 sum_vblocks = 0;
@@ -977,7 +978,8 @@ void build_nat_area_bitmap(struct f2fs_sb_info *sbi)
        pgoff_t block_off;
        pgoff_t block_addr;
        int seg_off;
-       int ret, i;
+       int ret;
+       unsigned int i;
 
 
        nat_block = (struct f2fs_nat_block *)calloc(BLOCK_SZ, 1);
@@ -1097,7 +1099,7 @@ void f2fs_do_umount(struct f2fs_sb_info *sbi)
        struct sit_info *sit_i = SIT_I(sbi);
        struct f2fs_sm_info *sm_i = SM_I(sbi);
        struct f2fs_nm_info *nm_i = NM_I(sbi);
-       int i;
+       unsigned int i;
 
        /* free nm_info */
        free(nm_i->nat_bitmap);
index 94d8dc3..bfca1a4 100644 (file)
@@ -12,8 +12,6 @@
 #include <inttypes.h>
 #include <linux/types.h>
 #include <sys/types.h>
-#include <endian.h>
-#include <byteswap.h>
 
 #ifdef HAVE_CONFIG_H
 #include <config.h>
index b1b1ca3..571cd5c 100644 (file)
@@ -1,9 +1,11 @@
 
 #define POISON_POINTER_DELTA 0
-#define LIST_POISON1  ((void *) 0x00100100 + POISON_POINTER_DELTA)
-#define LIST_POISON2  ((void *) 0x00200200 + POISON_POINTER_DELTA)
+#define LIST_POISON1  ((void *) (0x00100100 + POISON_POINTER_DELTA))
+#define LIST_POISON2  ((void *) (0x00200200 + POISON_POINTER_DELTA))
 
+#if !defined(offsetof)
 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+#endif
 #define container_of(ptr, type, member) ({                      \
                const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
                (type *)( (char *)__mptr - offsetof(type,member) );})
index fb3f8c1..c1e0b0e 100644 (file)
@@ -20,7 +20,6 @@
 #include <sys/mount.h>
 #include <sys/ioctl.h>
 #include <linux/hdreg.h>
-#include <linux/fs.h>
 
 #include <f2fs_fs.h>
 
@@ -428,7 +427,7 @@ int f2fs_dev_is_umounted(struct f2fs_configuration *c)
 int f2fs_get_device_info(struct f2fs_configuration *c)
 {
        int32_t fd = 0;
-       int32_t sector_size;
+       uint32_t sector_size;
        struct stat stat_buf;
        struct hd_geometry geom;
 
index b726bae..508ccce 100644 (file)
@@ -20,7 +20,6 @@
 #include <sys/mount.h>
 #include <sys/ioctl.h>
 #include <linux/hdreg.h>
-#include <linux/fs.h>
 
 #include <f2fs_fs.h>
 
index cef484a..c7c6971 100644 (file)
@@ -16,7 +16,6 @@
 #include <sys/stat.h>
 #include <sys/mount.h>
 #include <time.h>
-#include <linux/fs.h>
 #include <uuid/uuid.h>
 
 #include "f2fs_fs.h"
@@ -115,30 +114,11 @@ static int f2fs_prepare_super_block(void)
        log_blks_per_seg = log_base_2(config.blks_per_seg);
 
        super_block.log_sectorsize = cpu_to_le32(log_sectorsize);
-
-       if (log_sectorsize < 0) {
-               MSG(1, "\tError: Failed to get the sector size: %u!\n",
-                               config.sector_size);
-               return -1;
-       }
-
        super_block.log_sectors_per_block = cpu_to_le32(log_sectors_per_block);
 
-       if (log_sectors_per_block < 0) {
-               MSG(1, "\tError: Failed to get sectors per block: %u!\n",
-                               config.sectors_per_blk);
-               return -1;
-       }
-
        super_block.log_blocksize = cpu_to_le32(log_blocksize);
        super_block.log_blocks_per_seg = cpu_to_le32(log_blks_per_seg);
 
-       if (log_blks_per_seg < 0) {
-               MSG(1, "\tError: Failed to get block per segment: %u!\n",
-                               config.blks_per_seg);
-               return -1;
-       }
-
        super_block.segs_per_sec = cpu_to_le32(config.segs_per_sec);
        super_block.secs_per_zone = cpu_to_le32(config.secs_per_zone);
        blk_size_bytes = 1 << log_blocksize;
index 8350182..cee640a 100644 (file)
@@ -16,7 +16,7 @@
 #include <sys/stat.h>
 #include <sys/mount.h>
 #include <time.h>
-#include <linux/fs.h>
+//#include <linux/fs.h>
 #include <uuid/uuid.h>
 
 #include "f2fs_fs.h"
index bd10968..f4c3767 100644 (file)
@@ -12,7 +12,6 @@
 #include <unistd.h>
 #include <sys/ioctl.h>
 #include <sys/stat.h>
-#include <linux/fs.h>
 
 #include "f2fs_fs.h"
 
@@ -46,6 +45,7 @@ int f2fs_trim_device()
                return -1;
        }
 
+#if defined(BLKDISCARD)
        MSG(0, "Info: Discarding device\n");
        if (S_ISREG(stat_buf.st_mode))
                return 0;
@@ -54,6 +54,7 @@ int f2fs_trim_device()
                        MSG(0, "Info: This device doesn't support TRIM\n");
        } else
                return -1;
+#endif
        return 0;
 }
 
index a6a112b..c672808 100644 (file)
@@ -11,7 +11,7 @@
 #include <libgen.h>
 #include <linux/hdreg.h>
 #include <linux/types.h>
-#include <linux/fs.h>
+// #include <linux/fs.h>
 
 struct file_ext {
        __u32 f_pos;