Skip to contentSkip to conversation

remove unnecessary null check

PATCH Applied Dan Carpenter 2 participants 2 messages Nov 18, 2009 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 remove unnecessary null check

This function is only called from snd_ctl_ioctl() and the file parameter can never be null so there is no need to check it here.

We dereference file at the start of the function:

        struct snd_card *card = file->card;

and it confuses static checkers to dereference a pointer before checking it.

regards,
dan carpenter

sound/core/control.c +1 -1
@@ -1120,7 +1120,7 @@
 	    	goto __kctl_end;
 	}
 	if (vd->access & SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK) {
-		if (file && vd->owner != NULL && vd->owner != file) {
+		if (vd->owner != NULL && vd->owner != file) {
 			err = -EPERM;
 			goto __kctl_end;
 		}
Applied
#1 lore raw

At Wed, 18 Nov 2009 10:31:57 +0200 (SAST),

Quoted 5 lines · Dan Carpenter

This function is only called from snd_ctl_ioctl() and the file parameter can never be null so there is no need to check it here.

We dereference file at the start of the function:

Quoted 8 lines
        struct snd_card *card = file->card;

and it confuses static checkers to dereference a pointer before checking it.

regards,
dan carpenter

Thanks, applied now.

Takashi

Quoted 13 lines
sound/core/control.c +1 -1
@@ -1120,7 +1120,7 @@
 	    	goto __kctl_end;
 	}
 	if (vd->access & SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK) {
-		if (file && vd->owner != NULL && vd->owner != file) {
+		if (vd->owner != NULL && vd->owner != file) {
 			err = -EPERM;
 			goto __kctl_end;
 		}