macros: add macro _nm_printf() for function attribute

This commit is contained in:
Thomas Haller 2016-06-05 12:21:48 +02:00
parent 466bf2f633
commit 348e505b3a
7 changed files with 8 additions and 7 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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)))

View File

@ -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);

View File

@ -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, ...)
{

View File

@ -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);

View File

@ -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)
/*****************************************************************************/