Skip to contentSkip to conversation

xfs: Convert to use the preferred fallthrough macro

PATCH NAK Miaohe Lin 2 participants 2 messages Aug 20, 2020 XFS filesystem

lore
Share & tools
lore

Miaohe Lin

author
#0 lore raw

PATCH 1/1 xfs: Convert to use the preferred fallthrough macro

Convert the uses of fallthrough comments to fallthrough macro. Please see commit 294f69e662d1 ("compiler_attributes.h: Add 'fallthrough' pseudo keyword for switch/case use") for detail.

---
 fs/xfs/libxfs/xfs_ag_resv.c  | 4 ++--
 fs/xfs/libxfs/xfs_da_btree.c | 2 +-
 fs/xfs/scrub/bmap.c          | 2 +-
 fs/xfs/scrub/btree.c         | 2 +-
 fs/xfs/scrub/common.c        | 6 +++---
 fs/xfs/scrub/dabtree.c       | 2 +-
 fs/xfs/scrub/repair.c        | 2 +-
 fs/xfs/xfs_bmap_util.c       | 2 +-
 fs/xfs/xfs_file.c            | 2 +-
 fs/xfs/xfs_fsmap.c           | 2 +-
 fs/xfs/xfs_ioctl.c           | 2 +-
 fs/xfs/xfs_trans_buf.c       | 2 +-
 12 files changed, 15 insertions(+), 15 deletions(-)
fs/xfs/libxfs/xfs_ag_resv.c +2 -2
index fdfe6dc0d307..0b061a027e4e 100644
@@ -338,7 +338,7 @@ xfs_ag_resv_alloc_extent(
 		break;
 	default:
 		ASSERT(0);
-		/* fall through */
+		fallthrough;
 	case XFS_AG_RESV_NONE:
 		field = args->wasdel ? XFS_TRANS_SB_RES_FDBLOCKS :
 				       XFS_TRANS_SB_FDBLOCKS;
@@ -380,7 +380,7 @@ xfs_ag_resv_free_extent(
 		break;
 	default:
 		ASSERT(0);
-		/* fall through */
+		fallthrough;
 	case XFS_AG_RESV_NONE:
 		xfs_trans_mod_sb(tp, XFS_TRANS_SB_FDBLOCKS, (int64_t)len);
 		return;
fs/xfs/libxfs/xfs_da_btree.c +1 -1
index e46bc03365db..5a13bfe0ebbf 100644
@@ -282,7 +282,7 @@ xfs_da3_node_read_verify(
 						__this_address);
 				break;
 			}
-			/* fall through */
+			fallthrough;
 		case XFS_DA_NODE_MAGIC:
 			fa = xfs_da3_node_verify(bp);
 			if (fa)
fs/xfs/scrub/bmap.c +1 -1
index 955302e7cdde..6abd469d49d2 100644
@@ -270,7 +270,7 @@ xchk_bmap_iextent_xref(
 	case XFS_DATA_FORK:
 		if (xfs_is_reflink_inode(info->sc->ip))
 			break;
-		/* fall through */
+		fallthrough;
 	case XFS_ATTR_FORK:
 		xchk_xref_is_not_shared(info->sc, agbno,
 				irec->br_blockcount);
fs/xfs/scrub/btree.c +1 -1
index f52a7b8256f9..990a379fc322 100644
@@ -43,7 +43,7 @@ __xchk_btree_process_error(
 		/* Note the badness but don't abort. */
 		sc->sm->sm_flags |= errflag;
 		*error = 0;
-		/* fall through */
+		fallthrough;
 	default:
 		if (cur->bc_flags & XFS_BTREE_ROOT_IN_INODE)
 			trace_xchk_ifork_btree_op_error(sc, cur, level,
fs/xfs/scrub/common.c +3 -3
index 18876056e5e0..63f13c8ed8c7 100644
@@ -81,7 +81,7 @@ __xchk_process_error(
 		/* Note the badness but don't abort. */
 		sc->sm->sm_flags |= errflag;
 		*error = 0;
-		/* fall through */
+		fallthrough;
 	default:
 		trace_xchk_op_error(sc, agno, bno, *error,
 				ret_ip);
@@ -134,7 +134,7 @@ __xchk_fblock_process_error(
 		/* Note the badness but don't abort. */
 		sc->sm->sm_flags |= errflag;
 		*error = 0;
-		/* fall through */
+		fallthrough;
 	default:
 		trace_xchk_file_op_error(sc, whichfork, offset, *error,
 				ret_ip);
@@ -713,7 +713,7 @@ xchk_get_inode(
 		if (error)
 			return -ENOENT;
 		error = -EFSCORRUPTED;
-		/* fall through */
+		fallthrough;
 	default:
 		trace_xchk_op_error(sc,
 				XFS_INO_TO_AGNO(mp, sc->sm->sm_ino),
fs/xfs/scrub/dabtree.c +1 -1
index e56786f0a13c..2b3fb0b37e18 100644
@@ -47,7 +47,7 @@ xchk_da_process_error(
 		/* Note the badness but don't abort. */
 		sc->sm->sm_flags |= XFS_SCRUB_OFLAG_CORRUPT;
 		*error = 0;
-		/* fall through */
+		fallthrough;
 	default:
 		trace_xchk_file_op_error(sc, ds->dargs.whichfork,
 				xfs_dir2_da_to_db(ds->dargs.geo,
fs/xfs/scrub/repair.c +1 -1
index 25e86c71e7b9..c814b18efba9 100644
@@ -944,7 +944,7 @@ xrep_ino_dqattach(
 			xrep_force_quotacheck(sc, XFS_DQTYPE_GROUP);
 		if (XFS_IS_PQUOTA_ON(sc->mp) && !sc->ip->i_pdquot)
 			xrep_force_quotacheck(sc, XFS_DQTYPE_PROJ);
-		/* fall through */
+		fallthrough;
 	case -ESRCH:
 		error = 0;
 		break;
fs/xfs/xfs_bmap_util.c +1 -1
index 73cafc843cd7..6045cc20b0fb 100644
@@ -244,7 +244,7 @@ xfs_bmap_count_blocks(
 		 */
 		*count += btblocks - 1;
 
-		/* fall through */
+		fallthrough;
 	case XFS_DINODE_FMT_EXTENTS:
 		*nextents = xfs_bmap_count_leaves(ifp, count);
 		break;
fs/xfs/xfs_file.c +1 -1
index c31cd3be9fb2..976306724093 100644
@@ -772,7 +772,7 @@ xfs_break_layouts(
 			error = xfs_break_dax_layouts(inode, &retry);
 			if (error || retry)
 				break;
-			/* fall through */
+			fallthrough;
 		case BREAK_WRITE:
 			error = xfs_break_leased_layouts(inode, iolock, &retry);
 			break;
fs/xfs/xfs_fsmap.c +1 -1
index 4eebcec4aae6..c334550aeea7 100644
@@ -100,7 +100,7 @@ xfs_fsmap_owner_to_rmap(
 		dest->rm_owner = XFS_RMAP_OWN_COW;
 		break;
 	case XFS_FMR_OWN_DEFECTIVE:	/* not implemented */
-		/* fall through */
+		fallthrough;
 	default:
 		return -EINVAL;
 	}
fs/xfs/xfs_ioctl.c +1 -1
index 6f22a66777cd..85d6631f7e99 100644
@@ -557,7 +557,7 @@ xfs_ioc_attrmulti_one(
 	case ATTR_OP_REMOVE:
 		value = NULL;
 		*len = 0;
-		/* fall through */
+		fallthrough;
 	case ATTR_OP_SET:
 		error = mnt_want_write_file(parfilp);
 		if (error)
fs/xfs/xfs_trans_buf.c +1 -1
index 11cd666cd99a..86ba71580ffd 100644
@@ -310,7 +310,7 @@ xfs_trans_read_buf_map(
 	default:
 		if (tp && (tp->t_flags & XFS_TRANS_DIRTY))
 			xfs_force_shutdown(tp->t_mountp, SHUTDOWN_META_IO_ERROR);
-		/* fall through */
+		fallthrough;
 	case -ENOMEM:
 	case -EAGAIN:
 		return error;
Signature · 1 line
2.19.1
#1 lore raw
Quoted 6 lines · Miaohe Lin

Convert the uses of fallthrough comments to fallthrough macro. Please see commit 294f69e662d1 ("compiler_attributes.h: Add 'fallthrough' pseudo keyword for switch/case use") for detail.

NAK.

From the /previous/ attempt[0] to shovel in this compliance bullshit[1] that will do nothing but increase the cost of rebasing developers' trees, I'll just wait until "...the C17/C18 [[fallthrough]] syntax is more commonly supported by C compilers, static analyzers, and IDEs, [and] switch to using that syntax". Then I only have to accept the cost of this *once*.

If you feel really passionate about ramming a bunch of pointless churn into the kernel tree to make my life more painful, send this to Linus and let him make the change.

--D

[0] https://lore.kernel.org/linux-xfs/20200707200504.GA4796@embeddedor/

[1] https://www.kernel.org/doc/html/latest/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through

Quoted 201 lines
---
 fs/xfs/libxfs/xfs_ag_resv.c  | 4 ++--
 fs/xfs/libxfs/xfs_da_btree.c | 2 +-
 fs/xfs/scrub/bmap.c          | 2 +-
 fs/xfs/scrub/btree.c         | 2 +-
 fs/xfs/scrub/common.c        | 6 +++---
 fs/xfs/scrub/dabtree.c       | 2 +-
 fs/xfs/scrub/repair.c        | 2 +-
 fs/xfs/xfs_bmap_util.c       | 2 +-
 fs/xfs/xfs_file.c            | 2 +-
 fs/xfs/xfs_fsmap.c           | 2 +-
 fs/xfs/xfs_ioctl.c           | 2 +-
 fs/xfs/xfs_trans_buf.c       | 2 +-
 12 files changed, 15 insertions(+), 15 deletions(-)
fs/xfs/libxfs/xfs_ag_resv.c +2 -2
index fdfe6dc0d307..0b061a027e4e 100644
@@ -338,7 +338,7 @@ xfs_ag_resv_alloc_extent(
 		break;
 	default:
 		ASSERT(0);
-		/* fall through */
+		fallthrough;
 	case XFS_AG_RESV_NONE:
 		field = args->wasdel ? XFS_TRANS_SB_RES_FDBLOCKS :
 				       XFS_TRANS_SB_FDBLOCKS;
@@ -380,7 +380,7 @@ xfs_ag_resv_free_extent(
 		break;
 	default:
 		ASSERT(0);
-		/* fall through */
+		fallthrough;
 	case XFS_AG_RESV_NONE:
 		xfs_trans_mod_sb(tp, XFS_TRANS_SB_FDBLOCKS, (int64_t)len);
 		return;
fs/xfs/libxfs/xfs_da_btree.c +1 -1
index e46bc03365db..5a13bfe0ebbf 100644
@@ -282,7 +282,7 @@ xfs_da3_node_read_verify(
 						__this_address);
 				break;
 			}
-			/* fall through */
+			fallthrough;
 		case XFS_DA_NODE_MAGIC:
 			fa = xfs_da3_node_verify(bp);
 			if (fa)
fs/xfs/scrub/bmap.c +1 -1
index 955302e7cdde..6abd469d49d2 100644
@@ -270,7 +270,7 @@ xchk_bmap_iextent_xref(
 	case XFS_DATA_FORK:
 		if (xfs_is_reflink_inode(info->sc->ip))
 			break;
-		/* fall through */
+		fallthrough;
 	case XFS_ATTR_FORK:
 		xchk_xref_is_not_shared(info->sc, agbno,
 				irec->br_blockcount);
fs/xfs/scrub/btree.c +1 -1
index f52a7b8256f9..990a379fc322 100644
@@ -43,7 +43,7 @@ __xchk_btree_process_error(
 		/* Note the badness but don't abort. */
 		sc->sm->sm_flags |= errflag;
 		*error = 0;
-		/* fall through */
+		fallthrough;
 	default:
 		if (cur->bc_flags & XFS_BTREE_ROOT_IN_INODE)
 			trace_xchk_ifork_btree_op_error(sc, cur, level,
fs/xfs/scrub/common.c +3 -3
index 18876056e5e0..63f13c8ed8c7 100644
@@ -81,7 +81,7 @@ __xchk_process_error(
 		/* Note the badness but don't abort. */
 		sc->sm->sm_flags |= errflag;
 		*error = 0;
-		/* fall through */
+		fallthrough;
 	default:
 		trace_xchk_op_error(sc, agno, bno, *error,
 				ret_ip);
@@ -134,7 +134,7 @@ __xchk_fblock_process_error(
 		/* Note the badness but don't abort. */
 		sc->sm->sm_flags |= errflag;
 		*error = 0;
-		/* fall through */
+		fallthrough;
 	default:
 		trace_xchk_file_op_error(sc, whichfork, offset, *error,
 				ret_ip);
@@ -713,7 +713,7 @@ xchk_get_inode(
 		if (error)
 			return -ENOENT;
 		error = -EFSCORRUPTED;
-		/* fall through */
+		fallthrough;
 	default:
 		trace_xchk_op_error(sc,
 				XFS_INO_TO_AGNO(mp, sc->sm->sm_ino),
fs/xfs/scrub/dabtree.c +1 -1
index e56786f0a13c..2b3fb0b37e18 100644
@@ -47,7 +47,7 @@ xchk_da_process_error(
 		/* Note the badness but don't abort. */
 		sc->sm->sm_flags |= XFS_SCRUB_OFLAG_CORRUPT;
 		*error = 0;
-		/* fall through */
+		fallthrough;
 	default:
 		trace_xchk_file_op_error(sc, ds->dargs.whichfork,
 				xfs_dir2_da_to_db(ds->dargs.geo,
fs/xfs/scrub/repair.c +1 -1
index 25e86c71e7b9..c814b18efba9 100644
@@ -944,7 +944,7 @@ xrep_ino_dqattach(
 			xrep_force_quotacheck(sc, XFS_DQTYPE_GROUP);
 		if (XFS_IS_PQUOTA_ON(sc->mp) && !sc->ip->i_pdquot)
 			xrep_force_quotacheck(sc, XFS_DQTYPE_PROJ);
-		/* fall through */
+		fallthrough;
 	case -ESRCH:
 		error = 0;
 		break;
fs/xfs/xfs_bmap_util.c +1 -1
index 73cafc843cd7..6045cc20b0fb 100644
@@ -244,7 +244,7 @@ xfs_bmap_count_blocks(
 		 */
 		*count += btblocks - 1;
 
-		/* fall through */
+		fallthrough;
 	case XFS_DINODE_FMT_EXTENTS:
 		*nextents = xfs_bmap_count_leaves(ifp, count);
 		break;
fs/xfs/xfs_file.c +1 -1
index c31cd3be9fb2..976306724093 100644
@@ -772,7 +772,7 @@ xfs_break_layouts(
 			error = xfs_break_dax_layouts(inode, &retry);
 			if (error || retry)
 				break;
-			/* fall through */
+			fallthrough;
 		case BREAK_WRITE:
 			error = xfs_break_leased_layouts(inode, iolock, &retry);
 			break;
fs/xfs/xfs_fsmap.c +1 -1
index 4eebcec4aae6..c334550aeea7 100644
@@ -100,7 +100,7 @@ xfs_fsmap_owner_to_rmap(
 		dest->rm_owner = XFS_RMAP_OWN_COW;
 		break;
 	case XFS_FMR_OWN_DEFECTIVE:	/* not implemented */
-		/* fall through */
+		fallthrough;
 	default:
 		return -EINVAL;
 	}
fs/xfs/xfs_ioctl.c +1 -1
index 6f22a66777cd..85d6631f7e99 100644
@@ -557,7 +557,7 @@ xfs_ioc_attrmulti_one(
 	case ATTR_OP_REMOVE:
 		value = NULL;
 		*len = 0;
-		/* fall through */
+		fallthrough;
 	case ATTR_OP_SET:
 		error = mnt_want_write_file(parfilp);
 		if (error)
fs/xfs/xfs_trans_buf.c +1 -1
index 11cd666cd99a..86ba71580ffd 100644
@@ -310,7 +310,7 @@ xfs_trans_read_buf_map(
 	default:
 		if (tp && (tp->t_flags & XFS_TRANS_DIRTY))
 			xfs_force_shutdown(tp->t_mountp, SHUTDOWN_META_IO_ERROR);
-		/* fall through */
+		fallthrough;
 	case -ENOMEM:
 	case -EAGAIN:
 		return error;
Signature · 1 line
2.19.1