summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2016-06-05 12:21:48 +0200
committerThomas Haller <thaller@redhat.com>2016-06-05 12:22:01 +0200
commit348e505b3ae098dab96ac507673da5bd8f3f7018 (patch)
treef6203686f9b8a50f30b5b1acdf0c58de5e2caa1f
parent466bf2f6332e15a447a40e2a92b7f4493502855a (diff)
downloadNetworkManager-348e505b3ae098dab96ac507673da5bd8f3f7018.tar.gz
macros: add macro _nm_printf() for function attribute
-rw-r--r--clients/cli/utils.h2
-rw-r--r--clients/tui/newt/nmt-newt-utils.h4
-rw-r--r--shared/nm-macros-internal.h1
-rw-r--r--src/nm-core-utils.h2
-rw-r--r--src/nm-logging.c2
-rw-r--r--src/nm-logging.h2
-rw-r--r--src/platform/tests/test-common.h2
7 files changed, 8 insertions, 7 deletions
diff --git a/clients/cli/utils.h b/clients/cli/utils.h
index 917a237074..5adbd2be33 100644
--- a/clients/cli/utils.h
+++ b/clients/cli/utils.h
@@ -74,7 +74,7 @@ void nmc_terminal_show_progress (const char *str);
const char *nmc_term_color_sequence (NmcTermColor color);
const char *nmc_term_format_sequence (NmcTermFormat format);
NmcTermColor nmc_term_color_parse_string (const char *str, GError **error);
-char *nmc_colorize (NmCli *nmc, NmcTermColor color, NmcTermFormat format, const char * fmt, ...) __attribute__((__format__ (__printf__, 4, 5)));
+char *nmc_colorize (NmCli *nmc, NmcTermColor color, NmcTermFormat format, const char * fmt, ...) _nm_printf (4, 5);
void nmc_filter_out_colors_inplace (char *str);
char *nmc_filter_out_colors (const char *str);
char *nmc_get_user_input (const char *ask_str);
diff --git a/clients/tui/newt/nmt-newt-utils.h b/clients/tui/newt/nmt-newt-utils.h
index 4cbe8a09a3..430c2ec1db 100644
--- a/clients/tui/newt/nmt-newt-utils.h
+++ b/clients/tui/newt/nmt-newt-utils.h
@@ -41,11 +41,11 @@ char *nmt_newt_locale_from_utf8 (const char *str_utf8);
int nmt_newt_text_width (const char *str);
void nmt_newt_message_dialog (const char *message,
- ...) __attribute__((__format__ (__printf__, 1, 2)));
+ ...) _nm_printf (1, 2);
int nmt_newt_choice_dialog (const char *button1,
const char *button2,
const char *message,
- ...) __attribute__((__format__ (__printf__, 3, 4)));
+ ...) _nm_printf (3, 4);
char *nmt_newt_edit_string (const char *data);
diff --git a/shared/nm-macros-internal.h b/shared/nm-macros-internal.h
index 7a5c90fc53..04e6a1ab6c 100644
--- a/shared/nm-macros-internal.h
+++ b/shared/nm-macros-internal.h
@@ -30,6 +30,7 @@
#define _nm_unused __attribute__ ((unused))
#define _nm_pure __attribute__ ((pure))
#define _nm_const __attribute__ ((const))
+#define _nm_printf(a,b) __attribute__ ((__format__ (__printf__, a, b)))
#define nm_auto(fcn) __attribute__ ((cleanup(fcn)))
diff --git a/src/nm-core-utils.h b/src/nm-core-utils.h
index 56ec0b38ad..db7794f615 100644
--- a/src/nm-core-utils.h
+++ b/src/nm-core-utils.h
@@ -276,7 +276,7 @@ _nm_utils_strbuf_init (char *buf, gsize len, char **p_buf_ptr, gsize *p_buf_len)
G_STATIC_ASSERT (G_N_ELEMENTS (buf) == sizeof (buf) && sizeof (buf) > sizeof (char *)); \
_nm_utils_strbuf_init ((buf), sizeof (buf), (p_buf_ptr), (p_buf_len)); \
} G_STMT_END
-void nm_utils_strbuf_append (char **buf, gsize *len, const char *format, ...) __attribute__((__format__ (__printf__, 3, 4)));
+void nm_utils_strbuf_append (char **buf, gsize *len, const char *format, ...) _nm_printf (3, 4);
void nm_utils_strbuf_append_c (char **buf, gsize *len, char c);
void nm_utils_strbuf_append_str (char **buf, gsize *len, const char *str);
diff --git a/src/nm-logging.c b/src/nm-logging.c
index 4d9b3fbd45..e3eaf52b27 100644
--- a/src/nm-logging.c
+++ b/src/nm-logging.c
@@ -478,7 +478,7 @@ nm_logging_get_level (NMLogDomain domain)
}
#if SYSTEMD_JOURNAL
-__attribute__((__format__ (__printf__, 4, 5)))
+_nm_printf (4, 5)
static void
_iovec_set_format (struct iovec *iov, gboolean *iov_free, int i, const char *format, ...)
{
diff --git a/src/nm-logging.h b/src/nm-logging.h
index f49f6ec67b..e3289b7039 100644
--- a/src/nm-logging.h
+++ b/src/nm-logging.h
@@ -158,7 +158,7 @@ void _nm_log_impl (const char *file,
NMLogDomain domain,
int error,
const char *fmt,
- ...) __attribute__((__format__ (__printf__, 7, 8)));
+ ...) _nm_printf (7, 8);
const char *nm_logging_level_to_string (void);
const char *nm_logging_domains_to_string (void);
diff --git a/src/platform/tests/test-common.h b/src/platform/tests/test-common.h
index 143b9b5272..87fccee234 100644
--- a/src/platform/tests/test-common.h
+++ b/src/platform/tests/test-common.h
@@ -84,7 +84,7 @@ void link_callback (NMPlatform *platform, NMPObjectType obj_type, int ifindex, N
/*****************************************************************************/
-int nmtstp_run_command (const char *format, ...) __attribute__((__format__ (__printf__, 1, 2)));
+int nmtstp_run_command (const char *format, ...) _nm_printf (1, 2);
#define nmtstp_run_command_check(...) do { g_assert_cmpint (nmtstp_run_command (__VA_ARGS__), ==, 0); } while (0)
/*****************************************************************************/