aboutsummaryrefslogtreecommitdiffstats
path: root/fs/affs/file.c
diff options
context:
space:
mode:
authorJulia Lawall <julia@diku.dk>2008-04-29 03:59:12 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-29 11:06:02 -0400
commit8d4b69002e56e93f1cfe8bb863846ecde3990032 (patch)
tree0cd18b3bebad5db8e20bd7d760513a9b980235be /fs/affs/file.c
parentb70d3a2c596fb52b02488ad4aef13fa0d602090c (diff)
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>
Diffstat (limited to 'fs/affs/file.c')
-rw-r--r--fs/affs/file.c21
1 files changed, 7 insertions, 14 deletions
diff --git a/fs/affs/file.c b/fs/affs/file.c
index 6e0c9399200e..e87ede608f77 100644
--- a/fs/affs/file.c
+++ b/fs/affs/file.c
@@ -325,8 +325,7 @@ affs_get_block(struct inode *inode, sector_t block, struct buffer_head *bh_resul
325 pr_debug("AFFS: get_block(%u, %lu)\n", (u32)inode->i_ino, (unsigned long)block); 325 pr_debug("AFFS: get_block(%u, %lu)\n", (u32)inode->i_ino, (unsigned long)block);
326 326
327 327
328 if (block > (sector_t)0x7fffffffUL) 328 BUG_ON(block > (sector_t)0x7fffffffUL);
329 BUG();
330 329
331 if (block >= AFFS_I(inode)->i_blkcnt) { 330 if (block >= AFFS_I(inode)->i_blkcnt) {
332 if (block > AFFS_I(inode)->i_blkcnt || !create) 331 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
493 u32 tmp; 492 u32 tmp;
494 493
495 pr_debug("AFFS: read_page(%u, %ld, %d, %d)\n", (u32)inode->i_ino, page->index, from, to); 494 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) 495 BUG_ON(from > to || to > PAGE_CACHE_SIZE);
497 BUG();
498 kmap(page); 496 kmap(page);
499 data = page_address(page); 497 data = page_address(page);
500 bsize = AFFS_SB(sb)->s_data_blksize; 498 bsize = AFFS_SB(sb)->s_data_blksize;
@@ -507,8 +505,7 @@ affs_do_readpage_ofs(struct file *file, struct page *page, unsigned from, unsign
507 if (IS_ERR(bh)) 505 if (IS_ERR(bh))
508 return PTR_ERR(bh); 506 return PTR_ERR(bh);
509 tmp = min(bsize - boff, to - from); 507 tmp = min(bsize - boff, to - from);
510 if (from + tmp > to || tmp > bsize) 508 BUG_ON(from + tmp > to || tmp > bsize);
511 BUG();
512 memcpy(data + from, AFFS_DATA(bh) + boff, tmp); 509 memcpy(data + from, AFFS_DATA(bh) + boff, tmp);
513 affs_brelse(bh); 510 affs_brelse(bh);
514 bidx++; 511 bidx++;
@@ -540,8 +537,7 @@ affs_extent_file_ofs(struct inode *inode, u32 newsize)
540 if (IS_ERR(bh)) 537 if (IS_ERR(bh))
541 return PTR_ERR(bh); 538 return PTR_ERR(bh);
542 tmp = min(bsize - boff, newsize - size); 539 tmp = min(bsize - boff, newsize - size);
543 if (boff + tmp > bsize || tmp > bsize) 540 BUG_ON(boff + tmp > bsize || tmp > bsize);
544 BUG();
545 memset(AFFS_DATA(bh) + boff, 0, tmp); 541 memset(AFFS_DATA(bh) + boff, 0, tmp);
546 AFFS_DATA_HEAD(bh)->size = cpu_to_be32(be32_to_cpu(AFFS_DATA_HEAD(bh)->size) + tmp); 542 AFFS_DATA_HEAD(bh)->size = cpu_to_be32(be32_to_cpu(AFFS_DATA_HEAD(bh)->size) + tmp);
547 affs_fix_checksum(sb, bh); 543 affs_fix_checksum(sb, bh);
@@ -560,8 +556,7 @@ affs_extent_file_ofs(struct inode *inode, u32 newsize)
560 if (IS_ERR(bh)) 556 if (IS_ERR(bh))
561 goto out; 557 goto out;
562 tmp = min(bsize, newsize - size); 558 tmp = min(bsize, newsize - size);
563 if (tmp > bsize) 559 BUG_ON(tmp > bsize);
564 BUG();
565 AFFS_DATA_HEAD(bh)->ptype = cpu_to_be32(T_DATA); 560 AFFS_DATA_HEAD(bh)->ptype = cpu_to_be32(T_DATA);
566 AFFS_DATA_HEAD(bh)->key = cpu_to_be32(inode->i_ino); 561 AFFS_DATA_HEAD(bh)->key = cpu_to_be32(inode->i_ino);
567 AFFS_DATA_HEAD(bh)->sequence = cpu_to_be32(bidx); 562 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,
683 if (IS_ERR(bh)) 678 if (IS_ERR(bh))
684 return PTR_ERR(bh); 679 return PTR_ERR(bh);
685 tmp = min(bsize - boff, to - from); 680 tmp = min(bsize - boff, to - from);
686 if (boff + tmp > bsize || tmp > bsize) 681 BUG_ON(boff + tmp > bsize || tmp > bsize);
687 BUG();
688 memcpy(AFFS_DATA(bh) + boff, data + from, tmp); 682 memcpy(AFFS_DATA(bh) + boff, data + from, tmp);
689 AFFS_DATA_HEAD(bh)->size = cpu_to_be32(be32_to_cpu(AFFS_DATA_HEAD(bh)->size) + tmp); 683 AFFS_DATA_HEAD(bh)->size = cpu_to_be32(be32_to_cpu(AFFS_DATA_HEAD(bh)->size) + tmp);
690 affs_fix_checksum(sb, bh); 684 affs_fix_checksum(sb, bh);
@@ -732,8 +726,7 @@ static int affs_write_end_ofs(struct file *file, struct address_space *mapping,
732 if (IS_ERR(bh)) 726 if (IS_ERR(bh))
733 goto out; 727 goto out;
734 tmp = min(bsize, to - from); 728 tmp = min(bsize, to - from);
735 if (tmp > bsize) 729 BUG_ON(tmp > bsize);
736 BUG();
737 memcpy(AFFS_DATA(bh), data + from, tmp); 730 memcpy(AFFS_DATA(bh), data + from, tmp);
738 if (buffer_new(bh)) { 731 if (buffer_new(bh)) {
739 AFFS_DATA_HEAD(bh)->ptype = cpu_to_be32(T_DATA); 732 AFFS_DATA_HEAD(bh)->ptype = cpu_to_be32(T_DATA);