Patch 8.2.3274
Problem: Macro for printf format check can be simplified.
Solution: Add ATTRIBUTE_FORMAT_PRINTF(). (Dominique Pellé, issue #8635)
Files: src/channel.c, src/gui_xim.c, src/if_mzsch.c, src/nbdebug.c,
src/nbdebug.h, src/netbeans.c, src/proto.h, src/term.c, src/vim.h,
src/vim9execute.c
*** ../vim-8.2.3273/src/channel.c 2021-07-27 22:00:39.737712414 +0200
--- src/channel.c 2021-08-02 18:01:25.447178837 +0200
***************
*** 229,239 ****
#endif
static void
! ch_error(channel_T *ch, const char *fmt, ...)
! #ifdef USE_PRINTF_FORMAT_ATTRIBUTE
! __attribute__((format(printf, 2, 3)))
! #endif
! ;
static void
ch_error(channel_T *ch, const char *fmt, ...)
--- 229,235 ----
#endif
static void
! ch_error(channel_T *ch, const char *fmt, ...) ATTRIBUTE_FORMAT_PRINTF(2, 3);
static void
ch_error(channel_T *ch, const char *fmt, ...)
*** ../vim-8.2.3273/src/gui_xim.c 2021-03-18 22:28:53.563835682 +0100
--- src/gui_xim.c 2021-08-02 18:01:25.447178837 +0200
***************
*** 31,37 ****
* in the "xim.log" file.
*/
// #define XIM_DEBUG
! #ifdef XIM_DEBUG
static void
xim_log(char *s, ...)
{
--- 31,39 ----
* in the "xim.log" file.
*/
// #define XIM_DEBUG
! #if defined(XIM_DEBUG) && defined(FEAT_GUI_GTK)
! static void xim_log(char *s, ...) ATTRIBUTE_FORMAT_PRINTF(1, 2);
!
static void
xim_log(char *s, ...)
{
*** ../vim-8.2.3273/src/if_mzsch.c 2021-07-24 13:57:25.477296535 +0200
--- src/if_mzsch.c 2021-08-02 18:01:25.447178837 +0200
***************
*** 139,145 ****
# define OUTPUT_LEN_TYPE long
#endif
static void do_output(char *mesg, OUTPUT_LEN_TYPE len);
! static void do_printf(char *format, ...);
static void do_flush(void);
static Scheme_Object *_apply_thunk_catch_exceptions(
Scheme_Object *, Scheme_Object **);
--- 139,145 ----
# define OUTPUT_LEN_TYPE long
#endif
static void do_output(char *mesg, OUTPUT_LEN_TYPE len);
! static void do_printf(char *format, ...) ATTRIBUTE_FORMAT_PRINTF(1, 2);
static void do_flush(void);
static Scheme_Object *_apply_thunk_catch_exceptions(
Scheme_Object *, Scheme_Object **);
*** ../vim-8.2.3273/src/nbdebug.c 2019-12-05 19:59:01.000000000 +0100
--- src/nbdebug.c 2021-08-02 18:01:25.447178837 +0200
***************
*** 32,38 ****
FILE *nb_debug = NULL;
u_int nb_dlevel = 0; // nb_debug verbosity level
! void nbdb(char *, ...);
static int lookup(char *);
#ifdef USE_NB_ERRORHANDLER
--- 32,38 ----
FILE *nb_debug = NULL;
u_int nb_dlevel = 0; // nb_debug verbosity level
! void nbdb(char *, ...) ATTRIBUTE_FORMAT_PRINTF(1, 2);
static int lookup(char *);
#ifdef USE_NB_ERRORHANDLER
*** ../vim-8.2.3273/src/nbdebug.h 2019-11-30 18:42:46.000000000 +0100
--- src/nbdebug.h 2021-08-02 18:01:25.447178837 +0200
***************
*** 42,52 ****
} WtWait;
! void nbdbg(char *, ...)
! # ifdef USE_PRINTF_FORMAT_ATTRIBUTE
! __attribute__((format(printf, 1, 2)))
! # endif
! ;
void nbdebug_wait(u_int wait_flags, char *wait_var, u_int wait_secs);
void nbdebug_log_init(char *log_var, char *level_var);
--- 42,48 ----
} WtWait;
! void nbdbg(char *, ...) ATTRIBUTE_FORMAT_PRINTF(1, 2);
void nbdebug_wait(u_int wait_flags, char *wait_var, u_int wait_secs);
void nbdebug_log_init(char *log_var, char *level_var);
*** ../vim-8.2.3273/src/netbeans.c 2020-11-06 13:44:16.731277020 +0100
--- src/netbeans.c 2021-08-02 18:01:25.451178831 +0200
***************
*** 54,60 ****
static int getConnInfo(char *file, char **host, char **port, char **password);
static void nb_init_graphics(void);
! static void coloncmd(char *cmd, ...);
static void nb_set_curbuf(buf_T *buf);
static void nb_parse_cmd(char_u *);
static int nb_do_cmd(int, char_u *, int, int, char_u *);
--- 54,60 ----
static int getConnInfo(char *file, char **host, char **port, char **password);
static void nb_init_graphics(void);
! static void coloncmd(char *cmd, ...) ATTRIBUTE_FORMAT_PRINTF(1, 2);
static void nb_set_curbuf(buf_T *buf);
static void nb_parse_cmd(char_u *);
static int nb_do_cmd(int, char_u *, int, int, char_u *);
*** ../vim-8.2.3273/src/proto.h 2021-07-10 21:28:55.327050110 +0200
--- src/proto.h 2021-08-02 18:01:25.451178831 +0200
***************
*** 121,172 ****
# endif
// These prototypes cannot be produced automatically.
! int smsg(const char *, ...)
! # ifdef USE_PRINTF_FORMAT_ATTRIBUTE
! __attribute__((format(printf, 1, 2)))
! # endif
! ;
! int smsg_attr(int, const char *, ...)
! # ifdef USE_PRINTF_FORMAT_ATTRIBUTE
! __attribute__((format(printf, 2, 3)))
! # endif
! ;
! int smsg_attr_keep(int, const char *, ...)
! # ifdef USE_PRINTF_FORMAT_ATTRIBUTE
! __attribute__((format(printf, 2, 3)))
! # endif
! ;
// These prototypes cannot be produced automatically.
! int semsg(const char *, ...)
! # ifdef USE_PRINTF_FORMAT_ATTRIBUTE
! __attribute__((format(printf, 1, 2)))
! # endif
! ;
// These prototypes cannot be produced automatically.
! void siemsg(const char *, ...)
! # ifdef USE_PRINTF_FORMAT_ATTRIBUTE
! __attribute__((format(printf, 1, 2)))
! # endif
! ;
! int vim_snprintf_add(char *, size_t, const char *, ...)
! # ifdef USE_PRINTF_FORMAT_ATTRIBUTE
! __attribute__((format(printf, 3, 4)))
! # endif
! ;
! int vim_snprintf(char *, size_t, const char *, ...)
! # ifdef USE_PRINTF_FORMAT_ATTRIBUTE
! __attribute__((format(printf, 3, 4)))
! # endif
! ;
! int vim_vsnprintf(char *str, size_t str_m, const char *fmt, va_list ap);
! int vim_vsnprintf_typval(char *str, size_t str_m, const char *fmt, va_list ap, typval_T *tvs);
# include "
message.pro"
# include "
misc1.pro"
--- 121,146 ----
# endif
// These prototypes cannot be produced automatically.
! int smsg(const char *, ...) ATTRIBUTE_COLD ATTRIBUTE_FORMAT_PRINTF(1, 2);
! int smsg_attr(int, const char *, ...) ATTRIBUTE_FORMAT_PRINTF(2, 3);
! int smsg_attr_keep(int, const char *, ...) ATTRIBUTE_FORMAT_PRINTF(2, 3);
// These prototypes cannot be produced automatically.
! int semsg(const char *, ...) ATTRIBUTE_COLD ATTRIBUTE_FORMAT_PRINTF(1, 2);
// These prototypes cannot be produced automatically.
! void siemsg(const char *, ...) ATTRIBUTE_COLD ATTRIBUTE_FORMAT_PRINTF(1, 2);
! int vim_snprintf_add(char *, size_t, const char *, ...) ATTRIBUTE_FORMAT_PRINTF(3, 4);
! int vim_snprintf(char *, size_t, const char *, ...) ATTRIBUTE_FORMAT_PRINTF(3, 4);
! int vim_vsnprintf(char *str, size_t str_m, const char *fmt, va_list ap)
! ATTRIBUTE_FORMAT_PRINTF(3, 0);
! int vim_vsnprintf_typval(char *str, size_t str_m, const char *fmt, va_list ap, typval_T *tvs)
! ATTRIBUTE_FORMAT_PRINTF(3, 0);
# include "
message.pro"
# include "
misc1.pro"
***************
*** 284,294 ****
# include "
channel.pro"
// Not generated automatically, to add extra attribute.
! void ch_log(channel_T *ch, const char *fmt, ...)
! # ifdef USE_PRINTF_FORMAT_ATTRIBUTE
! __attribute__((format(printf, 2, 3)))
! # endif
! ;
# endif
--- 258,264 ----
# include "
channel.pro"
// Not generated automatically, to add extra attribute.
! void ch_log(channel_T *ch, const char *fmt, ...) ATTRIBUTE_FORMAT_PRINTF(2, 3);
# endif
*** ../vim-8.2.3273/src/term.c 2021-07-30 21:17:59.142134917 +0200
--- src/term.c 2021-08-02 18:01:25.451178831 +0200
***************
*** 100,106 ****
// Change this to "if 1" to debug what happens with termresponse.
# if 0
# define DEBUG_TERMRESPONSE
! static void log_tr(const char *fmt, ...);
# define LOG_TR(msg) log_tr msg
# else
# define LOG_TR(msg) do { /**/ } while (0)
--- 100,106 ----
// Change this to "if 1" to debug what happens with termresponse.
# if 0
# define DEBUG_TERMRESPONSE
! static void log_tr(const char *fmt, ...) ATTRIBUTE_FORMAT_PRINTF(1, 2);
# define LOG_TR(msg) log_tr msg
# else
# define LOG_TR(msg) do { /**/ } while (0)
*** ../vim-8.2.3273/src/vim.h 2021-08-01 14:52:05.558645405 +0200
--- src/vim.h 2021-08-02 18:01:25.451178831 +0200
***************
*** 2132,2139 ****
typedef struct stat stat_T;
#endif
! #if defined(__GNUC__) && !defined(__MINGW32__)
! # define USE_PRINTF_FORMAT_ATTRIBUTE
#endif
typedef enum {
--- 2132,2152 ----
typedef struct stat stat_T;
#endif
! #if (defined(__GNUC__) || defined(__clang__)) && !defined(__MINGW32__)
! # define ATTRIBUTE_FORMAT_PRINTF(fmt_idx, arg_idx) \
! __attribute__((format(printf, fmt_idx, arg_idx)))
! #else
! # define ATTRIBUTE_FORMAT_PRINTF(fmt_idx, arg_idx)
! #endif
!
! #if defined(__GNUC__) || defined(__clang__)
! # define likely(x) __builtin_expect((x), 1)
! # define unlikely(x) __builtin_expect((x), 0)
! # define ATTRIBUTE_COLD __attribute__((cold))
! #else
! # define unlikely(x) (x)
! # define likely(x) (x)
! # define ATTRIBUTE_COLD
#endif
typedef enum {
*** ../vim-8.2.3273/src/vim9execute.c 2021-08-01 14:08:50.780946552 +0200
--- src/vim9execute.c 2021-08-02 18:05:03.710740278 +0200
***************
*** 22,35 ****
#include "vim9.h"
- #if defined(__GNUC__) || defined(__clang__)
- # define likely(x) __builtin_expect((x), 1)
- # define unlikely(x) __builtin_expect((x), 0)
- #else
- # define unlikely(x) (x)
- # define likely(x) (x)
- #endif
-
// Structure put on ec_trystack when ISN_TRY is encountered.
typedef struct {
int tcd_frame_idx; // ec_frame_idx at ISN_TRY
--- 22,27 ----
*** ../vim-8.2.3273/src/version.c 2021-08-01 22:01:25.985012239 +0200
--- src/version.c 2021-08-02 18:02:49.707010046 +0200
***************
*** 757,758 ****
--- 757,760 ----
{ /* Add new patch number below this line */
+ /**/
+ 3274,
/**/
--
Not too long ago, cut and paste was done with scissors and glue...
/// Bram Moolenaar -- Br...@Moolenaar.net --
http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features --
http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims --
http://ICCF-Holland.org ///