Browse Source

Tag rest of my_vsnprintf users w/ ATTRIBUTE_FORMAT

This commit is the final batch of #3360’s `ATTRIBUTE_FORMAT` process,
covering various insignificant (as in, requires few-to-no
changes in addition to gaining this attribute) functions.

One of the main focus of this PR is to enable GCC `-Wformat` (by tagging
`ATTRIBUTE_FORMAT`) on ALL `my_snprintf` utilities. To be throughout,
functions that delegate to `my_vsnprintf` must also inherit this
attribute because `-Wformat` doesn’t trace argument across call stacks.
pull/3833/head
ParadoxV5 1 year ago
committed by Sergei Golubchik
parent
commit
c8783757d6
  1. 9
      client/mysqldump.cc
  2. 3
      include/sql_common.h
  3. 2
      plugin/query_response_time/query_response_time.cc
  4. 1
      sql/sp.cc
  5. 3
      storage/federatedx/federatedx_io_mysql.cc
  6. 2
      storage/maria/ha_maria.cc

9
client/mysqldump.cc

@ -628,8 +628,10 @@ static const char *load_default_groups[]=
0 };
static void ensure_out_dir_exists(const char *db);
static void maybe_exit(int error);
static void die(int error, const char* reason, ...);
static void maybe_die(int error, const char* reason, ...);
static void die(int error, const char* reason, ...)
ATTRIBUTE_FORMAT(printf, 2, 3);
static void maybe_die(int error, const char* reason, ...)
ATTRIBUTE_FORMAT(printf, 2, 3);
static void write_header(FILE *sql_file, const char *db_name);
static void print_value(FILE *file, MYSQL_RES *result, MYSQL_ROW row,
const char *prefix,const char *name,
@ -656,7 +658,8 @@ static int dump_all_tablespaces();
static int dump_tablespaces_for_tables(char *db, char **table_names, int tables);
static int dump_tablespaces_for_databases(char** databases);
static int dump_tablespaces(char* ts_where);
static void print_comment(FILE *, my_bool, const char *, ...);
static void print_comment(FILE *, my_bool, const char *, ...)
ATTRIBUTE_FORMAT(printf, 3, 4);
static inline int cmp_database(const char *a, const char *b)

3
include/sql_common.h

@ -109,7 +109,8 @@ void set_stmt_error(MYSQL_STMT *stmt, int errcode, const char *sqlstate,
const char *err);
void set_mysql_error(MYSQL *mysql, int errcode, const char *sqlstate);
void set_mysql_extended_error(MYSQL *mysql, int errcode, const char *sqlstate,
const char *format, ...);
const char *format, ...)
ATTRIBUTE_FORMAT(printf, 4, 5);
/* client side of the pluggable authentication */
struct st_vio;

2
plugin/query_response_time/query_response_time.cc

@ -136,7 +136,7 @@ private:
ulonglong m_bound[OVERALL_POWER_COUNT];
};
static
ATTRIBUTE_FORMAT(printf, 3, 0) static
size_t print_time(char* buffer, std::size_t buffer_size, const char* format,
uint64 value)
{

1
sql/sp.cc

@ -431,6 +431,7 @@ public:
Proc_table_intact() : m_print_once(TRUE) { has_keys= TRUE; }
protected:
ATTRIBUTE_FORMAT(printf, 3, 4)
void report_error(uint code, const char *fmt, ...) override;
};

3
storage/federatedx/federatedx_io_mysql.cc

@ -70,7 +70,8 @@ public:
federatedx_io_mysql(FEDERATEDX_SERVER *);
~federatedx_io_mysql() override;
int simple_query(const char *fmt, ...);
// 1st arg is the implicit `this`
int simple_query(const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 2, 3);
int query(const char *buffer, size_t length) override;
FEDERATEDX_IO_RESULT *store_result() override;

2
storage/maria/ha_maria.cc

@ -401,7 +401,7 @@ static void _ma_check_print(HA_CHECK *param, const LEX_CSTRING *msg_type,
// collect errors printed by maria_check routines
ATTRIBUTE_FORMAT(printf, 3, 0)
static void _ma_check_print_msg(HA_CHECK *param, const LEX_CSTRING *msg_type,
const char *fmt, va_list args)
{

Loading…
Cancel
Save