Skip to content

Commit 8d4b690

Browse files
Julia Lawalltorvalds
authored andcommitted
fs/affs/file.c: use BUG_ON
if (...) BUG(); should be replaced with BUG_ON(...) when the test has no side-effects to allow a definition of BUG_ON that drops the code completely. The semantic patch that makes this change is as follows: (http://www.emn.fr/x-info/coccinelle/) // <smpl> @ disable unlikely @ expression E,f; @@ ( if (<... f(...) ...>) { BUG(); } | - if (unlikely(E)) { BUG(); } + BUG_ON(E); ) @@ expression E,f; @@ ( if (<... f(...) ...>) { BUG(); } | - if (E) { BUG(); } + BUG_ON(E); ) // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk> Cc: Roman Zippel <zippel@linux-m68k.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent b70d3a2 commit 8d4b690

1 file changed

Lines changed: 7 additions & 14 deletions

File tree

‎fs/affs/file.c‎

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,7 @@ affs_get_block(struct inode *inode, sector_t block, struct buffer_head *bh_resul
325325
pr_debug("AFFS: get_block(%u, %lu)\n", (u32)inode->i_ino, (unsigned long)block);
326326

327327

328-
if (block > (sector_t)0x7fffffffUL)
329-
BUG();
328+
BUG_ON(block > (sector_t)0x7fffffffUL);
330329

331330
if (block >= AFFS_I(inode)->i_blkcnt) {
332331
if (block > AFFS_I(inode)->i_blkcnt || !create)
@@ -493,8 +492,7 @@ affs_do_readpage_ofs(struct file *file, struct page *page, unsigned from, unsign
493492
u32 tmp;
494493

495494
pr_debug("AFFS: read_page(%u, %ld, %d, %d)\n", (u32)inode->i_ino, page->index, from, to);
496-
if (from > to || to > PAGE_CACHE_SIZE)
497-
BUG();
495+
BUG_ON(from > to || to > PAGE_CACHE_SIZE);
498496
kmap(page);
499497
data = page_address(page);
500498
bsize = AFFS_SB(sb)->s_data_blksize;
@@ -507,8 +505,7 @@ affs_do_readpage_ofs(struct file *file, struct page *page, unsigned from, unsign
507505
if (IS_ERR(bh))
508506
return PTR_ERR(bh);
509507
tmp = min(bsize - boff, to - from);
510-
if (from + tmp > to || tmp > bsize)
511-
BUG();
508+
BUG_ON(from + tmp > to || tmp > bsize);
512509
memcpy(data + from, AFFS_DATA(bh) + boff, tmp);
513510
affs_brelse(bh);
514511
bidx++;
@@ -540,8 +537,7 @@ affs_extent_file_ofs(struct inode *inode, u32 newsize)
540537
if (IS_ERR(bh))
541538
return PTR_ERR(bh);
542539
tmp = min(bsize - boff, newsize - size);
543-
if (boff + tmp > bsize || tmp > bsize)
544-
BUG();
540+
BUG_ON(boff + tmp > bsize || tmp > bsize);
545541
memset(AFFS_DATA(bh) + boff, 0, tmp);
546542
AFFS_DATA_HEAD(bh)->size = cpu_to_be32(be32_to_cpu(AFFS_DATA_HEAD(bh)->size) + tmp);
547543
affs_fix_checksum(sb, bh);
@@ -560,8 +556,7 @@ affs_extent_file_ofs(struct inode *inode, u32 newsize)
560556
if (IS_ERR(bh))
561557
goto out;
562558
tmp = min(bsize, newsize - size);
563-
if (tmp > bsize)
564-
BUG();
559+
BUG_ON(tmp > bsize);
565560
AFFS_DATA_HEAD(bh)->ptype = cpu_to_be32(T_DATA);
566561
AFFS_DATA_HEAD(bh)->key = cpu_to_be32(inode->i_ino);
567562
AFFS_DATA_HEAD(bh)->sequence = cpu_to_be32(bidx);
@@ -683,8 +678,7 @@ static int affs_write_end_ofs(struct file *file, struct address_space *mapping,
683678
if (IS_ERR(bh))
684679
return PTR_ERR(bh);
685680
tmp = min(bsize - boff, to - from);
686-
if (boff + tmp > bsize || tmp > bsize)
687-
BUG();
681+
BUG_ON(boff + tmp > bsize || tmp > bsize);
688682
memcpy(AFFS_DATA(bh) + boff, data + from, tmp);
689683
AFFS_DATA_HEAD(bh)->size = cpu_to_be32(be32_to_cpu(AFFS_DATA_HEAD(bh)->size) + tmp);
690684
affs_fix_checksum(sb, bh);
@@ -732,8 +726,7 @@ static int affs_write_end_ofs(struct file *file, struct address_space *mapping,
732726
if (IS_ERR(bh))
733727
goto out;
734728
tmp = min(bsize, to - from);
735-
if (tmp > bsize)
736-
BUG();
729+
BUG_ON(tmp > bsize);
737730
memcpy(AFFS_DATA(bh), data + from, tmp);
738731
if (buffer_new(bh)) {
739732
AFFS_DATA_HEAD(bh)->ptype = cpu_to_be32(T_DATA);

0 commit comments

Comments
 (0)