Skip to content

Commit 7eb0e28

Browse files
pskrgagtorvalds
authored andcommitted
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 <paskripkin@gmail.com> Cc: Christoph Hellwig <hch@lst.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent ba1f70d commit 7eb0e28

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

fs/sysv/super.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -474,10 +474,8 @@ static int v7_fill_super(struct super_block *sb, void *data, int silent)
474474
struct sysv_sb_info *sbi;
475475
struct buffer_head *bh;
476476

477-
if (440 != sizeof (struct v7_super_block))
478-
panic("V7 FS: bad super-block size");
479-
if (64 != sizeof (struct sysv_inode))
480-
panic("sysv fs: bad i-node size");
477+
BUILD_BUG_ON(sizeof(struct v7_super_block) != 440);
478+
BUILD_BUG_ON(sizeof(struct sysv_inode) != 64);
481479

482480
sbi = kzalloc(sizeof(struct sysv_sb_info), GFP_KERNEL);
483481
if (!sbi)

0 commit comments

Comments
 (0)