All of lore.kernel.org
 help / color / mirror / Atom feed
* sound: patch_realtek: truncating bits
@ 2010-03-28 13:49 Dan Carpenter
  2010-03-29  7:25 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2010-03-28 13:49 UTC (permalink / raw)
  To: kailang; +Cc: alsa-devel

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@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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-03-29  7:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-28 13:49 sound: patch_realtek: truncating bits Dan Carpenter
2010-03-29  7:25 ` Takashi Iwai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.