Commit 8d4b6900 authored by Julia Lawall's avatar Julia Lawall Committed by Linus Torvalds

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: default avatarJulia Lawall <julia@diku.dk>
Cc: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent b70d3a2c
...@@ -325,8 +325,7 @@ affs_get_block(struct inode *inode, sector_t block, struct buffer_head *bh_resul ...@@ -325,8 +325,7 @@ affs_get_block(struct inode *inode, sector_t block, struct buffer_head *bh_resul
pr_debug("AFFS: get_block(%u, %lu)\n", (u32)inode->i_ino, (unsigned long)block); pr_debug("AFFS: get_block(%u, %lu)\n", (u32)inode->i_ino, (unsigned long)block);
if (block > (sector_t)0x7fffffffUL) BUG_ON(block > (sector_t)0x7fffffffUL);
BUG();
if (block >= AFFS_I(inode)->i_blkcnt) { if (block >= AFFS_I(inode)->i_blkcnt) {
if (block > AFFS_I(inode)->i_blkcnt || !create) 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,8 +492,7 @@ affs_do_readpage_ofs(struct file *file, struct page *page, unsigned from, unsign
u32 tmp; u32 tmp;
pr_debug("AFFS: read_page(%u, %ld, %d, %d)\n", (u32)inode->i_ino, page->index, from, to); pr_debug("AFFS: read_page(%u, %ld, %d, %d)\n", (u32)inode->i_ino, page->index, from, to);
if (from > to || to > PAGE_CACHE_SIZE) BUG_ON(from > to || to > PAGE_CACHE_SIZE);
BUG();
kmap(page); kmap(page);
data = page_address(page); data = page_address(page);
bsize = AFFS_SB(sb)->s_data_blksize; 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,8 +505,7 @@ affs_do_readpage_ofs(struct file *file, struct page *page, unsigned from, unsign
if (IS_ERR(bh)) if (IS_ERR(bh))
return PTR_ERR(bh); return PTR_ERR(bh);
tmp = min(bsize - boff, to - from); tmp = min(bsize - boff, to - from);
if (from + tmp > to || tmp > bsize) BUG_ON(from + tmp > to || tmp > bsize);
BUG();
memcpy(data + from, AFFS_DATA(bh) + boff, tmp); memcpy(data + from, AFFS_DATA(bh) + boff, tmp);
affs_brelse(bh); affs_brelse(bh);
bidx++; bidx++;
...@@ -540,8 +537,7 @@ affs_extent_file_ofs(struct inode *inode, u32 newsize) ...@@ -540,8 +537,7 @@ affs_extent_file_ofs(struct inode *inode, u32 newsize)
if (IS_ERR(bh)) if (IS_ERR(bh))
return PTR_ERR(bh); return PTR_ERR(bh);
tmp = min(bsize - boff, newsize - size); tmp = min(bsize - boff, newsize - size);
if (boff + tmp > bsize || tmp > bsize) BUG_ON(boff + tmp > bsize || tmp > bsize);
BUG();
memset(AFFS_DATA(bh) + boff, 0, tmp); memset(AFFS_DATA(bh) + boff, 0, tmp);
AFFS_DATA_HEAD(bh)->size = cpu_to_be32(be32_to_cpu(AFFS_DATA_HEAD(bh)->size) + tmp); AFFS_DATA_HEAD(bh)->size = cpu_to_be32(be32_to_cpu(AFFS_DATA_HEAD(bh)->size) + tmp);
affs_fix_checksum(sb, bh); affs_fix_checksum(sb, bh);
...@@ -560,8 +556,7 @@ affs_extent_file_ofs(struct inode *inode, u32 newsize) ...@@ -560,8 +556,7 @@ affs_extent_file_ofs(struct inode *inode, u32 newsize)
if (IS_ERR(bh)) if (IS_ERR(bh))
goto out; goto out;
tmp = min(bsize, newsize - size); tmp = min(bsize, newsize - size);
if (tmp > bsize) BUG_ON(tmp > bsize);
BUG();
AFFS_DATA_HEAD(bh)->ptype = cpu_to_be32(T_DATA); AFFS_DATA_HEAD(bh)->ptype = cpu_to_be32(T_DATA);
AFFS_DATA_HEAD(bh)->key = cpu_to_be32(inode->i_ino); AFFS_DATA_HEAD(bh)->key = cpu_to_be32(inode->i_ino);
AFFS_DATA_HEAD(bh)->sequence = cpu_to_be32(bidx); 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,8 +678,7 @@ static int affs_write_end_ofs(struct file *file, struct address_space *mapping,
if (IS_ERR(bh)) if (IS_ERR(bh))
return PTR_ERR(bh); return PTR_ERR(bh);
tmp = min(bsize - boff, to - from); tmp = min(bsize - boff, to - from);
if (boff + tmp > bsize || tmp > bsize) BUG_ON(boff + tmp > bsize || tmp > bsize);
BUG();
memcpy(AFFS_DATA(bh) + boff, data + from, tmp); memcpy(AFFS_DATA(bh) + boff, data + from, tmp);
AFFS_DATA_HEAD(bh)->size = cpu_to_be32(be32_to_cpu(AFFS_DATA_HEAD(bh)->size) + tmp); AFFS_DATA_HEAD(bh)->size = cpu_to_be32(be32_to_cpu(AFFS_DATA_HEAD(bh)->size) + tmp);
affs_fix_checksum(sb, bh); affs_fix_checksum(sb, bh);
...@@ -732,8 +726,7 @@ static int affs_write_end_ofs(struct file *file, struct address_space *mapping, ...@@ -732,8 +726,7 @@ static int affs_write_end_ofs(struct file *file, struct address_space *mapping,
if (IS_ERR(bh)) if (IS_ERR(bh))
goto out; goto out;
tmp = min(bsize, to - from); tmp = min(bsize, to - from);
if (tmp > bsize) BUG_ON(tmp > bsize);
BUG();
memcpy(AFFS_DATA(bh), data + from, tmp); memcpy(AFFS_DATA(bh), data + from, tmp);
if (buffer_new(bh)) { if (buffer_new(bh)) {
AFFS_DATA_HEAD(bh)->ptype = cpu_to_be32(T_DATA); AFFS_DATA_HEAD(bh)->ptype = cpu_to_be32(T_DATA);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment