Skip to content

Commit

Permalink
Update my_snprintf’s last loose ends to suffixes
Browse files Browse the repository at this point in the history
Migrate `mysys/errors.c`, `sql-common/errmsg.c` and a couple of
insignificant loose ends to use suffix-based, `-Wformat`-compatible
`my_snprintf` format extensions introduced in MDEV-21978

This commit is the final batch of MDEV-21978’s migration process.

While GCC `-Wformat` (with `ATTRIBUTE_FORMAT`) can catch obsolete or
malformed format string literals, formats originating from other sources
(such as those strings headers) (still) require manual review.
Thus, after all the automatic `-Wformat` complaints fixed in previous
commits, I’ve done a manual `grep` and caught these final matches.
  • Loading branch information
ParadoxV5 committed Aug 16, 2024
1 parent e29862e commit 4ffbf1f
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 64 deletions.
116 changes: 58 additions & 58 deletions mysys/errors.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,42 +21,42 @@

const char *globerrs[GLOBERRS+1]=
{
"Can't create/write to file '%s' (Errcode: %M)",
"Error reading file '%s' (Errcode: %M)",
"Error writing file '%s' (Errcode: %M)",
"Error on close of '%s' (Errcode: %M)",
"Can't create/write to file '%s' (Errcode: %iE)",
"Error reading file '%s' (Errcode: %iE)",
"Error writing file '%s' (Errcode: %iE)",
"Error on close of '%s' (Errcode: %iE)",
"Out of memory (Needed %u bytes)",
"Error on delete of '%s' (Errcode: %M)",
"Error on rename of '%s' to '%s' (Errcode: %M)",
"Error on delete of '%s' (Errcode: %iE)",
"Error on rename of '%s' to '%s' (Errcode: %iE)",
"",
"Unexpected end-of-file found when reading file '%s' (Errcode: %M)",
"Can't lock file (Errcode: %M)",
"Can't unlock file (Errcode: %M)",
"Can't read dir of '%s' (Errcode: %M)",
"Can't get stat of '%s' (Errcode: %M)",
"Can't change size of file (Errcode: %M)",
"Can't open stream from handle (Errcode: %M)",
"Can't get working directory (Errcode: %M)",
"Can't change dir to '%s' (Errcode: %M)",
"Unexpected end-of-file found when reading file '%s' (Errcode: %iE)",
"Can't lock file (Errcode: %iE)",
"Can't unlock file (Errcode: %iE)",
"Can't read dir of '%s' (Errcode: %iE)",
"Can't get stat of '%s' (Errcode: %iE)",
"Can't change size of file (Errcode: %iE)",
"Can't open stream from handle (Errcode: %iE)",
"Can't get working directory (Errcode: %iE)",
"Can't change dir to '%s' (Errcode: %iE)",
"Warning: '%s' had %d links",
"Warning: %d files and %d streams is left open\n",
"Disk is full writing '%s' (Errcode: %M). Waiting for someone to free space... (Expect up to %d secs delay for server to continue after freeing disk space)",
"Can't create directory '%s' (Errcode: %M)",
"Disk is full writing '%s' (Errcode: %iE). Waiting for someone to free space... (Expect up to %d secs delay for server to continue after freeing disk space)",
"Can't create directory '%s' (Errcode: %iE)",
"Character set '%s' is not a compiled character set and is not specified in the '%s' file",
"Out of resources when opening file '%s' (Errcode: %M)",
"Can't read value for symlink '%s' (Errcode: %M)",
"Can't create symlink '%s' pointing at '%s' (Errcode: %M)",
"Error on realpath() on '%s' (Errcode: %M)",
"Can't sync file '%s' to disk (Errcode: %M)",
"Out of resources when opening file '%s' (Errcode: %iE)",
"Can't read value for symlink '%s' (Errcode: %iE)",
"Can't create symlink '%s' pointing at '%s' (Errcode: %iE)",
"Error on realpath() on '%s' (Errcode: %iE)",
"Can't sync file '%s' to disk (Errcode: %iE)",
"Collation '%s' is not a compiled collation and is not specified in the '%s' file",
"File '%s' not found (Errcode: %M)",
"File '%s' not found (Errcode: %iE)",
"File '%s' (fileno: %d) was not closed",
"Can't change ownership of the file '%s' (Errcode: %M)",
"Can't change permissions of the file '%s' (Errcode: %M)",
"Can't seek in file '%s' (Errcode: %M)",
"Can't change mode for file '%s' to 0x%lx (Errcode: %M)",
"Warning: Can't copy ownership for file '%s' (Errcode: %M)",
"Failed to release memory pointer %p, %zu bytes (Errcode: %M)",
"Can't change ownership of the file '%s' (Errcode: %iE)",
"Can't change permissions of the file '%s' (Errcode: %iE)",
"Can't seek in file '%s' (Errcode: %iE)",
"Can't change mode for file '%s' to 0x%lx (Errcode: %iE)",
"Warning: Can't copy ownership for file '%s' (Errcode: %iE)",
"Failed to release memory pointer %p, %zu bytes (Errcode: %iE)",
"Lock Pages in memory access rights required",
"Memcntl %s cmd %s error",
"Warning: Charset id '%d' csname '%s' trying to replace existing csname '%s'",
Expand All @@ -75,41 +75,41 @@ void init_glob_errs(void)

void init_glob_errs()
{
EE(EE_CANTCREATEFILE) = "Can't create/write to file '%s' (Errcode: %M)";
EE(EE_READ) = "Error reading file '%s' (Errcode: %M)";
EE(EE_WRITE) = "Error writing file '%s' (Errcode: %M)";
EE(EE_BADCLOSE) = "Error on close of '%'s (Errcode: %M)";
EE(EE_CANTCREATEFILE) = "Can't create/write to file '%s' (Errcode: %iE)";
EE(EE_READ) = "Error reading file '%s' (Errcode: %iE)";
EE(EE_WRITE) = "Error writing file '%s' (Errcode: %iE)";
EE(EE_BADCLOSE) = "Error on close of '%'s (Errcode: %iE)";
EE(EE_OUTOFMEMORY) = "Out of memory (Needed %u bytes)";
EE(EE_DELETE) = "Error on delete of '%s' (Errcode: %M)";
EE(EE_LINK) = "Error on rename of '%s' to '%s' (Errcode: %M)";
EE(EE_EOFERR) = "Unexpected eof found when reading file '%s' (Errcode: %M)";
EE(EE_CANTLOCK) = "Can't lock file (Errcode: %M)";
EE(EE_CANTUNLOCK) = "Can't unlock file (Errcode: %M)";
EE(EE_DIR) = "Can't read dir of '%s' (Errcode: %M)";
EE(EE_STAT) = "Can't get stat of '%s' (Errcode: %M)";
EE(EE_CANT_CHSIZE) = "Can't change size of file (Errcode: %M)";
EE(EE_CANT_OPEN_STREAM)= "Can't open stream from handle (Errcode: %M)";
EE(EE_GETWD) = "Can't get working directory (Errcode: %M)";
EE(EE_SETWD) = "Can't change dir to '%s' (Errcode: %M)";
EE(EE_DELETE) = "Error on delete of '%s' (Errcode: %iE)";
EE(EE_LINK) = "Error on rename of '%s' to '%s' (Errcode: %iE)";
EE(EE_EOFERR) = "Unexpected eof found when reading file '%s' (Errcode: %iE)";
EE(EE_CANTLOCK) = "Can't lock file (Errcode: %iE)";
EE(EE_CANTUNLOCK) = "Can't unlock file (Errcode: %iE)";
EE(EE_DIR) = "Can't read dir of '%s' (Errcode: %iE)";
EE(EE_STAT) = "Can't get stat of '%s' (Errcode: %iE)";
EE(EE_CANT_CHSIZE) = "Can't change size of file (Errcode: %iE)";
EE(EE_CANT_OPEN_STREAM)= "Can't open stream from handle (Errcode: %iE)";
EE(EE_GETWD) = "Can't get working directory (Errcode: %iE)";
EE(EE_SETWD) = "Can't change dir to '%s' (Errcode: %iE)";
EE(EE_LINK_WARNING) = "Warning: '%s' had %d links";
EE(EE_OPEN_WARNING) = "Warning: %d files and %d streams is left open\n";
EE(EE_DISK_FULL) = "Disk is full writing '%s' (Errcode: %M). Waiting for someone to free space... (Expect up to %d secs delay for server to continue after freeing disk space)",
EE(EE_CANT_MKDIR) ="Can't create directory '%s' (Errcode: %M)";
EE(EE_DISK_FULL) = "Disk is full writing '%s' (Errcode: %iE). Waiting for someone to free space... (Expect up to %d secs delay for server to continue after freeing disk space)",
EE(EE_CANT_MKDIR) ="Can't create directory '%s' (Errcode: %iE)";
EE(EE_UNKNOWN_CHARSET)= "Character set '%s' is not a compiled character set and is not specified in the %s file";
EE(EE_OUT_OF_FILERESOURCES)="Out of resources when opening file '%s' (Errcode: %M)";
EE(EE_CANT_READLINK)= "Can't read value for symlink '%s' (Errcode: %M)";
EE(EE_CANT_SYMLINK)= "Can't create symlink '%s' pointing at '%s' (Errcode: %M)";
EE(EE_REALPATH)= "Error on realpath() on '%s' (Errcode: %M)";
EE(EE_SYNC)= "Can't sync file '%s' to disk (Errcode: %M)";
EE(EE_OUT_OF_FILERESOURCES)="Out of resources when opening file '%s' (Errcode: %iE)";
EE(EE_CANT_READLINK)= "Can't read value for symlink '%s' (Errcode: %iE)";
EE(EE_CANT_SYMLINK)= "Can't create symlink '%s' pointing at '%s' (Errcode: %iE)";
EE(EE_REALPATH)= "Error on realpath() on '%s' (Errcode: %iE)";
EE(EE_SYNC)= "Can't sync file '%s' to disk (Errcode: %iE)";
EE(EE_UNKNOWN_COLLATION)= "Collation '%s' is not a compiled collation and is not specified in the %s file";
EE(EE_FILENOTFOUND) = "File '%s' not found (Errcode: %M)";
EE(EE_FILENOTFOUND) = "File '%s' not found (Errcode: %iE)";
EE(EE_FILE_NOT_CLOSED) = "File '%s' (fileno: %d) was not closed";
EE(EE_CHANGE_OWNERSHIP) = "Can't change ownership of the file '%s' (Errcode: %M)";
EE(EE_CHANGE_PERMISSIONS) = "Can't change permissions of the file '%s' (Errcode: %M)";
EE(EE_CANT_SEEK) = "Can't seek in file '%s' (Errcode: %M)";
EE(EE_CANT_CHMOD) = "Can't change mode for file '%s' to 0x%lx (Errcode: %M)";
EE(EE_CANT_COPY_OWNERSHIP)= "Warning: Can't copy ownership for file '%s' (Errcode: %M)";
EE(EE_BADMEMORYRELEASE)= "Failed to release memory pointer %p, %zu bytes (Errcode: %M)";
EE(EE_CHANGE_OWNERSHIP) = "Can't change ownership of the file '%s' (Errcode: %iE)";
EE(EE_CHANGE_PERMISSIONS) = "Can't change permissions of the file '%s' (Errcode: %iE)";
EE(EE_CANT_SEEK) = "Can't seek in file '%s' (Errcode: %iE)";
EE(EE_CANT_CHMOD) = "Can't change mode for file '%s' to 0x%lx (Errcode: %iE)";
EE(EE_CANT_COPY_OWNERSHIP)= "Warning: Can't copy ownership for file '%s' (Errcode: %iE)";
EE(EE_BADMEMORYRELEASE)= "Failed to release memory pointer %p, %zu bytes (Errcode: %iE)";
EE(EE_PERM_LOCK_MEMORY)= "Lock Pages in memory access rights required";
EE(EE_MEMCNTL) = "Memcntl %s cmd %s error";
EE(EE_DUPLICATE_CHARSET)= "Warning: Charset id %d trying to replace csname %s with %s";
Expand Down
8 changes: 4 additions & 4 deletions sql-common/errmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ const char *client_errors[]=
{
"Unknown error",
"Can't create UNIX socket (%d)",
"Can't connect to local server through socket '%-.100s' (%M)",
"Can't connect to server on '%-.100s' (%M)",
"Can't create TCP/IP socket (%M)",
"Can't connect to local server through socket '%-.100s' (%iE)",
"Can't connect to server on '%-.100s' (%iE)",
"Can't create TCP/IP socket (%iE)",
"Unknown server host '%-.100s' (%d)",
"Server has gone away",
"Protocol mismatch; server version = %d, client version = %d",
Expand Down Expand Up @@ -81,7 +81,7 @@ const char *client_errors[]=
"Prepared statement contains no metadata",
"Attempt to read a row while there is no result set associated with the statement",
"This feature is not implemented yet",
"Lost connection to server at '%s', system error: %M",
"Lost connection to server at '%s', system error: %iE",
"Statement closed indirectly because of a preceding %s() call",
"The number of columns in the result set differs from the number of bound buffers. You must reset the statement, rebind the result set columns, and execute the statement again",
"This handle is already connected. Use a separate handle for each connection.",
Expand Down
2 changes: 1 addition & 1 deletion sql/sql_table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10148,7 +10148,7 @@ const char *online_alter_check_supported(const THD *thd,
LEX_CSTRING nxvl{STRING_WITH_LEN("NEXTVAL()")};
size_t len= strlen(fmt) + nxvl.length + c.field_name.length + dflt.length;
char *resp= (char*)thd->alloc(len);
// expression %s cannot be used in the %s clause of %`s
// expression %s cannot be used in the %s clause of %sQ
my_snprintf(resp, len, fmt, nxvl.str, dflt.str, c.field_name.str);
return resp;
}
Expand Down
2 changes: 1 addition & 1 deletion storage/maria/ma_sort.c
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ int _ma_create_index_by_sort(MARIA_SORT_PARAM *info, my_bool no_messages,
if (merge_index(info,keys,sort_keys,dynamic_element(&buffpek,0,BUFFPEK *),
maxbuffer,&tempfile))
{
const char *format= "Got error %M when merging index";
const char *format= "Got error %iE when merging index";
_ma_check_print_error(info->sort_info->param,
format, (int) my_errno);
goto err; /* purecov: inspected */
Expand Down

0 comments on commit 4ffbf1f

Please sign in to comment.