Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [alsa-devel] [PATCH] xfer-opitons: Fix -Wformat=2 warnings
@ 2019-12-22  2:54 Rosen Penev
  2019-12-24 10:13 ` Takashi Sakamoto
  0 siblings, 1 reply; 2+ messages in thread
From: Rosen Penev @ 2019-12-22  2:54 UTC (permalink / raw)
  To: alsa-devel

Allows the compiler to check types.

format string functions expect constant expressions, not constant
variables.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 axfer/xfer-options.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/axfer/xfer-options.c b/axfer/xfer-options.c
index 3740b16..d4e5ff2 100644
--- a/axfer/xfer-options.c
+++ b/axfer/xfer-options.c
@@ -422,8 +422,6 @@ static int generate_path_with_suffix(struct xfer_context *xfer,
 				     const char *template, unsigned int index,
 				     const char *suffix)
 {
-	static const char *const single_format = "%s%s";
-	static const char *const multiple_format = "%s-%i%s";
 	unsigned int len;
 
 	len = strlen(template) + strlen(suffix) + 1;
@@ -435,10 +433,10 @@ static int generate_path_with_suffix(struct xfer_context *xfer,
 		return -ENOMEM;
 
 	if (xfer->path_count == 1) {
-		snprintf(xfer->paths[index], len, single_format, template,
+		snprintf(xfer->paths[index], len, "%s%s", template,
 			 suffix);
 	} else {
-		snprintf(xfer->paths[index], len, multiple_format, template,
+		snprintf(xfer->paths[index], len, "%s-%i%s", template,
 			 index, suffix);
 	}
 
@@ -449,8 +447,6 @@ static int generate_path_without_suffix(struct xfer_context *xfer,
 				        const char *template,
 					unsigned int index, const char *suffix)
 {
-	static const char *const single_format = "%s";
-	static const char *const multiple_format = "%s-%i";
 	unsigned int len;
 
 	len = strlen(template) + 1;
@@ -462,9 +458,9 @@ static int generate_path_without_suffix(struct xfer_context *xfer,
 		return -ENOMEM;
 
 	if (xfer->path_count == 1) {
-		snprintf(xfer->paths[index], len, single_format, template);
+		snprintf(xfer->paths[index], len, "%s", template);
 	} else {
-		snprintf(xfer->paths[index], len, multiple_format, template,
+		snprintf(xfer->paths[index], len, "%s-%i", template,
 			index);
 	}
 
-- 
2.24.1

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

end of thread, other threads:[~2019-12-24 10:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-12-22  2:54 [alsa-devel] [PATCH] xfer-opitons: Fix -Wformat=2 warnings Rosen Penev
2019-12-24 10:13 ` Takashi Sakamoto

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox