Skip to content

Commit d5ba6f7

Browse files
ParadoxV5vuvova
authored andcommitted
Tag push_warning_printf with ATTRIBUTE_FORMAT
* Let GCC `-Wformat` check formats sent to these `my_vsnprintf_ex` users * Migrate them from the old extension specifiers to the new `-Wformat`-compatible suffixes
1 parent 2047483 commit d5ba6f7

File tree

9 files changed

+23
-22
lines changed

9 files changed

+23
-22
lines changed

sql/field.cc

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11490,9 +11490,9 @@ void Field::raise_note_cannot_use_key_part(THD *thd,
1149011490
const LEX_CSTRING colv(op_collation->coll_name);
1149111491
push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE,
1149211492
ER_UNKNOWN_ERROR,
11493-
"Cannot use key %`.*s part[%u] for lookup: "
11494-
"%`.*s.%`.*s.%`.*s of collation %`.*s "
11495-
"%.*s \"%.*T\" of collation %`.*s",
11493+
"Cannot use key %.*sQ part[%u] for lookup: "
11494+
"%.*sQ.%.*sQ.%.*sQ of collation %.*sQ "
11495+
"%.*s \"%.*sT\" of collation %.*sQ",
1149611496
(int) keyname.length, keyname.str,
1149711497
part,
1149811498
(int) table->s->db.length, table->s->db.str,
@@ -11514,9 +11514,9 @@ void Field::raise_note_cannot_use_key_part(THD *thd,
1151411514
const LEX_CSTRING dtypev(value->type_handler()->name().lex_cstring());
1151511515
push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE,
1151611516
ER_UNKNOWN_ERROR,
11517-
"Cannot use key %`.*s part[%u] for lookup: "
11518-
"%`.*s.%`.*s.%`.*s of type %`.*s "
11519-
"%.*s \"%.*T\" of type %`.*s",
11517+
"Cannot use key %.*sQ part[%u] for lookup: "
11518+
"%.*sQ.%.*sQ.%.*sQ of type %.*sQ "
11519+
"%.*s \"%.*sT\" of type %.*sQ",
1152011520
(int) keyname.length, keyname.str,
1152111521
part,
1152211522
(int) table->s->db.length, table->s->db.str,
@@ -11544,8 +11544,8 @@ void Field::raise_note_key_become_unused(THD *thd, const String &expr) const
1154411544
{
1154511545
push_warning_printf(thd,
1154611546
Sql_condition::WARN_LEVEL_NOTE, ER_UNKNOWN_ERROR,
11547-
"Cannot use key parts with %`.*s.%`.*s.%`.*s "
11548-
"in the rewritten condition: %`.*s",
11547+
"Cannot use key parts with %.*sQ.%.*sQ.%.*sQ "
11548+
"in the rewritten condition: %.*sQ",
1154911549
(int) table->s->db.length, table->s->db.str,
1155011550
(int) table->s->table_name.length, table->s->table_name.str,
1155111551
(int) field_name.length, field_name.str,

sql/item_subselect.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -793,7 +793,7 @@ bool Item_subselect::exec()
793793
QT_WITHOUT_INTRODUCERS));
794794

795795
push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE,
796-
ER_UNKNOWN_ERROR, "DBUG: Item_subselect::exec %.*b",
796+
ER_UNKNOWN_ERROR, "DBUG: Item_subselect::exec %.*sB",
797797
print.length(),print.ptr());
798798
);
799799
/*

sql/item_vectorfunc.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@ String *Item_func_vec_totext::val_str_ascii(String *str)
131131
if (r1->length() % 4)
132132
{
133133
THD *thd= current_thd;
134-
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
135-
ER_VECTOR_BINARY_FORMAT_INVALID,
136-
ER_THD(thd, ER_VECTOR_BINARY_FORMAT_INVALID));
134+
push_warning(thd, Sql_condition::WARN_LEVEL_WARN,
135+
ER_VECTOR_BINARY_FORMAT_INVALID,
136+
ER_THD(thd, ER_VECTOR_BINARY_FORMAT_INVALID));
137137
null_value= true;
138138
return nullptr;
139139
}

sql/opt_vcol_substitution.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ void print_vcol_subst_warning(THD *thd, Field *field, Item *expr,
287287
ER_UNKNOWN_ERROR,
288288
"Cannot substitute virtual column expression %*s -> %*s "
289289
"due to %s",
290-
expr_length, expr_buffer.c_ptr_safe(),
290+
(int) expr_length, expr_buffer.c_ptr_safe(),
291291
(int) field->field_name.length, field->field_name.str,
292292
cause);
293293
}

sql/sql_delete.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1884,7 +1884,7 @@ bool Sql_cmd_delete::prepare_inner(THD *thd)
18841884
{
18851885
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
18861886
WARN_INDEX_HINTS_IGNORED,
1887-
ER_THD(thd, WARN_INDEX_HINTS_IGNORED));
1887+
"%s", ER_THD(thd, WARN_INDEX_HINTS_IGNORED));
18881888
}
18891889
}
18901890
if (table_list->vers_conditions.is_set() && table_list->is_view_or_derived())

sql/sql_error.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1332,7 +1332,8 @@ void push_warning(THD *thd, Sql_condition::enum_warning_level level,
13321332
uint code, const char *msg);
13331333

13341334
void push_warning_printf(THD *thd, Sql_condition::enum_warning_level level,
1335-
uint code, const char *format, ...);
1335+
uint code, const char *format, ...)
1336+
ATTRIBUTE_FORMAT(printf, 4, 5);
13361337

13371338
bool mysqld_show_warnings(THD *thd, ulong levels_to_show);
13381339

sql/sql_statistics.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ static inline int open_stat_table_for_ddl(THD *thd, TABLE_LIST *table,
320320
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
321321
ER_CHECK_NO_SUCH_TABLE,
322322
"Got error %d when trying to open statistics "
323-
"table %`s for updating statistics",
323+
"table %sQ for updating statistics",
324324
error_handler.got_error(), stat_table_name->str);
325325
}
326326
return res;

storage/example/ha_example.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,7 @@ ha_example::check_if_supported_inplace_alter(TABLE* altered_table,
970970
if (f_new)
971971
{
972972
push_warning_printf(ha_thd(), Sql_condition::WARN_LEVEL_NOTE,
973-
ER_UNKNOWN_ERROR, "EXAMPLE DEBUG: Field %`s COMPLEX '%s' -> '%s'",
973+
ER_UNKNOWN_ERROR, "EXAMPLE DEBUG: Field %sQ COMPLEX '%s' -> '%s'",
974974
table->s->field[i]->field_name.str,
975975
f_old->complex_param_to_parse_it_in_engine,
976976
f_new->complex_param_to_parse_it_in_engine);

storage/innobase/handler/ha_innodb.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11166,7 +11166,7 @@ create_table_info_t::create_options_are_invalid()
1116611166
}
1116711167

1116811168
switch (m_create_info->key_block_size) {
11169-
ulint kbs_max;
11169+
ulong kbs_max;
1117011170
case 1:
1117111171
case 2:
1117211172
case 4:
@@ -11183,8 +11183,8 @@ create_table_info_t::create_options_are_invalid()
1118311183
push_warning_printf(
1118411184
m_thd, Sql_condition::WARN_LEVEL_WARN,
1118511185
ER_ILLEGAL_HA_CREATE_OPTION,
11186-
"InnoDB: KEY_BLOCK_SIZE=%ld"
11187-
" cannot be larger than %ld.",
11186+
"InnoDB: KEY_BLOCK_SIZE=%lu"
11187+
" cannot be larger than %lu.",
1118811188
m_create_info->key_block_size,
1118911189
kbs_max);
1119011190
ret = "KEY_BLOCK_SIZE";
@@ -21175,7 +21175,7 @@ dberr_t innodb_decryption_failed(THD *thd, dict_table_t *table)
2117521175
const int dblen= int(table->name.dblen());
2117621176
push_warning_printf(thd, Sql_condition::WARN_LEVEL_WARN,
2117721177
HA_ERR_DECRYPTION_FAILED,
21178-
"Table %`.*s.%`s in tablespace " UINT32PF
21178+
"Table %.*sQ.%sQ in tablespace " UINT32PF
2117921179
" (file %s) cannot be decrypted.",
2118021180
dblen, table->name.m_name,
2118121181
table->name.m_name + dblen + 1,
@@ -21197,7 +21197,7 @@ void innodb_fk_error(const trx_t *trx, dberr_t err, const char *name,
2119721197
(trx, &foreign, false);
2119821198
push_warning_printf(trx->mysql_thd, Sql_condition::WARN_LEVEL_WARN,
2119921199
convert_error_code_to_mysql(err, 0, nullptr),
21200-
"CREATE or ALTER TABLE %`.*s.%`s failed%s%.*s",
21200+
"CREATE or ALTER TABLE %.*sQ.%sQ failed%s%.*s",
2120121201
dblen, name, name + dblen + 1,
2120221202
err == DB_DUPLICATE_KEY
2120321203
? ": duplicate name" : "",

0 commit comments

Comments
 (0)