sparse fixes
Hi all,
the first patch changes how STATIC is defined for debug builds to make sparse checks for debug builds work without a lot of noise.
The rest fixes up various trivial sparse warnings. After that we have 5 warnings left, out of one which is in the new scrube code and looks serious. I'll try to find some time to look into it.
PATCH 1/8 xfs: always define STATIC to static noinline
Ever since we added the noinline tag there is no good reason to define away the static for debug builds - we'll get just as good debug information with our without it, so don't mess up sparse and other checkers due to it.
--- fs/xfs/xfs.h | 1 - fs/xfs/xfs_linux.h | 14 ++------------ 2 files changed, 2 insertions(+), 13 deletions(-)
fs/xfs/xfs.h +0 -1
@@ -19,7 +19,6 @@#define __XFS_H__#ifdef CONFIG_XFS_DEBUG -#define STATIC #define DEBUG 1#define XFS_BUF_LOCK_TRACKING 1#endif
fs/xfs/xfs_linux.h +2 -12
@@ -250,10 +250,6 @@ static inline uint64_t howmany_64(uint64_t x, uint32_t y)#define ASSERT (expr) \ (likely(expr) ? (void)0 : assfail(#expr, __FILE__, __LINE__)) -#ifndef STATIC -# define STATIC noinline -#endif -#else /* !DEBUG */ #ifdef XFS_WARN
@@ -261,21 +257,15 @@ static inline uint64_t howmany_64(uint64_t x, uint32_t y)#define ASSERT (expr) \ (likely(expr) ? (void)0 : asswarn(#expr, __FILE__, __LINE__)) -#ifndef STATIC -# define STATIC static noinline -#endif -#else /* !DEBUG && !XFS_WARN */ #define ASSERT (expr) ((void)0) -#ifndef STATIC -# define STATIC static noinline -#endif -#endif /* XFS_WARN */ #endif /* DEBUG */ +#define STATIC static noinline +#ifdef CONFIG_XFS_RT /*
Signature · 1 line
2.14.2
Re: [PATCH 1/8] xfs: always define STATIC to static noinline
Quoted 6 lines · Christoph Hellwig
Ever since we added the noinline tag there is no good reason to define away the static for debug builds - we'll get just as good debug information with our without it, so don't mess up sparse and other checkers due to it.
Signed-off-by Christoph Hellwig <[email protected]>
Looks ok,
Quoted 63 lines
--- fs/xfs/xfs.h | 1 - fs/xfs/xfs_linux.h | 14 ++------------ 2 files changed, 2 insertions(+), 13 deletions(-)fs/xfs/xfs.h +0
-1@@ -19,7 +19,6 @@#define __XFS_H__#ifdef CONFIG_XFS_DEBUG -#define STATIC #define DEBUG 1#define XFS_BUF_LOCK_TRACKING 1#endif fs/xfs/xfs_linux.h +2
-12@@ -250,10 +250,6 @@ static inline uint64_t howmany_64(uint64_t x, uint32_t y)#define ASSERT (expr) \ (likely(expr) ? (void)0 : assfail(#expr, __FILE__, __LINE__)) -#ifndef STATIC -# define STATIC noinline -#endif -#else /* !DEBUG */ #ifdef XFS_WARN @@ -261,21 +257,15 @@ static inline uint64_t howmany_64(uint64_t x, uint32_t y)#define ASSERT (expr) \ (likely(expr) ? (void)0 : asswarn(#expr, __FILE__, __LINE__)) -#ifndef STATIC -# define STATIC static noinline -#endif -#else /* !DEBUG && !XFS_WARN */ #define ASSERT (expr) ((void)0) -#ifndef STATIC -# define STATIC static noinline -#endif -#endif /* XFS_WARN */ #endif /* DEBUG */ +#define STATIC static noinline +#ifdef CONFIG_XFS_RT /* Signature · 6 lines
2.14.2 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 2/8 xfs: trivial sparse fixes for the new scrub code
In reply to Christoph Hellwig--- fs/xfs/scrub/attr.c | 4 ++-- fs/xfs/scrub/bmap.c | 2 +- fs/xfs/scrub/btree.c | 2 +- fs/xfs/scrub/dir.c | 2 +- fs/xfs/scrub/scrub.c | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-)
fs/xfs/scrub/attr.c +2 -2
@@ -91,7 +91,7 @@ xfs_scrub_xattr_listent( int valuelen) {struct xfs_scrub_xattr *sx; -struct xfs_da_args args = {0 }; +struct xfs_da_args args = {NULL };int error =0 ; sx = container_of(context, struct xfs_scrub_xattr, context);
@@ -420,7 +420,7 @@ intxfs_scrub_xattr ( struct xfs_scrub_context *sc) { -struct xfs_scrub_xattr sx = {0 }; +struct xfs_scrub_xattr sx = { {NULL } };struct attrlist_cursor_kern cursor = {0 };xfs_dablk_t last_checked =-1U ;int error =0 ;
fs/xfs/scrub/bmap.c +1 -1
@@ -229,7 +229,7 @@ xfs_scrub_bmap( int whichfork) {struct xfs_bmbt_irec irec; -struct xfs_scrub_bmap_info info = {0 }; +struct xfs_scrub_bmap_info info = {NULL };struct xfs_mount *mp = sc->mp;struct xfs_inode *ip = sc->ip;struct xfs_ifork *ifp;
fs/xfs/scrub/btree.c +1 -1
@@ -414,7 +414,7 @@ xfs_scrub_btree(struct xfs_owner_info *oinfo, void *private) { - struct xfs_scrub_btree bs = {0}; + struct xfs_scrub_btree bs = { NULL };union xfs_btree_ptr ptr;union xfs_btree_ptr *pp;union xfs_btree_rec *recp;
fs/xfs/scrub/dir.c +1 -1
@@ -560,7 +560,7 @@ xfs_scrub_directory_free_bestfree(struct xfs_buf *dbp;struct xfs_buf *bp;__be16 *bestp; -__be16 best; +__u16 best;unsigned int stale =0 ;int i;int error;
fs/xfs/scrub/scrub.c +1 -1
@@ -123,7 +123,7 @@* structure state to decide (in broad terms) if scrub/repair are * supported by the running kernel. */ -int +static int xfs_scrub_probe (struct xfs_scrub_context *sc) {
Signature · 1 line
2.14.2
Re: [PATCH 2/8] xfs: trivial sparse fixes for the new scrub code
Quoted 23 lines · Christoph Hellwig
Signed-off-by Christoph Hellwig <[email protected]>--- fs/xfs/scrub/attr.c | 4 ++-- fs/xfs/scrub/bmap.c | 2 +- fs/xfs/scrub/btree.c | 2 +- fs/xfs/scrub/dir.c | 2 +- fs/xfs/scrub/scrub.c | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-)fs/xfs/scrub/attr.c +1
-1@@ -91,7 +91,7 @@ xfs_scrub_xattr_listent( int valuelen) {struct xfs_scrub_xattr *sx; -struct xfs_da_args args = {0 }; +struct xfs_da_args args = {NULL };int error =0 ; sx = container_of(context, struct xfs_scrub_xattr, context);
fs/xfs/scrub/attr.c int · line 423
Quoted 5 lines
fs/xfs/scrub/attr.c +1
-1@@ -420,7 +420,7 @@ intxfs_scrub_xattr ( struct xfs_scrub_context *sc) { -struct xfs_scrub_xattr sx = {0 }; +struct xfs_scrub_xattr sx = { {NULL } };
gcc 5.4 (Ubuntu 16.04) complains about a missing initializer for sx.sc here. Seeing as we memset it immediately afterwards, I'll just remove the whole init thing.
--D
Quoted 62 lines
fs/xfs/scrub/attr.c +0
-0struct attrlist_cursor_kern cursor = {0 };xfs_dablk_t last_checked =-1U ;int error =0 ;fs/xfs/scrub/bmap.c +1
-1@@ -229,7 +229,7 @@ xfs_scrub_bmap( int whichfork) {struct xfs_bmbt_irec irec; -struct xfs_scrub_bmap_info info = {0 }; +struct xfs_scrub_bmap_info info = {NULL };struct xfs_mount *mp = sc->mp;struct xfs_inode *ip = sc->ip;struct xfs_ifork *ifp;fs/xfs/scrub/btree.c +1
-1@@ -414,7 +414,7 @@ xfs_scrub_btree(struct xfs_owner_info *oinfo, void *private) { - struct xfs_scrub_btree bs = {0}; + struct xfs_scrub_btree bs = { NULL };union xfs_btree_ptr ptr;union xfs_btree_ptr *pp;union xfs_btree_rec *recp;fs/xfs/scrub/dir.c +1
-1@@ -560,7 +560,7 @@ xfs_scrub_directory_free_bestfree(struct xfs_buf *dbp;struct xfs_buf *bp;__be16 *bestp; -__be16 best; +__u16 best;unsigned int stale =0 ;int i;int error;fs/xfs/scrub/scrub.c +1
-1@@ -123,7 +123,7 @@* structure state to decide (in broad terms) if scrub/repair are * supported by the running kernel. */ -int +static int xfs_scrub_probe (struct xfs_scrub_context *sc) {Signature · 6 lines
2.14.2 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 3/8 xfs: mark xfs_errortag_ktype static
In reply to Christoph Hellwig--- fs/xfs/xfs_error.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_error.c +1 -1
@@ -203,7 +203,7 @@ static struct attribute *xfs_errortag_attrs[] = { NULL, }; -struct kobj_type xfs_errortag_ktype = { +static struct kobj_type xfs_errortag_ktype = { .release = xfs_sysfs_release, .sysfs_ops = &xfs_errortag_sysfs_ops, .default_attrs = xfs_errortag_attrs,
Signature · 1 line
2.14.2
Re: [PATCH 3/8] xfs: mark xfs_errortag_ktype static
Quoted 1 line · Christoph Hellwig
Signed-off-by Christoph Hellwig <[email protected]>
Looks ok,
Quoted 24 lines
--- fs/xfs/xfs_error.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/xfs/xfs_error.c +1
-1@@ -203,7 +203,7 @@ static struct attribute *xfs_errortag_attrs[] = { NULL, }; -struct kobj_type xfs_errortag_ktype = { +static struct kobj_type xfs_errortag_ktype = { .release = xfs_sysfs_release, .sysfs_ops = &xfs_errortag_sysfs_ops, .default_attrs = xfs_errortag_attrs,Signature · 6 lines
2.14.2 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 4/8 xfs: remove unused debug counts for xfs_lock_inodes
In reply to Christoph Hellwig--- fs/xfs/xfs_inode.c | 21 --------------------- 1 file changed, 21 deletions(-)
fs/xfs/xfs_inode.c +0 -21
@@ -385,14 +385,6 @@ xfs_isilocked( }#endif -#ifdef DEBUG -int xfs_locked_n; -int xfs_small_retries; -int xfs_middle_retries; -int xfs_lots_retries; -int xfs_lock_delays; -#endif -/* * xfs_lockdep_subclass_ok() is only used in an ASSERT, so is only called when * DEBUG or XFS_WARN is set. And MAX_LOCKDEP_SUBCLASSES is then only defined
@@ -545,24 +537,11 @@ xfs_lock_inodes(if ((attempts %5 ) ==0 ) {delay (1 );/* Don't just spin the CPU */ -#ifdef DEBUG - xfs_lock_delays++; -#endif } i =0 ; try_lock =0 ; goto again; } - -#ifdef DEBUG -if (attempts) { -if (attempts <5 ) xfs_small_retries++; -else if (attempts <100 ) xfs_middle_retries++; -else xfs_lots_retries++; - }else { - xfs_locked_n++; - } -#endif }/*
Signature · 1 line
2.14.2
Re: [PATCH 4/8] xfs: remove unused debug counts for xfs_lock_inodes
Quoted 1 line · Christoph Hellwig
Signed-off-by Christoph Hellwig <[email protected]>
Looks ok,
Quoted 55 lines
--- fs/xfs/xfs_inode.c | 21 --------------------- 1 file changed, 21 deletions(-)fs/xfs/xfs_inode.c +0
-21@@ -385,14 +385,6 @@ xfs_isilocked( }#endif -#ifdef DEBUG -int xfs_locked_n; -int xfs_small_retries; -int xfs_middle_retries; -int xfs_lots_retries; -int xfs_lock_delays; -#endif -/* * xfs_lockdep_subclass_ok() is only used in an ASSERT, so is only called when * DEBUG or XFS_WARN is set. And MAX_LOCKDEP_SUBCLASSES is then only defined @@ -545,24 +537,11 @@ xfs_lock_inodes(if ((attempts %5 ) ==0 ) {delay (1 );/* Don't just spin the CPU */ -#ifdef DEBUG - xfs_lock_delays++; -#endif } i =0 ; try_lock =0 ; goto again; } - -#ifdef DEBUG -if (attempts) { -if (attempts <5 ) xfs_small_retries++; -else if (attempts <100 ) xfs_middle_retries++; -else xfs_lots_retries++; - }else { - xfs_locked_n++; - } -#endif }/* Signature · 6 lines
2.14.2 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 5/8 xfs: remove unreachable error injection code in xfs_qm_dqget
In reply to Christoph Hellwig--- fs/xfs/xfs_dquot.c | 17 ----------------- 1 file changed, 17 deletions(-)
fs/xfs/xfs_dquot.c +0 -17
@@ -53,13 +53,6 @@* otherwise by the lowest id first, see xfs_dqlock2. */ -#ifdef DEBUG -xfs_buftarg_t *xfs_dqerror_target; -int xfs_do_dqerror; -int xfs_dqreq_num; -int xfs_dqerror_mod =33 ; -#endif -struct kmem_zone *xfs_qm_dqtrxzone;static struct kmem_zone *xfs_qm_dqzone;
@@ -770,15 +763,6 @@ xfs_qm_dqget(return -ESRCH ; } -#ifdef DEBUG -if (xfs_do_dqerror) { -if ((xfs_dqerror_target == mp->m_ddev_targp) && - (xfs_dqreq_num++ % xfs_dqerror_mod) ==0 ) { -xfs_debug (mp,"Returning error in dqget" ); -return -EIO ; - } - } -ASSERT (type ==XFS_DQ_USER || type ==XFS_DQ_PROJ || type ==XFS_DQ_GROUP );
@@ -786,7 +770,6 @@ xfs_qm_dqget(ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL ));ASSERT (xfs_inode_dquot (ip, type) ==NULL ); } -#endif restart:mutex_lock (&qi->qi_tree_lock);
Signature · 1 line
2.14.2
Re: [PATCH 5/8] xfs: remove unreachable error injection code in xfs_qm_dqget
Quoted 1 line · Christoph Hellwig
Signed-off-by Christoph Hellwig <[email protected]>
Looks ok,
Quoted 53 lines
--- fs/xfs/xfs_dquot.c | 17 ----------------- 1 file changed, 17 deletions(-)fs/xfs/xfs_dquot.c +0
-17@@ -53,13 +53,6 @@* otherwise by the lowest id first, see xfs_dqlock2. */ -#ifdef DEBUG -xfs_buftarg_t *xfs_dqerror_target; -int xfs_do_dqerror; -int xfs_dqreq_num; -int xfs_dqerror_mod =33 ; -#endif -struct kmem_zone *xfs_qm_dqtrxzone;static struct kmem_zone *xfs_qm_dqzone;@@ -770,15 +763,6 @@ xfs_qm_dqget(return -ESRCH ; } -#ifdef DEBUG -if (xfs_do_dqerror) { -if ((xfs_dqerror_target == mp->m_ddev_targp) && - (xfs_dqreq_num++ % xfs_dqerror_mod) ==0 ) { -xfs_debug (mp,"Returning error in dqget" ); -return -EIO ; - } - } -ASSERT (type ==XFS_DQ_USER || type ==XFS_DQ_PROJ || type ==XFS_DQ_GROUP );@@ -786,7 +770,6 @@ xfs_qm_dqget(ASSERT (xfs_isilocked (ip,XFS_ILOCK_EXCL ));ASSERT (xfs_inode_dquot (ip, type) ==NULL ); } -#endif restart:mutex_lock (&qi->qi_tree_lock);Signature · 6 lines
2.14.2 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 6/8 xfs: mark xfs_btree_check_lblock and xfs_btree_check_ptr static
In reply to Christoph Hellwig--- fs/xfs/libxfs/xfs_btree.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/xfs/libxfs/xfs_btree.c +2 -2
@@ -109,7 +109,7 @@ __xfs_btree_check_lblock( }/* Check a long btree block header. */ -int +static int xfs_btree_check_lblock( struct xfs_btree_cur *cur, struct xfs_btree_block *block,
@@ -239,7 +239,7 @@ xfs_btree_check_sptr(* Check that a given (indexed) btree pointer at a certain level of a * btree is valid and doesn't point past where it should. */ -int +static int xfs_btree_check_ptr( struct xfs_btree_cur *cur, union xfs_btree_ptr *ptr,
Signature · 1 line
2.14.2
Re: [PATCH 6/8] xfs: mark xfs_btree_check_lblock and xfs_btree_check_ptr static
Quoted 1 line · Christoph Hellwig
Signed-off-by Christoph Hellwig <[email protected]>
Looks ok,
Quoted 33 lines
--- fs/xfs/libxfs/xfs_btree.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)fs/xfs/libxfs/xfs_btree.c +2
-2@@ -109,7 +109,7 @@ __xfs_btree_check_lblock( }/* Check a long btree block header. */ -int +static int xfs_btree_check_lblock( struct xfs_btree_cur *cur, struct xfs_btree_block *block,@@ -239,7 +239,7 @@ xfs_btree_check_sptr(* Check that a given (indexed) btree pointer at a certain level of a * btree is valid and doesn't point past where it should. */ -int +static int xfs_btree_check_ptr( struct xfs_btree_cur *cur, union xfs_btree_ptr *ptr,Signature · 6 lines
2.14.2 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 7/8 xfs: mark xlog_recover_check_summary STATIC
In reply to Christoph HellwigWe already did it in the forward declaration, but not for the function body itself.
--- fs/xfs/xfs_log_recover.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_log_recover.c +1 -1
@@ -5825,7 +5825,7 @@ xlog_recover_cancel(* Read all of the agf and agi counters and check that they * are consistent with the superblock counters. */ -void +STATIC voidxlog_recover_check_summary (struct xlog *log) {
Signature · 1 line
2.14.2
Re: [PATCH 7/8] xfs: mark xlog_recover_check_summary STATIC
Quoted 4 lines · Christoph Hellwig
We already did it in the forward declaration, but not for the function body itself.
Signed-off-by Christoph Hellwig <[email protected]>
Looks ok,
Quoted 24 lines
--- fs/xfs/xfs_log_recover.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/xfs/xfs_log_recover.c +1
-1@@ -5825,7 +5825,7 @@ xlog_recover_cancel(* Read all of the agf and agi counters and check that they * are consistent with the superblock counters. */ -void +STATIC voidxlog_recover_check_summary (struct xlog *log) {Signature · 6 lines
2.14.2 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH 8/8 xfs: mark xlog_verify_dest_ptr STATIC
In reply to Christoph HellwigWe already did it in the forward declaration, but not for the function body itself.
--- fs/xfs/xfs_log.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/xfs/xfs_log.c +1 -1
@@ -3763,7 +3763,7 @@ xlog_ticket_alloc(* one of the iclogs. This uses backup pointers stored in a different * part of the log in case we trash the log structure. */ -void +STATIC voidxlog_verify_dest_ptr (struct xlog *log,void *ptr)
Signature · 1 line
2.14.2
Re: [PATCH 8/8] xfs: mark xlog_verify_dest_ptr STATIC
Quoted 4 lines · Christoph Hellwig
We already did it in the forward declaration, but not for the function body itself.
Signed-off-by Christoph Hellwig <[email protected]>
Looks ok,
Quoted 24 lines
--- fs/xfs/xfs_log.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/xfs/xfs_log.c +1
-1@@ -3763,7 +3763,7 @@ xlog_ticket_alloc(* one of the iclogs. This uses backup pointers stored in a different * part of the log in case we trash the log structure. */ -void +STATIC voidxlog_verify_dest_ptr (struct xlog *log,void *ptr)Signature · 6 lines
2.14.2 -- To unsubscribe from this list: send the line "unsubscribe linux-xfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html