[alsa-devel] [PATCH] ASoC: Fix warning from strict_strtoul()
Signed-off-by: Mark Brown broonie@opensource.wolfsonmicro.com --- sound/soc/soc-dapm.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 9e83357..456d78a 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -808,7 +808,11 @@ static ssize_t dapm_pop_time_store(struct device *dev, const char *buf, size_t count)
{ - if (strict_strtoul(buf, 10, &pop_time) < 0) + unsigned long val; + + if (strict_strtoul(buf, 10, &val) >= 0) + pop_time = val; + else printk(KERN_ERR "Unable to parse pop_time setting\n");
return count;
At Fri, 4 Jul 2008 16:01:14 +0100, Mark Brown wrote:
Signed-off-by: Mark Brown broonie@opensource.wolfsonmicro.com
Thanks, applied.
(BTW, at the next time, a bit more patch description would be helpful. For example, in this case, it's actually not about warning but the behavior of strict_strtoul() that resets the value, if I understand correctly.)
Takashi
sound/soc/soc-dapm.c | 6 +++++- 1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 9e83357..456d78a 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -808,7 +808,11 @@ static ssize_t dapm_pop_time_store(struct device *dev, const char *buf, size_t count)
{
- if (strict_strtoul(buf, 10, &pop_time) < 0)
unsigned long val;
if (strict_strtoul(buf, 10, &val) >= 0)
pop_time = val;
else printk(KERN_ERR "Unable to parse pop_time setting\n");
return count;
-- 1.5.6
On Fri, Jul 04, 2008 at 05:09:36PM +0200, Takashi Iwai wrote:
(BTW, at the next time, a bit more patch description would be helpful. For example, in this case, it's actually not about warning but the behavior of strict_strtoul() that resets the value, if I understand correctly.)
It is a warning fix - I was passing the wrong type of variable to strict_strtoul(), though on most architectures int and long are the same in memory so the behaviour before and after the change is identical. The fix is to pass a temporary variable of the correct type in and then assign the result to pop_time rather than passing pop_time in directly.
At Fri, 4 Jul 2008 20:57:54 +0100, Mark Brown wrote:
On Fri, Jul 04, 2008 at 05:09:36PM +0200, Takashi Iwai wrote:
(BTW, at the next time, a bit more patch description would be helpful. For example, in this case, it's actually not about warning but the behavior of strict_strtoul() that resets the value, if I understand correctly.)
It is a warning fix - I was passing the wrong type of variable to strict_strtoul(), though on most architectures int and long are the same in memory so the behaviour before and after the change is identical. The fix is to pass a temporary variable of the correct type in and then assign the result to pop_time rather than passing pop_time in directly.
Ah, OK, that I totally missed.
Anyway this also fixes another strange behavior - strict_strtoul() stores 0 when it gets a parse error. So, in the older version, the pop_wait itself is reset to 0 at error while the value is kept in the newer version.
thanks,
Takashi
On Sat, Jul 05, 2008 at 09:43:55AM +0200, Takashi Iwai wrote:
Anyway this also fixes another strange behavior - strict_strtoul() stores 0 when it gets a parse error. So, in the older version, the pop_wait itself is reset to 0 at error while the value is kept in the newer version.
Oh, so it does - how unhelpful (if understandable) of strict_strtoul(). Good job I decided to do this fix rather than changing the type of pop_time :)
participants (2)
-
Mark Brown
-
Takashi Iwai