Browse Source

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

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

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
Andrew Borodin 9 years ago
parent
commit
d9ad3d2e32
10 changed files with 28 additions and 12 deletions
  1. 1 0
      lib/global.h
  2. 1 0
      lib/logging.c
  3. 4 2
      lib/logging.h
  4. 1 0
      lib/serialize.c
  5. 3 1
      lib/strutil.h
  6. 3 1
      lib/tty/tty.h
  7. 4 2
      lib/util.h
  8. 3 1
      lib/vfs/vfs.h
  9. 3 1
      lib/widget/label.h
  10. 5 4
      lib/widget/wtools.h

+ 1 - 0
lib/global.h

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

+ 1 - 0
lib/logging.c

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

+ 4 - 2
lib/logging.h

@@ -22,8 +22,10 @@
 
 /*** declarations of public functions ************************************************************/
 
-extern void mc_log (const char *, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
-extern void mc_always_log (const char *, ...) __attribute__ ((__format__ (__printf__, 1, 2)));
+/* *INDENT-OFF* */
+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 ****************************************************************************/
 

+ 1 - 0
lib/serialize.c

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

+ 3 - 1
lib/strutil.h

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

+ 3 - 1
lib/tty/tty.h

@@ -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_anychar (int c);
 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_hline (gboolean single);

+ 4 - 2
lib/util.h

@@ -246,8 +246,10 @@ char *guess_message_value (void);
 char *mc_build_filename (const char *first_element, ...);
 char *mc_build_filenamev (const char *first_element, va_list args);
 
-void mc_propagate_error (GError ** dest, int code, const char *format, ...);
-void mc_replace_error (GError ** dest, int code, const char *format, ...);
+/* *INDENT-OFF* */
+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);
 

+ 3 - 1
lib/vfs/vfs.h

@@ -256,7 +256,9 @@ void vfs_release_path (const vfs_path_t * vpath);
 
 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);
 

+ 3 - 1
lib/widget/label.h

@@ -28,7 +28,9 @@ typedef struct
 
 WLabel *label_new (int y, int x, 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 ****************************************************************************/
 

+ 5 - 4
lib/widget/wtools.h

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

Some files were not shown because too many files changed in this diff