[alsa-devel] sound: patch_realtek: truncating bits

Dan Carpenter error27 at gmail.com
Sun Mar 28 15:49:55 CEST 2010


Smatch complains that we are truncating bits here:

sound/pci/hda/patch_realtek.c +12459 alc268_aspire_one_speaker_automute(6) 
	warn: value 28800 can't fit into 255 'bits'
sound/pci/hda/patch_realtek.c +13482 alc269_quanta_fl1_speaker_automute(6)
	warn: value 28800 can't fit into 255 'bits'
sound/pci/hda/patch_realtek.c +13511 alc269_lifebook_speaker_automute(11)
	warn: value 28800 can't fit into 255 'bits'
sound/pci/hda/patch_realtek.c +13646 alc269_speaker_automute(8)
	warn: value 28800 can't fit into 255 'bits'

The code looks like this:
 13643          unsigned char bits;
 13644  
 13645          present = snd_hda_jack_detect(codec, nid);
 13646          bits = present ? AMP_IN_MUTE(0) : 0;

"bits" is declared as an unsigned char but AMP_IN_MUTE(0) is 0x7080 so
we are only using the last 0x80.

I couldn't figure out if it was intended.  This was first introduced by
this commit which change "bits" from unsigned int to unsigned char.

commit 60db6b53fb43421beb2ff3fe3e63412bf81620aa
Author: Kailang Yang <kailang at realtek.com>
Date:   Tue Aug 26 13:13:00 2008 +0200

    ALSA: hda - Add support of Quanta FL1
    
    Added the support of Quanta FL1 with ALC269 code chip.
    Also a bit space clean-ups.
    
If this is intentional, it would be cleaner to explicitly cast or mask
away the bits we don't care about.

regards,
dan carpenter


More information about the Alsa-devel mailing list