ALSA: sound: Move dereference after NULL test and drop unnecessary NULL tests
authorJulia Lawall <julia@diku.dk>
Sat, 17 Oct 2009 06:33:22 +0000 (08:33 +0200)
committerTakashi Iwai <tiwai@suse.de>
Fri, 30 Oct 2009 11:01:27 +0000 (12:01 +0100)
commit4b3be6afa4ab8b3fdce39df68bad71f8b85164de
tree9022bd2b563fabc987e31277782076db42946bb7
parentb71207e9dc044b30d8b5d7f1c2290ba14563f05c
ALSA: sound: Move dereference after NULL test and drop unnecessary NULL tests

In pcm.c, if the NULL test on pcm is needed, then the dereference should be
after the NULL test.

In dummy.c and ali5451.c, the context of the calls to
snd_card_dummy_new_mixer and snd_ali_free_voice show that dummy and pvoice,
respectively cannot be NULL.

A simplified version of the semantic match that detects this problem is as
follows (http://coccinelle.lip6.fr/):

// <smpl>
@match exists@
expression x, E;
identifier fld;
@@

* x->fld
  ... when != \(x = E\|&x\)
* x == NULL
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/core/pcm.c
sound/drivers/dummy.c
sound/pci/ali5451/ali5451.c