All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rosen Penev <rosenp@gmail.com>
To: alsa-devel@alsa-project.org
Subject: [alsa-devel] [PATCH] xfer-opitons: Fix -Wformat=2 warnings
Date: Sat, 21 Dec 2019 18:54:58 -0800	[thread overview]
Message-ID: <20191222025458.745140-1-rosenp@gmail.com> (raw)

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

             reply	other threads:[~2019-12-22  2:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-22  2:54 Rosen Penev [this message]
2019-12-24 10:13 ` [alsa-devel] [PATCH] xfer-opitons: Fix -Wformat=2 warnings Takashi Sakamoto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191222025458.745140-1-rosenp@gmail.com \
    --to=rosenp@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.