All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: kailang@realtek.com
Cc: alsa-devel@alsa-project.org
Subject: sound: patch_realtek: truncating bits
Date: Sun, 28 Mar 2010 16:49:55 +0300	[thread overview]
Message-ID: <20100328134955.GZ5069@bicker> (raw)

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

             reply	other threads:[~2010-03-28 13:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-28 13:49 Dan Carpenter [this message]
2010-03-29  7:25 ` sound: patch_realtek: truncating bits Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100328134955.GZ5069@bicker \
    --to=error27@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=kailang@realtek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.