Clarify __attribute ((format (printf))) usage.

Thanks Andreas Mohr <and@gmx.li> for the original patch.

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2015-08-25 15:28:01 +03:00 committed by Slava Zanko
parent bb6f1e6695
commit d9ad3d2e32
14 changed files with 34 additions and 15 deletions

View File

@ -64,6 +64,7 @@
#include <glib.h> #include <glib.h>
#include "glibcompat.h" #include "glibcompat.h"
/* For SMB VFS only */
#ifndef __GNUC__ #ifndef __GNUC__
#define __attribute__(x) #define __attribute__(x)
#endif #endif

View File

@ -110,6 +110,7 @@ get_log_filename (void)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static void static void
G_GNUC_PRINTF (1, 0)
mc_va_log (const char *fmt, va_list args) mc_va_log (const char *fmt, va_list args)
{ {
char *logfilename; char *logfilename;

View File

@ -22,8 +22,10 @@
/*** declarations of public functions ************************************************************/ /*** declarations of public functions ************************************************************/
extern void mc_log (const char *, ...) __attribute__ ((__format__ (__printf__, 1, 2))); /* *INDENT-OFF* */
extern void mc_always_log (const char *, ...) __attribute__ ((__format__ (__printf__, 1, 2))); void mc_log (const char *fmt, ...) G_GNUC_PRINTF (1, 2);
void mc_always_log (const char *fmt, ...) G_GNUC_PRINTF (1, 2);
/* *INDENT-ON* */
/*** inline functions ****************************************************************************/ /*** inline functions ****************************************************************************/

View File

@ -52,6 +52,7 @@
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static void static void
G_GNUC_PRINTF (2, 3)
prepend_error_message (GError ** error, const char *format, ...) prepend_error_message (GError ** error, const char *format, ...)
{ {
char *prepend_str; char *prepend_str;

View File

@ -217,7 +217,9 @@ estr_t str_vfs_convert_to (GIConv, const char *, int, GString *);
/* printf function for str_buffer, append result of printf at the end of buffer /* printf function for str_buffer, append result of printf at the end of buffer
*/ */
void str_printf (GString *, const char *, ...); /* *INDENT-OFF* */
void str_printf (GString * buffer, const char *format, ...) G_GNUC_PRINTF (2, 3);
/* *INDENT-ON* */
/* add standard replacement character in terminal encoding /* add standard replacement character in terminal encoding
*/ */

View File

@ -120,7 +120,9 @@ extern void tty_print_char (int c);
extern void tty_print_alt_char (int c, gboolean single); extern void tty_print_alt_char (int c, gboolean single);
extern void tty_print_anychar (int c); extern void tty_print_anychar (int c);
extern void tty_print_string (const char *s); extern void tty_print_string (const char *s);
extern void tty_printf (const char *s, ...); /* *INDENT-OFF* */
extern void tty_printf (const char *s, ...) G_GNUC_PRINTF (1, 2);
/* *INDENT-ON* */
extern void tty_print_one_vline (gboolean single); extern void tty_print_one_vline (gboolean single);
extern void tty_print_one_hline (gboolean single); extern void tty_print_one_hline (gboolean single);

View File

@ -246,8 +246,10 @@ char *guess_message_value (void);
char *mc_build_filename (const char *first_element, ...); char *mc_build_filename (const char *first_element, ...);
char *mc_build_filenamev (const char *first_element, va_list args); char *mc_build_filenamev (const char *first_element, va_list args);
void mc_propagate_error (GError ** dest, int code, const char *format, ...); /* *INDENT-OFF* */
void mc_replace_error (GError ** dest, int code, const char *format, ...); void mc_propagate_error (GError ** dest, int code, const char *format, ...) G_GNUC_PRINTF (3, 4);
void mc_replace_error (GError ** dest, int code, const char *format, ...) G_GNUC_PRINTF (3, 4);
/* *INDENT-ON* */
gboolean mc_time_elapsed (guint64 * timestamp, guint64 delay); gboolean mc_time_elapsed (guint64 * timestamp, guint64 delay);

View File

@ -256,7 +256,9 @@ void vfs_release_path (const vfs_path_t * vpath);
void vfs_fill_names (fill_names_f); void vfs_fill_names (fill_names_f);
void vfs_print_message (const char *msg, ...) __attribute__ ((format (__printf__, 1, 2))); /* *INDENT-OFF* */
void vfs_print_message (const char *msg, ...) G_GNUC_PRINTF (1, 2);
/* *INDENT-ON* */
int vfs_ferrno (struct vfs_class *vfs); int vfs_ferrno (struct vfs_class *vfs);

View File

@ -28,7 +28,9 @@ typedef struct
WLabel *label_new (int y, int x, const char *text); WLabel *label_new (int y, int x, const char *text);
void label_set_text (WLabel * label, const char *text); void label_set_text (WLabel * label, const char *text);
void label_set_textv (WLabel * label, const char *format, ...); /* *INDENT-OFF* */
void label_set_textv (WLabel * label, const char *format, ...) G_GNUC_PRINTF (2, 3);
/* *INDENT-ON* */
/*** inline functions ****************************************************************************/ /*** inline functions ****************************************************************************/

View File

@ -77,12 +77,13 @@ int query_dialog (const char *header, const char *text, int flags, int count, ..
void query_set_sel (int new_sel); void query_set_sel (int new_sel);
/* Create message box but don't dismiss it yet, not background safe */ /* Create message box but don't dismiss it yet, not background safe */
struct WDialog *create_message (int flags, const char *title, /* *INDENT-OFF* */
const char *text, ...) __attribute__ ((format (__printf__, 3, 4))); struct WDialog *create_message (int flags, const char *title, const char *text, ...)
G_GNUC_PRINTF (3, 4);
/* Show message box, background safe */ /* Show message box, background safe */
void message (int flags, const char *title, const char *text, ...) void message (int flags, const char *title, const char *text, ...) G_GNUC_PRINTF (3, 4);
__attribute__ ((format (__printf__, 3, 4))); /* *INDENT-ON* */
gboolean mc_error_message (GError ** mcerror, int *code); gboolean mc_error_message (GError ** mcerror, int *code);

View File

@ -64,6 +64,7 @@ dnl Sorted -W options:
MC_CHECK_ONE_CFLAG([-Wmissing-braces]) MC_CHECK_ONE_CFLAG([-Wmissing-braces])
MC_CHECK_ONE_CFLAG([-Wmissing-declarations]) MC_CHECK_ONE_CFLAG([-Wmissing-declarations])
MC_CHECK_ONE_CFLAG([-Wmissing-field-initializers]) MC_CHECK_ONE_CFLAG([-Wmissing-field-initializers])
MC_CHECK_ONE_CFLAG([-Wmissing-format-attribute])
MC_CHECK_ONE_CFLAG([-Wmissing-parameter-type]) MC_CHECK_ONE_CFLAG([-Wmissing-parameter-type])
MC_CHECK_ONE_CFLAG([-Wmissing-prototypes]) MC_CHECK_ONE_CFLAG([-Wmissing-prototypes])
MC_CHECK_ONE_CFLAG([-Wmissing-variable-declarations]) MC_CHECK_ONE_CFLAG([-Wmissing-variable-declarations])

View File

@ -236,6 +236,7 @@ fish_get_reply (struct vfs_class *me, int sock, char *string_buf, int string_len
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static int static int
G_GNUC_PRINTF (4, 5)
fish_command (struct vfs_class *me, struct vfs_s_super *super, int wait_reply, const char *fmt, ...) fish_command (struct vfs_class *me, struct vfs_s_super *super, int wait_reply, const char *fmt, ...)
{ {
va_list ap; va_list ap;

View File

@ -264,8 +264,6 @@ static const char *netrcp;
static char *ftpfs_get_current_directory (struct vfs_class *me, struct vfs_s_super *super); static char *ftpfs_get_current_directory (struct vfs_class *me, struct vfs_s_super *super);
static int ftpfs_chdir_internal (struct vfs_class *me, struct vfs_s_super *super, static int ftpfs_chdir_internal (struct vfs_class *me, struct vfs_s_super *super,
const char *remote_path); const char *remote_path);
static int ftpfs_command (struct vfs_class *me, struct vfs_s_super *super, int wait_reply,
const char *fmt, ...) __attribute__ ((format (__printf__, 4, 5)));
static int ftpfs_open_socket (struct vfs_class *me, struct vfs_s_super *super); static int ftpfs_open_socket (struct vfs_class *me, struct vfs_s_super *super);
static int ftpfs_login_server (struct vfs_class *me, struct vfs_s_super *super, static int ftpfs_login_server (struct vfs_class *me, struct vfs_s_super *super,
const char *netrcpass); const char *netrcpass);
@ -449,6 +447,7 @@ ftpfs_reconnect (struct vfs_class *me, struct vfs_s_super *super)
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */
static int static int
G_GNUC_PRINTF (4, 5)
ftpfs_command (struct vfs_class *me, struct vfs_s_super *super, int wait_reply, const char *fmt, ftpfs_command (struct vfs_class *me, struct vfs_s_super *super, int wait_reply, const char *fmt,
...) ...)
{ {

View File

@ -43,7 +43,9 @@ struct vfs_s_entry *vfs_root_entry;
static struct vfs_s_inode *vfs_root_inode; static struct vfs_s_inode *vfs_root_inode;
static struct vfs_s_super *vfs_test_super; static struct vfs_s_super *vfs_test_super;
void message (int flags, const char *title, const char *text, ...); /* *INDENT-OFF* */
void message (int flags, const char *title, const char *text, ...) G_GNUC_PRINTF (3, 4);
/* *INDENT-ON* */
/* --------------------------------------------------------------------------------------------- */ /* --------------------------------------------------------------------------------------------- */