diff --git a/debugfs/do_journal.c b/debugfs/do_journal.c index b8c1e598..40c473ce 100644 --- a/debugfs/do_journal.c +++ b/debugfs/do_journal.c @@ -165,7 +165,8 @@ static errcode_t journal_add_revoke_to_trans(journal_transaction_t *trans, void *buf; size_t i, offset; blk64_t curr_blk; - int sz, csum_size = 0; + unsigned int sz; + unsigned csum_size = 0; struct buffer_head *bh; errcode_t err; diff --git a/debugfs/set_fields.c b/debugfs/set_fields.c index 8a4c6a8d..ff9b7b69 100644 --- a/debugfs/set_fields.c +++ b/debugfs/set_fields.c @@ -569,7 +569,6 @@ static errcode_t parse_time(struct field_set_info *info, __s64 t; __u32 t_low, t_high; __u32 *ptr_low, *ptr_high; - int suffix = check_suffix(field); if (check_suffix(field)) return parse_uint(info, field, arg); diff --git a/e2fsck/recovery.c b/e2fsck/recovery.c index b828ed4c..48f42b73 100644 --- a/e2fsck/recovery.c +++ b/e2fsck/recovery.c @@ -184,7 +184,7 @@ static int jbd2_descr_block_csum_verify(journal_t *j, if (!journal_has_csum_v2or3(j)) return 1; - tail = (struct journal_block_tail *)(buf + j->j_blocksize - + tail = (struct journal_block_tail *)((char *)buf + j->j_blocksize - sizeof(struct journal_block_tail)); provided = tail->t_checksum; tail->t_checksum = 0; @@ -626,8 +626,9 @@ static int do_one_pass(journal_t *journal, memcpy(nbh->b_data, obh->b_data, journal->j_blocksize); if (flags & JFS_FLAG_ESCAPE) { - *((__u32 *)nbh->b_data) = - ext2fs_cpu_to_be32(JFS_MAGIC_NUMBER); + __u32 magic = ext2fs_cpu_to_be32(JFS_MAGIC_NUMBER); + memcpy(nbh->b_data, &magic, + sizeof(magic)); } BUFFER_TRACE(nbh, "marking dirty"); @@ -818,7 +819,7 @@ static int jbd2_revoke_block_csum_verify(journal_t *j, if (!journal_has_csum_v2or3(j)) return 1; - tail = (struct journal_revoke_tail *)(buf + j->j_blocksize - + tail = (struct journal_revoke_tail *)((char *)buf + j->j_blocksize - sizeof(struct journal_revoke_tail)); provided = tail->r_checksum; tail->r_checksum = 0; @@ -835,7 +836,7 @@ static int scan_revoke_records(journal_t *journal, struct buffer_head *bh, { journal_revoke_header_t *header; int offset, max; - int csum_size = 0; + unsigned csum_size = 0; __u32 rcount; int record_len = 4; diff --git a/e2fsck/rehash.c b/e2fsck/rehash.c index 10e5d67a..22a58f33 100644 --- a/e2fsck/rehash.c +++ b/e2fsck/rehash.c @@ -791,8 +791,9 @@ errcode_t e2fsck_rehash_dir(e2fsck_t ctx, ext2_ino_t ino, errcode_t retval; struct ext2_inode inode; char *dir_buf = 0; - struct fill_dir_struct fd = { NULL }; - struct out_dir outdir = { 0 }; + struct fill_dir_struct fd = { NULL, NULL, 0, 0, 0, NULL, + 0, 0, 0, 0, 0, 0 }; + struct out_dir outdir = { 0, 0, 0, 0 }; e2fsck_read_inode(ctx, ino, &inode, "rehash_dir"); diff --git a/lib/blkid/blkidP.h b/lib/blkid/blkidP.h index e0f11a07..b90bfedb 100644 --- a/lib/blkid/blkidP.h +++ b/lib/blkid/blkidP.h @@ -157,7 +157,7 @@ struct dir_list { char *name; struct dir_list *next; }; -extern void blkid__scan_dir(char *, dev_t, struct dir_list **, char **); +extern void blkid__scan_dir(const char *, dev_t, struct dir_list **, char **); /* lseek.c */ extern blkid_loff_t blkid_llseek(int fd, blkid_loff_t offset, int whence); diff --git a/lib/blkid/devno.c b/lib/blkid/devno.c index 479d9776..aa6eb907 100644 --- a/lib/blkid/devno.c +++ b/lib/blkid/devno.c @@ -91,7 +91,7 @@ static void free_dirlist(struct dir_list **list) *list = NULL; } -void blkid__scan_dir(char *dirname, dev_t devno, struct dir_list **list, +void blkid__scan_dir(const char *dirname, dev_t devno, struct dir_list **list, char **devname) { DIR *dir; diff --git a/lib/blkid/probe.c b/lib/blkid/probe.c index a4860171..66ecbc43 100644 --- a/lib/blkid/probe.c +++ b/lib/blkid/probe.c @@ -857,10 +857,10 @@ static int probe_jfs(struct blkid_probe *probe, js = (struct jfs_super_block *)buf; - if (blkid_le32(js->js_bsize) != (1 << blkid_le16(js->js_l2bsize))) + if (blkid_le32(js->js_bsize) != (1U << blkid_le16(js->js_l2bsize))) return 1; - if (blkid_le32(js->js_pbsize) != (1 << blkid_le16(js->js_l2pbsize))) + if (blkid_le32(js->js_pbsize) != (1U << blkid_le16(js->js_l2pbsize))) return 1; if ((blkid_le16(js->js_l2bsize) - blkid_le16(js->js_l2pbsize)) != @@ -1393,7 +1393,7 @@ static int probe_btrfs(struct blkid_probe *probe, } static int probe_f2fs(struct blkid_probe *probe, - struct blkid_magic *id, + struct blkid_magic *id __BLKID_ATTR((unused)), unsigned char *buf) { struct f2fs_super_block *bs; diff --git a/lib/ext2fs/kernel-jbd.h b/lib/ext2fs/kernel-jbd.h index 092a50ba..a7507b57 100644 --- a/lib/ext2fs/kernel-jbd.h +++ b/lib/ext2fs/kernel-jbd.h @@ -274,7 +274,12 @@ typedef struct journal_superblock_s JFS_FEATURE_INCOMPAT_CSUM_V2|\ JFS_FEATURE_INCOMPAT_CSUM_V3) - +#ifdef NO_INLINE_FUNCS +extern size_t journal_tag_bytes(journal_t *journal); +extern int journal_has_csum_v2or3(journal_t *journal); +extern int tid_gt(tid_t x, tid_t y) EXT2FS_ATTR((unused)); +extern int tid_geq(tid_t x, tid_t y) EXT2FS_ATTR((unused)); +#endif #if (defined(E2FSCK_INCLUDE_INLINE_FUNCS) || !defined(NO_INLINE_FUNCS)) #ifdef E2FSCK_INCLUDE_INLINE_FUNCS @@ -297,17 +302,20 @@ typedef struct journal_superblock_s /* journal feature predicate functions */ #define JFS_FEATURE_COMPAT_FUNCS(name, flagname) \ +_INLINE_ int jfs_has_feature_##name(journal_t *j); \ _INLINE_ int jfs_has_feature_##name(journal_t *j) \ { \ return ((j)->j_format_version >= 2 && \ ((j)->j_superblock->s_feature_compat & \ ext2fs_cpu_to_be32(JFS_FEATURE_COMPAT_##flagname)) != 0); \ } \ +_INLINE_ void jfs_set_feature_##name(journal_t *j); \ _INLINE_ void jfs_set_feature_##name(journal_t *j) \ { \ (j)->j_superblock->s_feature_compat |= \ ext2fs_cpu_to_be32(JFS_FEATURE_COMPAT_##flagname); \ } \ +_INLINE_ void jfs_clear_feature_##name(journal_t *j); \ _INLINE_ void jfs_clear_feature_##name(journal_t *j) \ { \ (j)->j_superblock->s_feature_compat &= \ @@ -315,17 +323,20 @@ _INLINE_ void jfs_clear_feature_##name(journal_t *j) \ } #define JFS_FEATURE_RO_COMPAT_FUNCS(name, flagname) \ - _INLINE_ int jfs_has_feature_##name(journal_t *j) \ +_INLINE_ int jfs_has_feature_##name(journal_t *j); \ +_INLINE_ int jfs_has_feature_##name(journal_t *j) \ { \ return ((j)->j_format_version >= 2 && \ ((j)->j_superblock->s_feature_ro_compat & \ ext2fs_cpu_to_be32(JFS_FEATURE_RO_COMPAT_##flagname)) != 0); \ } \ +_INLINE_ void jfs_set_feature_##name(journal_t *j); \ _INLINE_ void jfs_set_feature_##name(journal_t *j) \ { \ (j)->j_superblock->s_feature_ro_compat |= \ ext2fs_cpu_to_be32(JFS_FEATURE_RO_COMPAT_##flagname); \ } \ +_INLINE_ void jfs_clear_feature_##name(journal_t *j); \ _INLINE_ void jfs_clear_feature_##name(journal_t *j) \ { \ (j)->j_superblock->s_feature_ro_compat &= \ @@ -333,23 +344,44 @@ _INLINE_ void jfs_clear_feature_##name(journal_t *j) \ } #define JFS_FEATURE_INCOMPAT_FUNCS(name, flagname) \ +_INLINE_ int jfs_has_feature_##name(journal_t *j); \ _INLINE_ int jfs_has_feature_##name(journal_t *j) \ { \ return ((j)->j_format_version >= 2 && \ ((j)->j_superblock->s_feature_incompat & \ ext2fs_cpu_to_be32(JFS_FEATURE_INCOMPAT_##flagname)) != 0); \ } \ +_INLINE_ void jfs_set_feature_##name(journal_t *j); \ _INLINE_ void jfs_set_feature_##name(journal_t *j) \ { \ (j)->j_superblock->s_feature_incompat |= \ ext2fs_cpu_to_be32(JFS_FEATURE_INCOMPAT_##flagname); \ } \ +_INLINE_ void jfs_clear_feature_##name(journal_t *j); \ _INLINE_ void jfs_clear_feature_##name(journal_t *j) \ { \ (j)->j_superblock->s_feature_incompat &= \ ~ext2fs_cpu_to_be32(JFS_FEATURE_INCOMPAT_##flagname); \ } +#else +#define JFS_FEATURE_COMPAT_FUNCS(name, flagname) \ +extern int jfs_has_feature_##name(journal_t *j); \ +extern void jfs_set_feature_##name(journal_t *j); \ +extern void jfs_clear_feature_##name(journal_t *j); + +#define JFS_FEATURE_RO_COMPAT_FUNCS(name, flagname) \ +extern int jfs_has_feature_##name(journal_t *j); \ +extern void jfs_set_feature_##name(journal_t *j); \ +extern void jfs_clear_feature_##name(journal_t *j); + +#define JFS_FEATURE_INCOMPAT_FUNCS(name, flagname) \ +extern int jfs_has_feature_##name(journal_t *j); \ +extern void jfs_set_feature_##name(journal_t *j); \ +extern void jfs_clear_feature_##name(journal_t *j); + +#endif /* (defined(E2FSCK_INCLUDE_INLINE_FUNCS) || !defined(NO_INLINE_FUNCS)) */ + JFS_FEATURE_COMPAT_FUNCS(checksum, CHECKSUM) JFS_FEATURE_INCOMPAT_FUNCS(revoke, REVOKE) @@ -358,6 +390,7 @@ JFS_FEATURE_INCOMPAT_FUNCS(async_commit, ASYNC_COMMIT) JFS_FEATURE_INCOMPAT_FUNCS(csum2, CSUM_V2) JFS_FEATURE_INCOMPAT_FUNCS(csum3, CSUM_V3) +#if (defined(E2FSCK_INCLUDE_INLINE_FUNCS) || !defined(NO_INLINE_FUNCS)) /* * helper functions to deal with 32 or 64bit block numbers. */ @@ -387,9 +420,6 @@ _INLINE_ int journal_has_csum_v2or3(journal_t *journal) return 0; } -_INLINE_ int tid_gt(tid_t x, tid_t y) EXT2FS_ATTR((unused)); -_INLINE_ int tid_geq(tid_t x, tid_t y) EXT2FS_ATTR((unused)); - /* Comparison functions for transaction IDs: perform comparisons using * modulo arithmetic so that they work over sequence number wraps. */ @@ -404,9 +434,9 @@ _INLINE_ int tid_geq(tid_t x, tid_t y) int difference = (x - y); return (difference >= 0); } +#endif /* (defined(E2FSCK_INCLUDE_INLINE_FUNCS) || !defined(NO_INLINE_FUNCS)) */ #undef _INLINE_ -#endif extern int journal_blocks_per_page(struct inode *inode); diff --git a/lib/support/mkquota.c b/lib/support/mkquota.c index fc3f556e..8407c76e 100644 --- a/lib/support/mkquota.c +++ b/lib/support/mkquota.c @@ -670,7 +670,7 @@ out: return err; } -int parse_quota_opts(const char *opts, int (*func)(char *, void *), void *data) +int parse_quota_opts(const char *opts, int (*func)(char *)) { char *buf, *token, *next, *p; int len; @@ -691,7 +691,7 @@ int parse_quota_opts(const char *opts, int (*func)(char *, void *), void *data) *p = 0; next = p + 1; } - ret = func(token, data); + ret = func(token); if (ret) break; } diff --git a/lib/support/quotaio.h b/lib/support/quotaio.h index 8f7ddcb0..486c2a56 100644 --- a/lib/support/quotaio.h +++ b/lib/support/quotaio.h @@ -233,7 +233,7 @@ int quota_file_exists(ext2_filsys fs, enum quota_type qtype); void quota_set_sb_inum(ext2_filsys fs, ext2_ino_t ino, enum quota_type qtype); errcode_t quota_compare_and_update(quota_ctx_t qctx, enum quota_type qtype, int *usage_inconsistent); -int parse_quota_opts(const char *opts, int (*func)(char *, void *), void *data); +int parse_quota_opts(const char *opts, int (*func)(char *)); /* parse_qtype.c */ int parse_quota_types(const char *in_str, unsigned int *qtype_bits, diff --git a/lib/support/quotaio_tree.c b/lib/support/quotaio_tree.c index 3e6fd2ca..a7c2028c 100644 --- a/lib/support/quotaio_tree.c +++ b/lib/support/quotaio_tree.c @@ -314,7 +314,8 @@ static void dq_insert_tree(struct quota_handle *h, struct dquot *dquot) /* Write dquot to file */ void qtree_write_dquot(struct dquot *dquot) { - ssize_t ret; + errcode_t retval; + unsigned int ret; char *ddquot; struct quota_handle *h = dquot->dq_h; struct qtree_mem_dqinfo *info = @@ -322,8 +323,8 @@ void qtree_write_dquot(struct dquot *dquot) log_debug("writing ddquot 1: off=%llu, info->dqi_entry_size=%u", dquot->dq_dqb.u.v2_mdqb.dqb_off, info->dqi_entry_size); - ret = ext2fs_get_mem(info->dqi_entry_size, &ddquot); - if (ret) { + retval = ext2fs_get_mem(info->dqi_entry_size, &ddquot); + if (retval) { errno = ENOMEM; log_err("Quota write failed (id %u): %s", (unsigned int)dquot->dq_id, strerror(errno)); @@ -506,7 +507,7 @@ struct dquot *qtree_read_dquot(struct quota_handle *h, qid_t id) { struct qtree_mem_dqinfo *info = &h->qh_info.u.v2_mdqi.dqi_qtree; ext2_loff_t offset; - ssize_t ret; + unsigned int ret; char *ddquot; struct dquot *dquot = get_empty_dquot(); diff --git a/misc/create_inode.c b/misc/create_inode.c index c879a3ec..fd5cb21f 100644 --- a/misc/create_inode.c +++ b/misc/create_inode.c @@ -444,10 +444,10 @@ fail: return err; } +#if defined(SEEK_DATA) && defined(SEEK_HOLE) static errcode_t try_lseek_copy(ext2_filsys fs, int fd, struct stat *statbuf, ext2_file_t e2_file, char *buf, char *zerobuf) { -#if defined(SEEK_DATA) && defined(SEEK_HOLE) off_t data = 0, hole; off_t data_blk, hole_blk; errcode_t err; @@ -475,15 +475,13 @@ static errcode_t try_lseek_copy(ext2_filsys fs, int fd, struct stat *statbuf, } return err; -#else - return EXT2_ET_UNIMPLEMENTED; -#endif /* SEEK_DATA and SEEK_HOLE */ } +#endif /* SEEK_DATA and SEEK_HOLE */ +#if defined(FS_IOC_FIEMAP) static errcode_t try_fiemap_copy(ext2_filsys fs, int fd, ext2_file_t e2_file, char *buf, char *zerobuf) { -#if defined(FS_IOC_FIEMAP) #define EXTENT_MAX_COUNT 512 struct fiemap *fiemap_buf; struct fiemap_extent *ext_buf, *ext; @@ -537,10 +535,8 @@ static errcode_t try_fiemap_copy(ext2_filsys fs, int fd, ext2_file_t e2_file, out: ext2fs_free_mem(&fiemap_buf); return err; -#else - return EXT2_ET_UNIMPLEMENTED; -#endif /* FS_IOC_FIEMAP */ } +#endif /* FS_IOC_FIEMAP */ static errcode_t copy_file(ext2_filsys fs, int fd, struct stat *statbuf, ext2_ino_t ino) @@ -561,13 +557,17 @@ static errcode_t copy_file(ext2_filsys fs, int fd, struct stat *statbuf, if (err) goto out; +#if defined(SEEK_DATA) && defined(SEEK_HOLE) err = try_lseek_copy(fs, fd, statbuf, e2_file, buf, zerobuf); if (err != EXT2_ET_UNIMPLEMENTED) goto out; +#endif +#if defined(FS_IOC_FIEMAP) err = try_fiemap_copy(fs, fd, e2_file, buf, zerobuf); if (err != EXT2_ET_UNIMPLEMENTED) goto out; +#endif err = copy_file_range(fs, fd, e2_file, 0, statbuf->st_size, buf, zerobuf); diff --git a/misc/tune2fs.c b/misc/tune2fs.c index 2d9ded6a..8562de6d 100644 --- a/misc/tune2fs.c +++ b/misc/tune2fs.c @@ -1557,7 +1557,7 @@ static void handle_quota_options(ext2_filsys fs) return; } -static int option_handle_function(char *token, void *data) +static int option_handle_function(char *token) { if (strncmp(token, "usr", 3) == 0) { quota_enable[USRQUOTA] = QOPT_ENABLE; @@ -1805,8 +1805,7 @@ static void parse_tune2fs_options(int argc, char **argv) break; case 'Q': Q_flag = 1; - ret = parse_quota_opts(optarg, option_handle_function, - NULL); + ret = parse_quota_opts(optarg, option_handle_function); if (ret) exit(1); open_flag = EXT2_FLAG_RW; diff --git a/util/android_config.h b/util/android_config.h index 51db4876..b3c12a7d 100644 --- a/util/android_config.h +++ b/util/android_config.h @@ -33,6 +33,7 @@ #define HAVE_STRCASECMP 1 #define HAVE_STRDUP 1 #define HAVE_STRINGS_H 1 +#define HAVE_STRNLEN 1 #define HAVE_STRPTIME 1 #define HAVE_SYSCONF 1 #define HAVE_SYS_IOCTL_H 1 diff --git a/util/gcc-wall-cleanup b/util/gcc-wall-cleanup index 52a80d5f..cef7a2dc 100644 --- a/util/gcc-wall-cleanup +++ b/util/gcc-wall-cleanup @@ -13,6 +13,7 @@ /traditional C rejects string concatenation/d /integer constant is unsigned in ANSI C, signed with -traditional/d /ISO C forbids conversion of object pointer to function pointer type/,+2d +/ISO C does not support ‘__FUNCTION__’ predefined identifier/d /At top level:/d /In file included from/d /In function `.*':/d