From: Pavel Skripkin Date: Tue, 9 Nov 2021 02:35:25 +0000 (-0800) Subject: sysv: use BUILD_BUG_ON instead of runtime check X-Git-Tag: v6.6.17~8877^2~12 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7eb0e28c1d3147e2234512e2beeb99183ac99f58;p=platform%2Fkernel%2Flinux-rpi.git sysv: use BUILD_BUG_ON instead of runtime check There were runtime checks about sizes of struct v7_super_block and struct sysv_inode. If one of these checks fail the kernel will panic. Since these values are known at compile time let's use BUILD_BUG_ON(), because it's a standard mechanism for validation checking at build time Link: https://lkml.kernel.org/r/20210813123020.22971-1-paskripkin@gmail.com Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Pavel Skripkin Cc: Christoph Hellwig Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/fs/sysv/super.c b/fs/sysv/super.c index cc8e2ed..d1def07 100644 --- a/fs/sysv/super.c +++ b/fs/sysv/super.c @@ -474,10 +474,8 @@ static int v7_fill_super(struct super_block *sb, void *data, int silent) struct sysv_sb_info *sbi; struct buffer_head *bh; - if (440 != sizeof (struct v7_super_block)) - panic("V7 FS: bad super-block size"); - if (64 != sizeof (struct sysv_inode)) - panic("sysv fs: bad i-node size"); + BUILD_BUG_ON(sizeof(struct v7_super_block) != 440); + BUILD_BUG_ON(sizeof(struct sysv_inode) != 64); sbi = kzalloc(sizeof(struct sysv_sb_info), GFP_KERNEL); if (!sbi)