Skip to contentSkip to conversation

ASoC: Fix warning from strict_strtoul()

PATCH Applied Mark Brown 2 participants 5 messages Jul 4, 2008 – Jul 5, 2008

Subsystems (2)
lore
Share & tools
lore

Mark Brown

author
#0 lore raw

PATCH 1/1 ASoC: Fix warning from strict_strtoul()

---
 sound/soc/soc-dapm.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
sound/soc/soc-dapm.c +5 -1
index 9e83357..456d78a 100644
@@ -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;
Signature · 1 line
1.5.6
Applied
#1 lore raw

At Fri, 4 Jul 2008 16:01:14 +0100,

Quoted 2 lines · Mark Brown

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

Quoted 24 lines
---
 sound/soc/soc-dapm.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
sound/soc/soc-dapm.c +5 -1
index 9e83357..456d78a 100644
@@ -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;
Signature · 1 line
1.5.6
author
#2 lore raw
Quoted 4 lines · Takashi Iwai

(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.

#3 lore raw

At Fri, 4 Jul 2008 20:57:54 +0100,

Quoted 7 lines · Mark Brown
Quoted 4 lines · Takashi Iwai

(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.)

Quoted 5 lines

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

author
#4 lore raw
Quoted 4 lines · Takashi Iwai

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 :)