Skip to contentSkip to conversation

dev_info() argument in sound/soc/soc_dapm.c

PATCH Takashi Iwai 2 participants 3 messages Dec 22, 2010

Subsystems (2)
lore
Share & tools
lore

Takashi Iwai

author Applied
#0 lore raw

Hi,

my build tests caught a warning regarding the conversion to dev_info() in soc-dapm.c. dev_info() is printf style, thus you shouldn't pass the expanded string to the format argument.

I applied the following patch to topic/asoc branch.

thanks,

Takashi

===

Quoted 1 line

From 9d01df063e70260d6c0aabd58dd5507db151aa51 Mon Sep 17 00:00:00 2001

From: Takashi Iwai <[email protected]>
Date: Wed, 22 Dec 2010 14:08:40 +0100
Subject: [PATCH] ASoC: don't pass the string as the format arguemtn for dev_info()

---
 sound/soc/soc-dapm.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
sound/soc/soc-dapm.c +1 -1
index 50f5c78..499730a 100644
@@ -110,7 +110,7 @@ static void pop_dbg(struct device *dev, u32 pop_time, const char *fmt, ...)
 
 	va_start(args, fmt);
 	vsnprintf(buf, PAGE_SIZE, fmt, args);
-	dev_info(dev, buf);
+	dev_info(dev, "%s", buf);
 	va_end(args);
 
 	kfree(buf);
Signature · 1 line
1.7.3.4
#1 lore raw
Quoted 8 lines · On Wed, 22 Dec 2010 15:06:44 +0100 Takashi Iwai <[email protected]> wrote:

Hi,

my build tests caught a warning regarding the conversion to dev_info() in soc-dapm.c. dev_info() is printf style, thus you shouldn't pass the expanded string to the format argument.

I applied the following patch to topic/asoc branch.

...

sound/soc/soc-dapm.c static void pop_dbg(struct device *dev, u32 pop_time, const char *fmt, ...) · line 115

Quoted 10 lines
sound/soc/soc-dapm.c +1 -1
@@ -110,7 +110,7 @@ static void pop_dbg(struct device *dev, u32 pop_time, const char *fmt, ...)
 
 	va_start(args, fmt);
 	vsnprintf(buf, PAGE_SIZE, fmt, args);
-	dev_info(dev, buf);
+	dev_info(dev, "%s", buf);
 	va_end(args);
 

Thanks! I guess this is safer as the buf here should contain only the characters to be printed.

Signature · 1 line
Jarkko
#2 lore raw

At Wed, 22 Dec 2010 16:42:01 +0200,

Quoted 18 lines · Jarkko Nikula
Quoted 8 lines · On Wed, 22 Dec 2010 15:06:44 +0100 Takashi Iwai <[email protected]> wrote:

Hi,

my build tests caught a warning regarding the conversion to dev_info() in soc-dapm.c. dev_info() is printf style, thus you shouldn't pass the expanded string to the format argument.

I applied the following patch to topic/asoc branch.

...

Quoted 4 lines
sound/soc/soc-dapm.c +0 -0
@@ -110,7 +110,7 @@ static void pop_dbg(struct device *dev, u32 pop_time, const char *fmt, ...)
 
Quoted 8 lines

sound/soc/soc-dapm.c static void pop_dbg(struct device *dev, u32 pop_time, const char *fmt, ...) · line 115

Quoted 6 lines
sound/soc/soc-dapm.c +1 -1
 	va_start(args, fmt);
 	vsnprintf(buf, PAGE_SIZE, fmt, args);
-	dev_info(dev, buf);
+	dev_info(dev, "%s", buf);
 	va_end(args);
 

Thanks! I guess this is safer as the buf here should contain only the characters to be printed.

Yes, the problem is when the expanded string contains '%' letter. In the worse case, it Oopses :)

Takashi