DPDK patches and discussions
 help / color / mirror / Atom feed
From: Thomas Monjalon <thomas@monjalon.net>
To: dev@dpdk.org
Cc: Olivier Matz <olivier.matz@6wind.com>
Subject: [dpdk-dev] [PATCH 20.05 14/15] replace printf format attributes
Date: Mon, 10 Feb 2020 17:20:31 +0100	[thread overview]
Message-ID: <20200210162032.1177478-15-thomas@monjalon.net> (raw)
In-Reply-To: <20200210162032.1177478-1-thomas@monjalon.net>

The new macro __rte_format_printf, for compiler hinting,
is now used where appropriate for consistency.

Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
 lib/librte_cmdline/cmdline.h                | 3 ++-
 lib/librte_eal/common/include/rte_common.h  | 8 +++++++-
 lib/librte_eal/common/include/rte_debug.h   | 2 +-
 lib/librte_eal/common/include/rte_devargs.h | 2 +-
 lib/librte_eal/common/include/rte_log.h     | 4 ++--
 5 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/lib/librte_cmdline/cmdline.h b/lib/librte_cmdline/cmdline.h
index 27d2effdf7..190fc3d165 100644
--- a/lib/librte_cmdline/cmdline.h
+++ b/lib/librte_cmdline/cmdline.h
@@ -8,6 +8,7 @@
 #define _CMDLINE_H_
 
 #include <termios.h>
+#include <rte_common.h>
 #include <cmdline_rdline.h>
 #include <cmdline_parse.h>
 
@@ -34,7 +35,7 @@ struct cmdline *cmdline_new(cmdline_parse_ctx_t *ctx, const char *prompt, int s_
 void cmdline_set_prompt(struct cmdline *cl, const char *prompt);
 void cmdline_free(struct cmdline *cl);
 void cmdline_printf(const struct cmdline *cl, const char *fmt, ...)
-	__attribute__((format(printf,2,3)));
+	__rte_format_printf(2, 3);
 int cmdline_in(struct cmdline *cl, const char *buf, int size);
 int cmdline_write_char(struct rdline *rdl, char c);
 
diff --git a/lib/librte_eal/common/include/rte_common.h b/lib/librte_eal/common/include/rte_common.h
index 575183e944..3e14ffc136 100644
--- a/lib/librte_eal/common/include/rte_common.h
+++ b/lib/librte_eal/common/include/rte_common.h
@@ -94,6 +94,12 @@ typedef uint16_t unaligned_uint16_t;
  */
 #define RTE_SET_USED(x) (void)(x)
 
+/**
+ * Hint type checking for printf-style arguments.
+ */
+#define __rte_format_printf(fmt_idx, args_idx) \
+	__attribute__((format(printf, fmt_idx, args_idx)))
+
 #define RTE_PRIORITY_LOG 101
 #define RTE_PRIORITY_BUS 110
 #define RTE_PRIORITY_CLASS 120
@@ -803,7 +809,7 @@ rte_str_to_size(const char *str)
  */
 __rte_noreturn void
 rte_exit(int exit_code, const char *format, ...)
-	__attribute__((format(printf, 2, 3)));
+	__rte_format_printf(2, 3);
 
 #ifdef __cplusplus
 }
diff --git a/lib/librte_eal/common/include/rte_debug.h b/lib/librte_eal/common/include/rte_debug.h
index eb06c835f7..50052c5a90 100644
--- a/lib/librte_eal/common/include/rte_debug.h
+++ b/lib/librte_eal/common/include/rte_debug.h
@@ -73,7 +73,7 @@ void __rte_panic(const char *funcname , const char *format, ...)
 #endif
 #endif
 	__rte_noreturn
-	__attribute__((format(printf, 2, 3)));
+	__rte_format_printf(2, 3);
 
 #ifdef __cplusplus
 }
diff --git a/lib/librte_eal/common/include/rte_devargs.h b/lib/librte_eal/common/include/rte_devargs.h
index 882dfa0abd..898efa0d66 100644
--- a/lib/librte_eal/common/include/rte_devargs.h
+++ b/lib/librte_eal/common/include/rte_devargs.h
@@ -137,7 +137,7 @@ rte_devargs_parse(struct rte_devargs *da, const char *dev);
 int
 rte_devargs_parsef(struct rte_devargs *da,
 		   const char *format, ...)
-__attribute__((format(printf, 2, 0)));
+__rte_format_printf(2, 0);
 
 /**
  * Insert an rte_devargs in the global list.
diff --git a/lib/librte_eal/common/include/rte_log.h b/lib/librte_eal/common/include/rte_log.h
index f2a5bc18ea..f292444966 100644
--- a/lib/librte_eal/common/include/rte_log.h
+++ b/lib/librte_eal/common/include/rte_log.h
@@ -282,7 +282,7 @@ int rte_log(uint32_t level, uint32_t logtype, const char *format, ...)
 	__rte_cold
 #endif
 #endif
-	__attribute__((format(printf, 3, 4)));
+	__rte_format_printf(3, 4);
 
 /**
  * Generates a log message.
@@ -311,7 +311,7 @@ int rte_log(uint32_t level, uint32_t logtype, const char *format, ...)
  *   - Negative on error.
  */
 int rte_vlog(uint32_t level, uint32_t logtype, const char *format, va_list ap)
-	__attribute__((format(printf,3,0)));
+	__rte_format_printf(3, 0);
 
 /**
  * Generates a log message.
-- 
2.25.0


  parent reply	other threads:[~2020-02-10 16:24 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-10 16:20 [dpdk-dev] [PATCH 20.05 00/15] clean-up use of __attribute__ Thomas Monjalon
2020-02-10 16:20 ` [dpdk-dev] [PATCH 20.05 01/15] app/bbdev: replace constructor syntax with common macro Thomas Monjalon
2020-02-10 21:06   ` Chautru, Nicolas
2020-02-10 16:20 ` [dpdk-dev] [PATCH 20.05 02/15] net/mlx5: replace destructor " Thomas Monjalon
2020-02-10 16:20 ` [dpdk-dev] [PATCH 20.05 03/15] net/memif: use common macros for cache line marker Thomas Monjalon
2020-02-10 16:20 ` [dpdk-dev] [PATCH 20.05 04/15] common/mlx5: replace alignas keyword Thomas Monjalon
2020-02-10 16:20 ` [dpdk-dev] [PATCH 20.05 05/15] replace alignment attributes Thomas Monjalon
2020-02-10 19:11   ` David Christensen
2020-02-10 16:20 ` [dpdk-dev] [PATCH 20.05 06/15] replace packed attributes Thomas Monjalon
2020-02-10 16:20 ` [dpdk-dev] [PATCH 20.05 07/15] replace always-inline attributes Thomas Monjalon
2020-02-10 16:20 ` [dpdk-dev] [PATCH 20.05 08/15] replace no-inline attributes Thomas Monjalon
2020-02-10 16:20 ` [dpdk-dev] [PATCH 20.05 09/15] replace unused attributes Thomas Monjalon
2020-02-10 16:20 ` [dpdk-dev] [PATCH 20.05 10/15] replace used attributes Thomas Monjalon
2020-02-10 16:20 ` [dpdk-dev] [PATCH 20.05 11/15] replace hot attributes Thomas Monjalon
2020-02-10 16:20 ` [dpdk-dev] [PATCH 20.05 12/15] replace cold attributes Thomas Monjalon
2020-02-10 19:14   ` David Christensen
2020-02-10 16:20 ` [dpdk-dev] [PATCH 20.05 13/15] replace no-return attributes Thomas Monjalon
2020-02-10 16:20 ` Thomas Monjalon [this message]
2020-02-10 16:20 ` [dpdk-dev] [PATCH 20.05 15/15] devtools: check use of compiler attributes Thomas Monjalon
2020-04-16 16:34 ` [dpdk-dev] [PATCH 20.05 00/15] clean-up use of __attribute__ Thomas Monjalon

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=20200210162032.1177478-15-thomas@monjalon.net \
    --to=thomas@monjalon.net \
    --cc=dev@dpdk.org \
    --cc=olivier.matz@6wind.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).