Fix various clang and gcc -Wall warnings

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
debian
Theodore Ts'o 2016-03-18 12:45:19 -04:00
parent 17ea174a75
commit 82e48fb163
12 changed files with 109 additions and 83 deletions

View File

@ -133,7 +133,7 @@ void do_lsdel(int argc, char **argv)
while (ino) {
if ((inode.i_dtime == 0) ||
(secs && ((unsigned) abs(now - secs) > inode.i_dtime)))
(secs && (labs(now - secs) > (long) inode.i_dtime)))
goto next;
lsd.inode = ino;

View File

@ -590,7 +590,7 @@ static void check_is_really_dir(e2fsck_t ctx, struct problem_context *pctx,
if (inlinedata_fs && (inode->i_flags & EXT4_INLINE_DATA_FL)) {
size_t size;
__u32 dotdot;
unsigned int rec_len;
unsigned int rec_len2;
struct ext2_dir_entry de;
if (ext2fs_inline_data_size(ctx->fs, pctx->ino, &size))
@ -611,14 +611,14 @@ static void check_is_really_dir(e2fsck_t ctx, struct problem_context *pctx,
dotdot = ext2fs_le32_to_cpu(dotdot);
de.inode = ext2fs_le32_to_cpu(de.inode);
de.rec_len = ext2fs_le16_to_cpu(de.rec_len);
ext2fs_get_rec_len(ctx->fs, &de, &rec_len);
ext2fs_get_rec_len(ctx->fs, &de, &rec_len2);
if (dotdot >= ctx->fs->super->s_inodes_count ||
(dotdot < EXT2_FIRST_INO(ctx->fs->super) &&
dotdot != EXT2_ROOT_INO) ||
de.inode >= ctx->fs->super->s_inodes_count ||
(de.inode < EXT2_FIRST_INO(ctx->fs->super) &&
de.inode != 0) ||
rec_len > EXT4_MIN_INLINE_DATA_SIZE -
rec_len2 > EXT4_MIN_INLINE_DATA_SIZE -
EXT4_INLINE_DATA_DOTDOT_SIZE)
return;
/* device files never have a "system.data" entry */
@ -1979,7 +1979,8 @@ static void process_inodes(e2fsck_t ctx, char *block_buf)
sizeof(struct process_inode_block), process_inode_cmp);
clear_problem_context(&pctx);
for (i=0; i < process_inode_count; i++) {
pctx.inode = ctx->stashed_inode = &inodes_to_process[i].inode;
pctx.inode = ctx->stashed_inode =
(struct ext2_inode *) &inodes_to_process[i].inode;
pctx.ino = ctx->stashed_ino = inodes_to_process[i].ino;
#if 0
@ -2017,8 +2018,8 @@ static EXT2_QSORT_TYPE process_inode_cmp(const void *a, const void *b)
* inodes, so it's OK to pass NULL to
* ext2fs_file_acl_block() here.
*/
ret = ext2fs_file_acl_block(0, &(ib_a->inode)) -
ext2fs_file_acl_block(0, &(ib_b->inode));
ret = ext2fs_file_acl_block(0, ext2fs_const_inode(&ib_a->inode)) -
ext2fs_file_acl_block(0, ext2fs_const_inode(&ib_b->inode));
if (ret == 0)
ret = ib_a->ino - ib_b->ino;
return ret;

View File

@ -1692,6 +1692,8 @@ extern int ext2fs_dirent_name_len(const struct ext2_dir_entry *entry);
extern void ext2fs_dirent_set_name_len(struct ext2_dir_entry *entry, int len);
extern int ext2fs_dirent_file_type(const struct ext2_dir_entry *entry);
extern void ext2fs_dirent_set_file_type(struct ext2_dir_entry *entry, int type);
extern struct ext2_inode *ext2fs_inode(struct ext2_inode_large * large_inode);
extern const struct ext2_inode *ext2fs_const_inode(const struct ext2_inode_large * large_inode);
#endif
@ -1952,6 +1954,19 @@ _INLINE_ void ext2fs_dirent_set_file_type(struct ext2_dir_entry *entry, int type
entry->name_len = (entry->name_len & 0xff) | (type << 8);
}
_INLINE_ struct ext2_inode *ext2fs_inode(struct ext2_inode_large * large_inode)
{
/* It is always safe to convert large inode to a small inode */
return (struct ext2_inode *) large_inode;
}
_INLINE_ const struct ext2_inode *
ext2fs_const_inode(const struct ext2_inode_large * large_inode)
{
/* It is always safe to convert large inode to a small inode */
return (const struct ext2_inode *) large_inode;
}
#undef _INLINE_
#endif

View File

@ -253,69 +253,6 @@ typedef struct journal_superblock_s
#define JFS_FEATURE_INCOMPAT_CSUM_V2 0x00000008
#define JFS_FEATURE_INCOMPAT_CSUM_V3 0x00000010
/* journal feature predicate functions */
#define JFS_FEATURE_COMPAT_FUNCS(name, flagname) \
static 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); \
} \
static inline void jfs_set_feature_##name(journal_t *j) \
{ \
(j)->j_superblock->s_feature_compat |= \
ext2fs_cpu_to_be32(JFS_FEATURE_COMPAT_##flagname); \
} \
static inline void jfs_clear_feature_##name(journal_t *j) \
{ \
(j)->j_superblock->s_feature_compat &= \
~ext2fs_cpu_to_be32(JFS_FEATURE_COMPAT_##flagname); \
}
#define JFS_FEATURE_RO_COMPAT_FUNCS(name, flagname) \
static 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); \
} \
static 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); \
} \
static inline void jfs_clear_feature_##name(journal_t *j) \
{ \
(j)->j_superblock->s_feature_ro_compat &= \
~ext2fs_cpu_to_be32(JFS_FEATURE_RO_COMPAT_##flagname); \
}
#define JFS_FEATURE_INCOMPAT_FUNCS(name, flagname) \
static 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); \
} \
static inline void jfs_set_feature_##name(journal_t *j) \
{ \
(j)->j_superblock->s_feature_incompat |= \
ext2fs_cpu_to_be32(JFS_FEATURE_INCOMPAT_##flagname); \
} \
static inline void jfs_clear_feature_##name(journal_t *j) \
{ \
(j)->j_superblock->s_feature_incompat &= \
~ext2fs_cpu_to_be32(JFS_FEATURE_INCOMPAT_##flagname); \
}
JFS_FEATURE_COMPAT_FUNCS(checksum, CHECKSUM)
JFS_FEATURE_INCOMPAT_FUNCS(revoke, REVOKE)
JFS_FEATURE_INCOMPAT_FUNCS(64bit, 64BIT)
JFS_FEATURE_INCOMPAT_FUNCS(async_commit, ASYNC_COMMIT)
JFS_FEATURE_INCOMPAT_FUNCS(csum2, CSUM_V2)
JFS_FEATURE_INCOMPAT_FUNCS(csum3, CSUM_V3)
/* Features known to this kernel version: */
#define JFS_KNOWN_COMPAT_FEATURES 0
#define JFS_KNOWN_ROCOMPAT_FEATURES 0
@ -325,6 +262,8 @@ JFS_FEATURE_INCOMPAT_FUNCS(csum3, CSUM_V3)
JFS_FEATURE_INCOMPAT_CSUM_V2|\
JFS_FEATURE_INCOMPAT_CSUM_V3)
#if (defined(E2FSCK_INCLUDE_INLINE_FUNCS) || !defined(NO_INLINE_FUNCS))
#ifdef E2FSCK_INCLUDE_INLINE_FUNCS
#if (__STDC_VERSION__ >= 199901L)
@ -344,10 +283,73 @@ JFS_FEATURE_INCOMPAT_FUNCS(csum3, CSUM_V3)
#endif /* __STDC_VERSION__ >= 199901L */
#endif /* INCLUDE_INLINE_FUNCS */
/* journal feature predicate functions */
#define JFS_FEATURE_COMPAT_FUNCS(name, flagname) \
_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) \
{ \
(j)->j_superblock->s_feature_compat |= \
ext2fs_cpu_to_be32(JFS_FEATURE_COMPAT_##flagname); \
} \
_INLINE_ void jfs_clear_feature_##name(journal_t *j) \
{ \
(j)->j_superblock->s_feature_compat &= \
~ext2fs_cpu_to_be32(JFS_FEATURE_COMPAT_##flagname); \
}
#define JFS_FEATURE_RO_COMPAT_FUNCS(name, flagname) \
_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) \
{ \
(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) \
{ \
(j)->j_superblock->s_feature_ro_compat &= \
~ext2fs_cpu_to_be32(JFS_FEATURE_RO_COMPAT_##flagname); \
}
#define JFS_FEATURE_INCOMPAT_FUNCS(name, flagname) \
_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) \
{ \
(j)->j_superblock->s_feature_incompat |= \
ext2fs_cpu_to_be32(JFS_FEATURE_INCOMPAT_##flagname); \
} \
_INLINE_ void jfs_clear_feature_##name(journal_t *j) \
{ \
(j)->j_superblock->s_feature_incompat &= \
~ext2fs_cpu_to_be32(JFS_FEATURE_INCOMPAT_##flagname); \
}
JFS_FEATURE_COMPAT_FUNCS(checksum, CHECKSUM)
JFS_FEATURE_INCOMPAT_FUNCS(revoke, REVOKE)
JFS_FEATURE_INCOMPAT_FUNCS(64bit, 64BIT)
JFS_FEATURE_INCOMPAT_FUNCS(async_commit, ASYNC_COMMIT)
JFS_FEATURE_INCOMPAT_FUNCS(csum2, CSUM_V2)
JFS_FEATURE_INCOMPAT_FUNCS(csum3, CSUM_V3)
/*
* helper functions to deal with 32 or 64bit block numbers.
*/
static inline size_t journal_tag_bytes(journal_t *journal)
_INLINE_ size_t journal_tag_bytes(journal_t *journal)
{
size_t sz;
@ -365,34 +367,35 @@ static inline size_t journal_tag_bytes(journal_t *journal)
return sz - sizeof(__u32);
}
static inline int journal_has_csum_v2or3(journal_t *journal)
_INLINE_ int journal_has_csum_v2or3(journal_t *journal)
{
if (jfs_has_feature_csum2(journal) || jfs_has_feature_csum3(journal))
return 1;
return 0;
}
#undef _INLINE_
#endif
static inline int tid_gt(tid_t x, tid_t y) EXT2FS_ATTR((unused));
static inline int tid_geq(tid_t x, tid_t y) EXT2FS_ATTR((unused));
_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. */
static inline int tid_gt(tid_t x, tid_t y)
_INLINE_ int tid_gt(tid_t x, tid_t y)
{
int difference = (x - y);
return (difference > 0);
}
static inline int tid_geq(tid_t x, tid_t y)
_INLINE_ int tid_geq(tid_t x, tid_t y)
{
int difference = (x - y);
return (difference >= 0);
}
#undef _INLINE_
#endif
extern int journal_blocks_per_page(struct inode *inode);
/*

View File

@ -232,7 +232,7 @@ static errcode_t punch_extent_blocks(ext2_filsys fs, ext2_ino_t ino,
}
/* Free whole clusters from the middle of the range. */
while (free_count > 0 && free_count >= EXT2FS_CLUSTER_RATIO(fs)) {
while (free_count > 0 && free_count >= (unsigned) EXT2FS_CLUSTER_RATIO(fs)) {
ext2fs_block_alloc_stats2(fs, free_start, -1);
freed_now++;
cluster_freed = EXT2FS_CLUSTER_RATIO(fs);

View File

@ -114,7 +114,11 @@ struct undo_key_block {
__le32 crc; /* block checksum */
__le64 reserved; /* zero */
#if __STDC_VERSION__ >= 199901L
struct undo_key keys[]; /* keys, which come immediately after */
#else
struct undo_key keys[0]; /* keys, which come immediately after */
#endif
};
struct undo_private_data {

View File

@ -1023,7 +1023,7 @@ static errcode_t unix_zeroout(io_channel channel, unsigned long long block,
ret = fstat(data->dev, &statbuf);
if (ret)
goto err;
if (statbuf.st_size < (block + count) * channel->block_size) {
if ((unsigned long long) statbuf.st_size < (block + count) * channel->block_size) {
ret = ftruncate(data->dev,
(block + count) * channel->block_size);
if (ret)

View File

@ -44,7 +44,7 @@ struct disk_dqheader {
*/
const char *quota_type2name(enum quota_type qtype)
{
if (qtype < 0 || qtype >= MAXQUOTAS)
if (qtype >= MAXQUOTAS)
return "unknown";
return extensions[qtype];
}
@ -328,7 +328,7 @@ errcode_t quota_file_create(struct quota_handle *h, ext2_filsys fs,
{
ext2_file_t e2_file;
int err;
unsigned long qf_inum = 0;
ext2_ino_t qf_inum = 0;
if (fmt == -1)
fmt = QFMT_VFS_V1;

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)(), void *data);
int parse_quota_opts(const char *opts, int (*func)(void), void *data);
/*
* Return pointer to reserved inode field in superblock for given quota type.

View File

@ -37,6 +37,7 @@
* gcc-wall wall mode
*/
#define _SVID_SOURCE
#define _DEFAULT_SOURCE /* since glibc 2.20 _SVID_SOURCE is deprecated */
#include "config.h"

View File

@ -4,6 +4,7 @@
#define _XOPEN_SOURCE 600 /* for inclusion of PATH_MAX in Solaris */
#define _BSD_SOURCE /* for makedev() and major() */
#define _DEFAULT_SOURCE /* since glibc 2.20 _BSD_SOURCE is deprecated */
#include "config.h"
#include <stdio.h>

View File

@ -44,6 +44,7 @@ extern int optind;
#include <strings.h> /* for strcasecmp() */
#else
#define _BSD_SOURCE /* for inclusion of strcasecmp() via <string.h> */
#define _DEFAULT_SOURCE /* since glibc 2.20 _BSD_SOURCE is deprecated */
#endif
#include <string.h>
#include <time.h>