mirror of
https://github.com/vim/vim
synced 2025-07-16 09:12:00 +00:00
patch 8.2.3274: macro for printf format check can be simplified
Problem: Macro for printf format check can be simplified. Solution: Add ATTRIBUTE_FORMAT_PRINTF(). (Dominique Pellé, issue #8635)
This commit is contained in:
@ -229,11 +229,7 @@ ch_log(channel_T *ch, const char *fmt, ...)
|
||||
#endif
|
||||
|
||||
static void
|
||||
ch_error(channel_T *ch, const char *fmt, ...)
|
||||
#ifdef USE_PRINTF_FORMAT_ATTRIBUTE
|
||||
__attribute__((format(printf, 2, 3)))
|
||||
#endif
|
||||
;
|
||||
ch_error(channel_T *ch, const char *fmt, ...) ATTRIBUTE_FORMAT_PRINTF(2, 3);
|
||||
|
||||
static void
|
||||
ch_error(channel_T *ch, const char *fmt, ...)
|
||||
|
@ -31,7 +31,9 @@
|
||||
* in the "xim.log" file.
|
||||
*/
|
||||
// #define XIM_DEBUG
|
||||
#ifdef 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, ...)
|
||||
{
|
||||
|
@ -139,7 +139,7 @@ static char *string_to_line(Scheme_Object *obj);
|
||||
# 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_printf(char *format, ...) ATTRIBUTE_FORMAT_PRINTF(1, 2);
|
||||
static void do_flush(void);
|
||||
static Scheme_Object *_apply_thunk_catch_exceptions(
|
||||
Scheme_Object *, Scheme_Object **);
|
||||
|
@ -32,7 +32,7 @@
|
||||
FILE *nb_debug = NULL;
|
||||
u_int nb_dlevel = 0; // nb_debug verbosity level
|
||||
|
||||
void nbdb(char *, ...);
|
||||
void nbdb(char *, ...) ATTRIBUTE_FORMAT_PRINTF(1, 2);
|
||||
|
||||
static int lookup(char *);
|
||||
#ifdef USE_NB_ERRORHANDLER
|
||||
|
@ -42,11 +42,7 @@ typedef enum {
|
||||
} WtWait;
|
||||
|
||||
|
||||
void nbdbg(char *, ...)
|
||||
# ifdef USE_PRINTF_FORMAT_ATTRIBUTE
|
||||
__attribute__((format(printf, 1, 2)))
|
||||
# endif
|
||||
;
|
||||
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);
|
||||
|
@ -54,7 +54,7 @@ static void special_keys(char_u *args);
|
||||
static int getConnInfo(char *file, char **host, char **port, char **password);
|
||||
|
||||
static void nb_init_graphics(void);
|
||||
static void coloncmd(char *cmd, ...);
|
||||
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 *);
|
||||
|
54
src/proto.h
54
src/proto.h
@ -121,52 +121,26 @@ extern int _stricoll(char *a, char *b);
|
||||
# endif
|
||||
|
||||
// These prototypes cannot be produced automatically.
|
||||
int smsg(const char *, ...)
|
||||
# ifdef USE_PRINTF_FORMAT_ATTRIBUTE
|
||||
__attribute__((format(printf, 1, 2)))
|
||||
# endif
|
||||
;
|
||||
int smsg(const char *, ...) ATTRIBUTE_COLD ATTRIBUTE_FORMAT_PRINTF(1, 2);
|
||||
|
||||
int smsg_attr(int, const char *, ...)
|
||||
# ifdef USE_PRINTF_FORMAT_ATTRIBUTE
|
||||
__attribute__((format(printf, 2, 3)))
|
||||
# endif
|
||||
;
|
||||
int smsg_attr(int, const char *, ...) ATTRIBUTE_FORMAT_PRINTF(2, 3);
|
||||
|
||||
int smsg_attr_keep(int, const char *, ...)
|
||||
# ifdef USE_PRINTF_FORMAT_ATTRIBUTE
|
||||
__attribute__((format(printf, 2, 3)))
|
||||
# endif
|
||||
;
|
||||
int smsg_attr_keep(int, const char *, ...) ATTRIBUTE_FORMAT_PRINTF(2, 3);
|
||||
|
||||
// These prototypes cannot be produced automatically.
|
||||
int semsg(const char *, ...)
|
||||
# ifdef USE_PRINTF_FORMAT_ATTRIBUTE
|
||||
__attribute__((format(printf, 1, 2)))
|
||||
# endif
|
||||
;
|
||||
int semsg(const char *, ...) ATTRIBUTE_COLD ATTRIBUTE_FORMAT_PRINTF(1, 2);
|
||||
|
||||
// These prototypes cannot be produced automatically.
|
||||
void siemsg(const char *, ...)
|
||||
# ifdef USE_PRINTF_FORMAT_ATTRIBUTE
|
||||
__attribute__((format(printf, 1, 2)))
|
||||
# endif
|
||||
;
|
||||
void siemsg(const char *, ...) ATTRIBUTE_COLD ATTRIBUTE_FORMAT_PRINTF(1, 2);
|
||||
|
||||
int vim_snprintf_add(char *, size_t, const char *, ...)
|
||||
# ifdef USE_PRINTF_FORMAT_ATTRIBUTE
|
||||
__attribute__((format(printf, 3, 4)))
|
||||
# endif
|
||||
;
|
||||
int vim_snprintf_add(char *, size_t, const char *, ...) ATTRIBUTE_FORMAT_PRINTF(3, 4);
|
||||
|
||||
int vim_snprintf(char *, size_t, const char *, ...)
|
||||
# ifdef USE_PRINTF_FORMAT_ATTRIBUTE
|
||||
__attribute__((format(printf, 3, 4)))
|
||||
# endif
|
||||
;
|
||||
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);
|
||||
int vim_vsnprintf_typval(char *str, size_t str_m, const char *fmt, va_list ap, typval_T *tvs);
|
||||
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,11 +258,7 @@ void mbyte_im_set_active(int active_arg);
|
||||
# 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
|
||||
;
|
||||
void ch_log(channel_T *ch, const char *fmt, ...) ATTRIBUTE_FORMAT_PRINTF(2, 3);
|
||||
|
||||
# endif
|
||||
|
||||
|
@ -100,7 +100,7 @@ char *tgetstr(char *, char **);
|
||||
// Change this to "if 1" to debug what happens with termresponse.
|
||||
# if 0
|
||||
# define DEBUG_TERMRESPONSE
|
||||
static void log_tr(const char *fmt, ...);
|
||||
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)
|
||||
|
@ -755,6 +755,8 @@ static char *(features[]) =
|
||||
|
||||
static int included_patches[] =
|
||||
{ /* Add new patch number below this line */
|
||||
/**/
|
||||
3274,
|
||||
/**/
|
||||
3273,
|
||||
/**/
|
||||
|
17
src/vim.h
17
src/vim.h
@ -2132,8 +2132,21 @@ typedef struct _stat64 stat_T;
|
||||
typedef struct stat stat_T;
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && !defined(__MINGW32__)
|
||||
# define USE_PRINTF_FORMAT_ATTRIBUTE
|
||||
#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 {
|
||||
|
@ -22,14 +22,6 @@
|
||||
|
||||
#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
|
||||
|
Reference in New Issue
Block a user