[hatari-devel] change in crossbar.c

Eero Tamminen eerot at users.berlios.de
Thu Feb 18 23:55:14 CET 2010


Hi,

On Friday 19 February 2010, npomarede at corp.free.fr wrote:
> Hello eero, I see you modified crossbar.c :
>
>   		switch (crossbar.codecInputSource) {
> -			case 0:
> -				/* No sound */
> -				dac_LeftData  = 0;
> -				dac_RightData = 0;
> -				break;
>   			case 1:
>   				/* direct ADC->DAC sound only */
>   				dac_LeftData = adc_leftData;
> @@ -1715,6 +1710,11 @@
>   					dac_RightData = adc_rightData;
>   				}
>   				break;
> +			default:
> +				/* No sound */
> +				dac_LeftData  = 0;
> +				dac_RightData = 0;
> +				break;
>
>
> But in order to explicitly keep the original values 0,1,2 and 3 of
> laurent's code, I think it might be better to keep "case 0"

"case 0:" could also be added before "default:".  That keeps
the old intention and fixes the warning.


> and add for example ;
>
>          Sint16 adc_leftData, adc_rightData, dac_LeftData=0,
> dac_RightData=0;

I think this is less clear and my guess would be that compiler can
optimize:
	case 0:
	default:
better?

Even clearer would be to use a bitfield, but at least with my gcc
version that didn't get rid of the warning.


> Because if the compiler doesn't know valid values are only 0-3, if
> someone looks at the code, it's not clear what the default case is doing
> now (without looking at other parts of the code to see what values could
> be take by codecInputSource and that default now means "0")
>
> More generally, I'm not sure it's a good idea to correct someone else's
> code while he's working on it ; there're might be some compilers warning
> during that time, but we can discuss them later on the list and see how
> to remove them before we do an official release.

Usually I mail Laurent patches, but the warning had been there for quite
a while and the fix "seemed" obvious...


	- Eero



More information about the hatari-devel mailing list