From d55f8b8c3fd2ef1ab3d8fe580c20f4fc282e0d8b Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Tue, 17 Aug 2021 15:56:24 -0400 Subject: [PATCH 1/1] fix unused-function -Wall warnings Signed-off-by: Theodore Ts'o --- debugfs/logdump.c | 7 ++++++ e2fsck/e2fsck.h | 7 ++++++ e2fsck/jfs_user.h | 59 +++++++++++++++++++++++++++++-------------------- lib/ext2fs/compiler.h | 9 ++++++++ lib/ext2fs/jfs_compat.h | 6 ----- lib/ext2fs/rbtree.h | 9 ++++++++ 6 files changed, 67 insertions(+), 30 deletions(-) diff --git a/debugfs/logdump.c b/debugfs/logdump.c index 5416f9e..4154ef2 100644 --- a/debugfs/logdump.c +++ b/debugfs/logdump.c @@ -33,7 +33,14 @@ extern char *optarg; #include "debugfs.h" #include "blkid/blkid.h" #include "jfs_user.h" +#if __GNUC_PREREQ (4, 6) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-function" +#endif #include "ext2fs/fast_commit.h" +#if __GNUC_PREREQ (4, 6) +#pragma GCC diagnostic pop +#endif #include enum journal_location {JOURNAL_IS_INTERNAL, JOURNAL_IS_EXTERNAL}; diff --git a/e2fsck/e2fsck.h b/e2fsck/e2fsck.h index 5704316..00b2091 100644 --- a/e2fsck/e2fsck.h +++ b/e2fsck/e2fsck.h @@ -68,7 +68,14 @@ #endif #include "support/quotaio.h" +#if __GNUC_PREREQ (4, 6) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-function" +#endif #include "ext2fs/fast_commit.h" +#if __GNUC_PREREQ (4, 6) +#pragma GCC diagnostic pop +#endif /* * Exit codes used by fsck-type programs diff --git a/e2fsck/jfs_user.h b/e2fsck/jfs_user.h index 6d24558..4ad2005 100644 --- a/e2fsck/jfs_user.h +++ b/e2fsck/jfs_user.h @@ -92,14 +92,6 @@ typedef struct kmem_cache { #define kmalloc(len, flags) malloc(len) #define kfree(p) free(p) -static inline void *kmalloc_array(unsigned n, unsigned size, - int flags EXT2FS_ATTR((unused))) -{ - if (n && (~0U)/n < size) - return NULL; - return malloc(n * size); -} - #define cond_resched() do { } while (0) #define __init @@ -120,6 +112,11 @@ extern size_t journal_tag_bytes(journal_t *journal); extern __u32 __hash_32(__u32 val); extern __u32 hash_32(__u32 val, unsigned int bits); extern __u32 hash_64(__u64 val, unsigned int bits); +extern void *kmalloc_array(unsigned n, unsigned size, int flags); +extern __u32 jbd2_chksum(journal_t *j, __u32 crc, const void *address, + unsigned int length); +extern void jbd2_descriptor_block_csum_set(journal_t *j, + struct buffer_head *bh); #endif #if (defined(E2FSCK_INCLUDE_INLINE_FUNCS) || !defined(NO_INLINE_FUNCS)) @@ -182,6 +179,36 @@ _INLINE_ __u32 hash_64(__u64 val, unsigned int bits) } } +_INLINE_ void *kmalloc_array(unsigned n, unsigned size, + int flags EXT2FS_ATTR((unused))) +{ + if (n && (~0U)/n < size) + return NULL; + return malloc(n * size); +} + +_INLINE_ __u32 jbd2_chksum(journal_t *j EXT2FS_ATTR((unused)), + __u32 crc, const void *address, + unsigned int length) +{ + return ext2fs_crc32c_le(crc, address, length); +} + +_INLINE_ void jbd2_descriptor_block_csum_set(journal_t *j, + struct buffer_head *bh) +{ + struct jbd2_journal_block_tail *tail; + __u32 csum; + + if (!jbd2_journal_has_csum_v2or3(j)) + return; + + tail = (struct jbd2_journal_block_tail *)(bh->b_data + j->j_blocksize - + sizeof(struct jbd2_journal_block_tail)); + tail->t_checksum = 0; + csum = jbd2_chksum(j, j->j_csum_seed, bh->b_data, j->j_blocksize); + tail->t_checksum = cpu_to_be32(csum); +} #undef _INLINE_ #endif @@ -235,22 +262,6 @@ extern e2fsck_t e2fsck_global_ctx; /* Try your very best not to use this! */ #define EFSCORRUPTED EXT2_ET_FILESYSTEM_CORRUPTED #endif -static inline void jbd2_descriptor_block_csum_set(journal_t *j, - struct buffer_head *bh) -{ - struct jbd2_journal_block_tail *tail; - __u32 csum; - - if (!jbd2_journal_has_csum_v2or3(j)) - return; - - tail = (struct jbd2_journal_block_tail *)(bh->b_data + j->j_blocksize - - sizeof(struct jbd2_journal_block_tail)); - tail->t_checksum = 0; - csum = jbd2_chksum(j, j->j_csum_seed, bh->b_data, j->j_blocksize); - tail->t_checksum = cpu_to_be32(csum); -} - /* recovery.c */ extern int jbd2_journal_recover (journal_t *journal); extern int jbd2_journal_skip_recovery (journal_t *); diff --git a/lib/ext2fs/compiler.h b/lib/ext2fs/compiler.h index baed2a6..3bb3521 100644 --- a/lib/ext2fs/compiler.h +++ b/lib/ext2fs/compiler.h @@ -5,6 +5,15 @@ #ifdef __GNUC__ +#ifndef __GNUC_PREREQ +#if defined(__GNUC__) && defined(__GNUC_MINOR__) +#define __GNUC_PREREQ(maj, min) \ + ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min)) +#else +#define __GNUC_PREREQ(maj, min) 0 +#endif +#endif + #define container_of(ptr, type, member) ({ \ __typeof__( ((type *)0)->member ) *__mptr = (ptr); \ (type *)( (char *)__mptr - offsetof(type,member) );}) diff --git a/lib/ext2fs/jfs_compat.h b/lib/ext2fs/jfs_compat.h index 71483f6..e11cf49 100644 --- a/lib/ext2fs/jfs_compat.h +++ b/lib/ext2fs/jfs_compat.h @@ -51,12 +51,6 @@ typedef unsigned int gfp_t; typedef __u64 u64; #define put_bh(x) brelse(x) -static inline __u32 jbd2_chksum(journal_t *j EXT2FS_ATTR((unused)), - __u32 crc, const void *address, - unsigned int length) -{ - return ext2fs_crc32c_le(crc, address, length); -} #define crc32_be(x, y, z) ext2fs_crc32_be((x), (y), (z)) #define spin_lock_init(x) #define spin_lock(x) diff --git a/lib/ext2fs/rbtree.h b/lib/ext2fs/rbtree.h index f718ad2..790f5c1 100644 --- a/lib/ext2fs/rbtree.h +++ b/lib/ext2fs/rbtree.h @@ -98,6 +98,11 @@ static inline struct page * rb_insert_page_cache(struct inode * inode, #include #include "compiler.h" +#if __GNUC_PREREQ (4, 6) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-function" +#endif + struct rb_node { uintptr_t rb_parent_color; @@ -171,4 +176,8 @@ static inline void ext2fs_rb_link_node(struct rb_node * node, *rb_link = node; } +#if __GNUC_PREREQ (4, 6) +#pragma GCC diagnostic pop +#endif + #endif /* _LINUX_RBTREE_H */ -- 1.8.3.1