Tag my_vsnprintf.c with ATTRIBUTE_FORMAT

[Breaking]
Good news:
GCC now checks your `my_snprintf` (direct) calls (`-Wformat` was on);
Bad news:
The build process no longer lets your incorrect
formats/arguments sneak past (`-Werror` was also on).

As such, this commit also migrates all direct `my_snprintf` calls from
the old specifiers to MDEV-21978’s new `-Wformat`-compatible suffixes.
The next commits will cover non-direct calls to `my_snprintf`.
(I call them “`my_snprintf` descendants”.)

This commit does not update the ABI records because
there’re more ABI “changes” to come – half a dozen
`include/mysql/plugin_*.h.pp`s are now missing the new `__attribute__`s.
This commit is contained in:
ParadoxV5 2024-06-28 20:48:51 -06:00 committed by Sergei Golubchik
commit 5100773ab9
10 changed files with 36 additions and 27 deletions

View file

@ -551,7 +551,7 @@ static int is_view(const char *table)
int view;
DBUG_ENTER("is_view");
my_snprintf(query, sizeof(query), "SHOW CREATE TABLE %`s", table);
my_snprintf(query, sizeof(query), "SHOW CREATE TABLE %sQ", table);
if (mysql_query(sock, query))
{
fprintf(stderr, "Failed to %s\n", query);
@ -800,7 +800,7 @@ static int fix_table_storage_name(const char *name)
if (strncmp(name, "#mysql50#", 9))
DBUG_RETURN(1);
my_snprintf(qbuf, sizeof(qbuf), "RENAME TABLE %`s TO %`s",
my_snprintf(qbuf, sizeof(qbuf), "RENAME TABLE %sQ TO %sQ",
name, name + 9);
rc= run_query(qbuf, 1);
@ -817,7 +817,7 @@ static int fix_database_storage_name(const char *name)
if (strncmp(name, "#mysql50#", 9))
DBUG_RETURN(1);
my_snprintf(qbuf, sizeof(qbuf), "ALTER DATABASE %`s UPGRADE DATA DIRECTORY "
my_snprintf(qbuf, sizeof(qbuf), "ALTER DATABASE %sQ UPGRADE DATA DIRECTORY "
"NAME", name);
rc= run_query(qbuf, 1);
if (!opt_silent)
@ -1026,7 +1026,7 @@ static void insert_table_name(DYNAMIC_ARRAY *arr, char *in, size_t dblen)
{
char buf[NAME_LEN*2+2];
in[dblen]= 0;
my_snprintf(buf, sizeof(buf), "%`s.%`s", in, in + dblen + 1);
my_snprintf(buf, sizeof(buf), "%sQ.%sQ", in, in + dblen + 1);
insert_dynamic(arr, (uchar*) buf);
}