Commit a0f7bfd3429fc48f4d1aa5364b9428d75798ba04
Committed by
Felix Blyakher
1 parent
eb00457d62
Exists in
master
and in
7 other branches
fs/xfs: Correct redundant test
bp was tested for NULL a few lines before, followed by a return, and there is no intervening modification of its value. A simplified version of the semantic match that finds this problem is as follows: (http://www.emn.fr/x-info/coccinelle/) // <smpl> @r exists@ local idexpression x; expression E; position p1,p2; @@ if (x == NULL || ...) { ... when forall return ...; } ... when != \(x=E\|x--\|x++\|--x\|++x\|x-=E\|x+=E\|x|=E\|x&=E\|&x\) ( *x == NULL | *x != NULL ) // </smpl> Signed-off-by: Julia Lawall <julia@diku.dk> Acked-by: Felix Blyakher <felixb@sgi.com> Signed-off-by: Felix Blyakher <felixb@sgi.com>
Showing 1 changed file with 2 additions and 2 deletions Side-by-side Diff
fs/xfs/xfs_trans_buf.c
... | ... | @@ -307,7 +307,7 @@ |
307 | 307 | return (flags & XFS_BUF_TRYLOCK) ? |
308 | 308 | EAGAIN : XFS_ERROR(ENOMEM); |
309 | 309 | |
310 | - if ((bp != NULL) && (XFS_BUF_GETERROR(bp) != 0)) { | |
310 | + if (XFS_BUF_GETERROR(bp) != 0) { | |
311 | 311 | xfs_ioerror_alert("xfs_trans_read_buf", mp, |
312 | 312 | bp, blkno); |
313 | 313 | error = XFS_BUF_GETERROR(bp); |
... | ... | @@ -315,7 +315,7 @@ |
315 | 315 | return error; |
316 | 316 | } |
317 | 317 | #ifdef DEBUG |
318 | - if (xfs_do_error && (bp != NULL)) { | |
318 | + if (xfs_do_error) { | |
319 | 319 | if (xfs_error_target == target) { |
320 | 320 | if (((xfs_req_num++) % xfs_error_mod) == 0) { |
321 | 321 | xfs_buf_relse(bp); |