Skip to content

Commit

Permalink
sound: Use BUG_ON
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
  • Loading branch information
Julia Lawall authored and Takashi Iwai committed Apr 24, 2008
1 parent 0ccb541 commit 21ac1f9
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions sound/oss/trident.c
Original file line number Diff line number Diff line change
Expand Up @@ -3076,8 +3076,7 @@ ali_ac97_get(struct trident_card *card, int secondary, u8 reg)
u16 wcontrol;
unsigned long flags;

if (!card)
BUG();
BUG_ON(!card);

address = ALI_AC97_READ;
if (card->revision == ALI_5451_V02) {
Expand Down Expand Up @@ -3148,8 +3147,7 @@ ali_ac97_set(struct trident_card *card, int secondary, u8 reg, u16 val)

data = ((u32) val) << 16;

if (!card)
BUG();
BUG_ON(!card);

address = ALI_AC97_WRITE;
mask = ALI_AC97_WRITE_ACTION | ALI_AC97_AUDIO_BUSY;
Expand Down Expand Up @@ -3213,8 +3211,7 @@ ali_ac97_read(struct ac97_codec *codec, u8 reg)
struct trident_card *card = NULL;

/* Added by Matt Wu */
if (!codec)
BUG();
BUG_ON(!codec);

card = (struct trident_card *) codec->private_data;

Expand All @@ -3240,8 +3237,7 @@ ali_ac97_write(struct ac97_codec *codec, u8 reg, u16 val)
struct trident_card *card;

/* Added by Matt Wu */
if (!codec)
BUG();
BUG_ON(!codec);

card = (struct trident_card *) codec->private_data;

Expand Down

0 comments on commit 21ac1f9

Please sign in to comment.