Fix Android build warnings

Also fix some additional gcc -Wall build warnings in a traditional
Linux environment.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
debian
Theodore Ts'o 2016-05-29 23:35:13 -04:00
parent 749f07121d
commit 478360f50b
15 changed files with 72 additions and 38 deletions

View File

@ -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;

View File

@ -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);

View File

@ -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;

View File

@ -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");

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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;
}

View File

@ -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,

View File

@ -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();

View File

@ -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);

View File

@ -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;

View File

@ -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

View File

@ -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