[alsa-devel] [PATCH 1/3 v3] alsa-lib: fixed coverity reported issues under "FORWARD_NULL" checker.

Mark Brown broonie at opensource.wolfsonmicro.com
Mon Apr 4 11:18:23 CEST 2011

On Mon, Apr 04, 2011 at 11:53:57AM +0300, sudarshan.bisht at nokia.com wrote:

> This patch has fix for situations where variable can be NULL 
> but not been checked beforehand.

This description doesn't seem to match the patch...

> -	if (h == NULL)
> +	if (h)
>  		snd_dlclose(h);

This is a coding style change, the two conditions are equivalent.

>  			SNDERR("Invalid type for func %s definition", str);
> +			err = -EINVAL;
>  			goto _err;

This appears to be fixing an uninitialised return value error.

>  			return err;
>  		if (periods == 1)
>  			return -EINVAL;
> -		if (*period_time == 0) {
> +		if (period_time) {
>  			err = INTERNAL(snd_pcm_hw_params_get_period_time)(hw_params, period_time, NULL);
>  			if (err < 0)

This check alters the semantics - rather than checking if *period_time is
non-zero we now check to see if period_time is non-NULL, paying no
attention to the value if the pointer is set.

There was at least one relevant fix in there but lots of the changes are
as above.

More information about the Alsa-devel mailing list