All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sound:pci:Change return type of function, shift_bits in xonar_dg.c to avoid overflow
@ 2015-03-12  4:35 Nicholas Krause
  2015-03-12  6:33 ` [PATCH] sound:pci:Change return type of function,shift_bits " Takashi Iwai
  2015-03-12  7:49 ` [PATCH] sound:pci:Change return type of function, shift_bits " Clemens Ladisch
  0 siblings, 2 replies; 3+ messages in thread
From: Nicholas Krause @ 2015-03-12  4:35 UTC (permalink / raw)
  To: clemens; +Cc: tiwai, alsa-devel, linux-kernel

This changes the return type of the function,shift_bits to unsigned
long in order to avoid overflowing issues with this function when
called as found when running sparse on the kernel source tree.

Signed-off-by: Nicholas Krause <xerofoify@gmail.com>
---
 sound/pci/oxygen/xonar_dg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/pci/oxygen/xonar_dg.c b/sound/pci/oxygen/xonar_dg.c
index 4cf3200..2337a76 100644
--- a/sound/pci/oxygen/xonar_dg.c
+++ b/sound/pci/oxygen/xonar_dg.c
@@ -238,7 +238,7 @@ void set_cs4245_adc_params(struct oxygen *chip,
 	cs4245_write_spi(chip, CS4245_MCLK_FREQ);
 }
 
-static inline unsigned int shift_bits(unsigned int value,
+static inline unsigned long shift_bits(unsigned int value,
 				      unsigned int shift_from,
 				      unsigned int shift_to,
 				      unsigned int mask)
-- 
2.1.0

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

* Re: [PATCH] sound:pci:Change return type of function,shift_bits in xonar_dg.c to avoid overflow
  2015-03-12  4:35 [PATCH] sound:pci:Change return type of function, shift_bits in xonar_dg.c to avoid overflow Nicholas Krause
@ 2015-03-12  6:33 ` Takashi Iwai
  2015-03-12  7:49 ` [PATCH] sound:pci:Change return type of function, shift_bits " Clemens Ladisch
  1 sibling, 0 replies; 3+ messages in thread
From: Takashi Iwai @ 2015-03-12  6:33 UTC (permalink / raw)
  To: Nicholas Krause; +Cc: clemens, perex, alsa-devel, linux-kernel

At Thu, 12 Mar 2015 00:35:46 -0400,
Nicholas Krause wrote:
> 
> This changes the return type of the function,shift_bits to unsigned
> long in order to avoid overflowing issues with this function when
> called as found when running sparse on the kernel source tree.

What overflows exactly?  Did you follow the code?


thanks,

Takashi

> 
> Signed-off-by: Nicholas Krause <xerofoify@gmail.com>
> ---
>  sound/pci/oxygen/xonar_dg.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/sound/pci/oxygen/xonar_dg.c b/sound/pci/oxygen/xonar_dg.c
> index 4cf3200..2337a76 100644
> --- a/sound/pci/oxygen/xonar_dg.c
> +++ b/sound/pci/oxygen/xonar_dg.c
> @@ -238,7 +238,7 @@ void set_cs4245_adc_params(struct oxygen *chip,
>  	cs4245_write_spi(chip, CS4245_MCLK_FREQ);
>  }
>  
> -static inline unsigned int shift_bits(unsigned int value,
> +static inline unsigned long shift_bits(unsigned int value,
>  				      unsigned int shift_from,
>  				      unsigned int shift_to,
>  				      unsigned int mask)
> -- 
> 2.1.0
> 

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

* Re: [PATCH] sound:pci:Change return type of function, shift_bits in xonar_dg.c to avoid overflow
  2015-03-12  4:35 [PATCH] sound:pci:Change return type of function, shift_bits in xonar_dg.c to avoid overflow Nicholas Krause
  2015-03-12  6:33 ` [PATCH] sound:pci:Change return type of function,shift_bits " Takashi Iwai
@ 2015-03-12  7:49 ` Clemens Ladisch
  1 sibling, 0 replies; 3+ messages in thread
From: Clemens Ladisch @ 2015-03-12  7:49 UTC (permalink / raw)
  To: Nicholas Krause; +Cc: tiwai, alsa-devel

Nicholas Krause wrote:
> This changes the return type of the function,shift_bits to unsigned
> long in order to avoid overflowing issues with this function when
> called as found when running sparse on the kernel source tree.

sparse is just a tool to help finding problems.  The goal is not to do
something to shut it up, but the remove the actual problem.

In this case, if the return type of shift_bits() were a problem, you
would have just moved the problem to its caller where the value is
then returned as unsigned int anyway.

Stop spamming us with patches for code that you do not understand.


Regards,
Clemens

> Signed-off-by: Nicholas Krause <xerofoify@gmail.com>
> ---
>  sound/pci/oxygen/xonar_dg.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/sound/pci/oxygen/xonar_dg.c b/sound/pci/oxygen/xonar_dg.c
> index 4cf3200..2337a76 100644
> --- a/sound/pci/oxygen/xonar_dg.c
> +++ b/sound/pci/oxygen/xonar_dg.c
> @@ -238,7 +238,7 @@ void set_cs4245_adc_params(struct oxygen *chip,
>  	cs4245_write_spi(chip, CS4245_MCLK_FREQ);
>  }
>
> -static inline unsigned int shift_bits(unsigned int value,
> +static inline unsigned long shift_bits(unsigned int value,
>  				      unsigned int shift_from,
>  				      unsigned int shift_to,
>  				      unsigned int mask)

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

end of thread, other threads:[~2015-03-12  7:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-12  4:35 [PATCH] sound:pci:Change return type of function, shift_bits in xonar_dg.c to avoid overflow Nicholas Krause
2015-03-12  6:33 ` [PATCH] sound:pci:Change return type of function,shift_bits " Takashi Iwai
2015-03-12  7:49 ` [PATCH] sound:pci:Change return type of function, shift_bits " Clemens Ladisch

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.