All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ALSA: usb-audio: fix sign unintended sign extension on left shifts
@ 2019-06-27 16:43 ` Colin King
  0 siblings, 0 replies; 5+ messages in thread
From: Colin King @ 2019-06-27 16:43 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, alsa-devel; +Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

There are a couple of left shifts of unsigned 8 bit values that
first get promoted to signed ints and hence get sign extended
on the shift if the top bit of the 8 bit values are set. Fix
this by casting the 8 bit values to unsigned ints to stop the
unintentional sign extension.

Addresses-Coverity: ("Unintended sign extension")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 sound/usb/mixer_quirks.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c
index 1f6011f36bb0..199fa157a411 100644
--- a/sound/usb/mixer_quirks.c
+++ b/sound/usb/mixer_quirks.c
@@ -741,7 +741,7 @@ static int snd_ni_control_init_val(struct usb_mixer_interface *mixer,
 		return err;
 	}
 
-	kctl->private_value |= (value << 24);
+	kctl->private_value |= ((unsigned int)value << 24);
 	return 0;
 }
 
@@ -902,7 +902,7 @@ static int snd_ftu_eff_switch_init(struct usb_mixer_interface *mixer,
 	if (err < 0)
 		return err;
 
-	kctl->private_value |= value[0] << 24;
+	kctl->private_value |= (unsigned int)value[0] << 24;
 	return 0;
 }
 
-- 
2.20.1


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

* [PATCH] ALSA: usb-audio: fix sign unintended sign extension on left shifts
@ 2019-06-27 16:43 ` Colin King
  0 siblings, 0 replies; 5+ messages in thread
From: Colin King @ 2019-06-27 16:43 UTC (permalink / raw)
  To: Jaroslav Kysela, Takashi Iwai, alsa-devel; +Cc: kernel-janitors, linux-kernel

From: Colin Ian King <colin.king@canonical.com>

There are a couple of left shifts of unsigned 8 bit values that
first get promoted to signed ints and hence get sign extended
on the shift if the top bit of the 8 bit values are set. Fix
this by casting the 8 bit values to unsigned ints to stop the
unintentional sign extension.

Addresses-Coverity: ("Unintended sign extension")
Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 sound/usb/mixer_quirks.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/sound/usb/mixer_quirks.c b/sound/usb/mixer_quirks.c
index 1f6011f36bb0..199fa157a411 100644
--- a/sound/usb/mixer_quirks.c
+++ b/sound/usb/mixer_quirks.c
@@ -741,7 +741,7 @@ static int snd_ni_control_init_val(struct usb_mixer_interface *mixer,
 		return err;
 	}
 
-	kctl->private_value |= (value << 24);
+	kctl->private_value |= ((unsigned int)value << 24);
 	return 0;
 }
 
@@ -902,7 +902,7 @@ static int snd_ftu_eff_switch_init(struct usb_mixer_interface *mixer,
 	if (err < 0)
 		return err;
 
-	kctl->private_value |= value[0] << 24;
+	kctl->private_value |= (unsigned int)value[0] << 24;
 	return 0;
 }
 
-- 
2.20.1

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

* Re: [PATCH] ALSA: usb-audio: fix sign unintended sign extension on left shifts
  2019-06-27 16:43 ` Colin King
  (?)
@ 2019-06-28  8:37   ` Takashi Iwai
  -1 siblings, 0 replies; 5+ messages in thread
From: Takashi Iwai @ 2019-06-28  8:37 UTC (permalink / raw)
  To: Colin King; +Cc: alsa-devel, Jaroslav Kysela, kernel-janitors, linux-kernel

On Thu, 27 Jun 2019 18:43:08 +0200,
Colin King wrote:
> 
> From: Colin Ian King <colin.king@canonical.com>
> 
> There are a couple of left shifts of unsigned 8 bit values that
> first get promoted to signed ints and hence get sign extended
> on the shift if the top bit of the 8 bit values are set. Fix
> this by casting the 8 bit values to unsigned ints to stop the
> unintentional sign extension.
> 
> Addresses-Coverity: ("Unintended sign extension")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Applied now.  Thanks.


Takashi

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

* Re: [PATCH] ALSA: usb-audio: fix sign unintended sign extension on left shifts
@ 2019-06-28  8:37   ` Takashi Iwai
  0 siblings, 0 replies; 5+ messages in thread
From: Takashi Iwai @ 2019-06-28  8:37 UTC (permalink / raw)
  To: Colin King; +Cc: alsa-devel, Jaroslav Kysela, kernel-janitors, linux-kernel

On Thu, 27 Jun 2019 18:43:08 +0200,
Colin King wrote:
> 
> From: Colin Ian King <colin.king@canonical.com>
> 
> There are a couple of left shifts of unsigned 8 bit values that
> first get promoted to signed ints and hence get sign extended
> on the shift if the top bit of the 8 bit values are set. Fix
> this by casting the 8 bit values to unsigned ints to stop the
> unintentional sign extension.
> 
> Addresses-Coverity: ("Unintended sign extension")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Applied now.  Thanks.


Takashi

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

* Re: [PATCH] ALSA: usb-audio: fix sign unintended sign extension on left shifts
@ 2019-06-28  8:37   ` Takashi Iwai
  0 siblings, 0 replies; 5+ messages in thread
From: Takashi Iwai @ 2019-06-28  8:37 UTC (permalink / raw)
  To: Colin King; +Cc: alsa-devel, Jaroslav Kysela, kernel-janitors, linux-kernel

On Thu, 27 Jun 2019 18:43:08 +0200,
Colin King wrote:
> 
> From: Colin Ian King <colin.king@canonical.com>
> 
> There are a couple of left shifts of unsigned 8 bit values that
> first get promoted to signed ints and hence get sign extended
> on the shift if the top bit of the 8 bit values are set. Fix
> this by casting the 8 bit values to unsigned ints to stop the
> unintentional sign extension.
> 
> Addresses-Coverity: ("Unintended sign extension")
> Signed-off-by: Colin Ian King <colin.king@canonical.com>

Applied now.  Thanks.


Takashi

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

end of thread, other threads:[~2019-06-28  8:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-27 16:43 [PATCH] ALSA: usb-audio: fix sign unintended sign extension on left shifts Colin King
2019-06-27 16:43 ` Colin King
2019-06-28  8:37 ` Takashi Iwai
2019-06-28  8:37   ` Takashi Iwai
2019-06-28  8:37   ` 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.