1
0
mirror of https://github.com/MariaDB/server.git synced 2025-04-18 21:44:20 +03:00

Reënable ATTRIBUTE_FORMAT on DBUG_PRINT & t/eprint

(Re)ënable the `ATTRIBUTE_FORMAT` on `my_dbug.h`’s `_db_doprnt_`
(better known by its frontend `DBUG_PRINT`) and `ma_recovery_util.h`’s
`tprint` & `eprint` to leverage GCC `-Wformat` checking

c4bf4b7aef introduced `WAITING_FOR_BUGFIX_TO_VSPRINTF` to conditionally
(read: temporarily) disable their `ATTRIBUTE_FORMAT`s.
Whatever that bug was aside, MDEV-21978 Zulip suggested that the
preference for `%b` was probably intended, although c52e62a76f
reverted the one in `storage/maria/ma_recovery.c` back to `%s`.

All extension migrations (e.g., `%b` ➡ `%sB`)
in this commit were on `DBUG_PRINT`.
This commit is contained in:
ParadoxV5 2024-08-05 14:39:09 -06:00 committed by Sergei Golubchik
parent d5ba6f71b9
commit 21dfef474c
5 changed files with 7 additions and 15 deletions

View File

@ -298,7 +298,8 @@ static void Indent(CODE_STATE *cs, int indent);
static void DbugFlush(CODE_STATE *); static void DbugFlush(CODE_STATE *);
static void DbugExit(const char *why); static void DbugExit(const char *why);
static const char *DbugStrTok(const char *s); static const char *DbugStrTok(const char *s);
static void DbugVfprintf(FILE *stream, const char* format, va_list args); static void DbugVfprintf(FILE *stream, const char* format, va_list args)
ATTRIBUTE_FORMAT(printf, 2, 0);
/* /*
* Miscellaneous printf format strings. * Miscellaneous printf format strings.

View File

@ -51,11 +51,7 @@ extern void _db_enter_(const char *_func_, const char *_file_, uint _line_,
struct _db_stack_frame_ *_stack_frame_); struct _db_stack_frame_ *_stack_frame_);
extern void _db_return_(struct _db_stack_frame_ *_stack_frame_); extern void _db_return_(struct _db_stack_frame_ *_stack_frame_);
extern int _db_pargs_(uint _line_,const char *keyword); extern int _db_pargs_(uint _line_,const char *keyword);
extern void _db_doprnt_(const char *format,...) extern void _db_doprnt_(const char *format, ...) ATTRIBUTE_FORMAT(printf, 1, 2);
#ifdef WAITING_FOR_BUGFIX_TO_VSPRINTF
ATTRIBUTE_FORMAT(printf, 1, 2)
#endif
;
extern void _db_dump_(uint _line_,const char *keyword, extern void _db_dump_(uint _line_,const char *keyword,
const unsigned char *memory, size_t length); const unsigned char *memory, size_t length);
extern void _db_end_(void); extern void _db_end_(void);

View File

@ -3177,7 +3177,7 @@ Rows_log_event::Rows_log_event(const uchar *buf, uint event_len,
uchar *ptr_after_width= (uchar*) ptr_width; uchar *ptr_after_width= (uchar*) ptr_width;
DBUG_PRINT("debug", ("Reading from %p", ptr_after_width)); DBUG_PRINT("debug", ("Reading from %p", ptr_after_width));
m_width= net_field_length(&ptr_after_width); m_width= net_field_length(&ptr_after_width);
DBUG_PRINT("debug", ("m_width=%lu", m_width)); DBUG_PRINT("debug", ("m_width=%u", m_width));
/* Avoid reading out of buffer */ /* Avoid reading out of buffer */
if (ptr_after_width + (m_width + 7) / 8 > (uchar*)buf + event_len) if (ptr_after_width + (m_width + 7) / 8 > (uchar*)buf + event_len)
@ -3240,7 +3240,7 @@ Rows_log_event::Rows_log_event(const uchar *buf, uint event_len,
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
} }
size_t const data_size= event_len - read_size; size_t const data_size= event_len - read_size;
DBUG_PRINT("info",("m_table_id: %llu m_flags: %d m_width: %lu data_size: %lu", DBUG_PRINT("info",("m_table_id: %llu m_flags: %d m_width: %u data_size: %lu",
m_table_id, m_flags, m_width, (ulong) data_size)); m_table_id, m_flags, m_width, (ulong) data_size));
m_rows_buf= (uchar*) my_malloc(PSI_INSTRUMENT_ME, data_size, MYF(MY_WME)); m_rows_buf= (uchar*) my_malloc(PSI_INSTRUMENT_ME, data_size, MYF(MY_WME));

View File

@ -1485,7 +1485,7 @@ bool Protocol_text::store_str(const char *from, size_t length,
CHARSET_INFO *fromcs, CHARSET_INFO *tocs) CHARSET_INFO *fromcs, CHARSET_INFO *tocs)
{ {
#ifndef DBUG_OFF #ifndef DBUG_OFF
DBUG_PRINT("info", ("Protocol_text::store field %u : %.*b", field_pos, DBUG_PRINT("info", ("Protocol_text::store field %u : %.*sB", field_pos,
(int) length, (length == 0 ? "" : from))); (int) length, (length == 0 ? "" : from)));
DBUG_ASSERT(field_handlers == 0 || field_pos < field_count); DBUG_ASSERT(field_handlers == 0 || field_pos < field_count);
DBUG_ASSERT(valid_handler(field_pos, PROTOCOL_SEND_STRING)); DBUG_ASSERT(valid_handler(field_pos, PROTOCOL_SEND_STRING));
@ -1501,7 +1501,7 @@ bool Protocol_text::store_numeric_zerofill_str(const char *from,
{ {
#ifndef DBUG_OFF #ifndef DBUG_OFF
DBUG_PRINT("info", DBUG_PRINT("info",
("Protocol_text::store_numeric_zerofill_str field %u : %.*b", ("Protocol_text::store_numeric_zerofill_str field %u : %.*sB",
field_pos, (int) length, (length == 0 ? "" : from))); field_pos, (int) length, (length == 0 ? "" : from)));
DBUG_ASSERT(field_handlers == 0 || field_pos < field_count); DBUG_ASSERT(field_handlers == 0 || field_pos < field_count);
DBUG_ASSERT(valid_handler(field_pos, send_type)); DBUG_ASSERT(valid_handler(field_pos, send_type));

View File

@ -31,12 +31,7 @@ extern FILE *tracef;
my_bool _ma_redo_not_needed_for_page(uint16 shortid, LSN lsn, my_bool _ma_redo_not_needed_for_page(uint16 shortid, LSN lsn,
pgcache_page_no_t page, pgcache_page_no_t page,
my_bool index); my_bool index);
#ifdef WAITING_FOR_BUGFIX_TO_VSPRINTF
void tprint(FILE *trace_file, const char *format, ...) void tprint(FILE *trace_file, const char *format, ...)
ATTRIBUTE_FORMAT(printf, 2, 3); ATTRIBUTE_FORMAT(printf, 2, 3);
void eprint(FILE *trace_file, const char *format, ...) void eprint(FILE *trace_file, const char *format, ...)
ATTRIBUTE_FORMAT(printf, 2, 3); ATTRIBUTE_FORMAT(printf, 2, 3);
#else
void tprint(FILE *trace_file, const char *format, ...);
void eprint(FILE *trace_file, const char *format, ...);
#endif