diff options
author | unknown <jimw@rama.(none)> | 2006-08-17 12:25:40 -0700 |
---|---|---|
committer | unknown <jimw@rama.(none)> | 2006-08-17 12:25:40 -0700 |
commit | 915bdfbea873dd064edc28905945f2f098bb83e2 (patch) | |
tree | 049d464ebbe02c19d780b0f231fb2b7b2789b6af /include | |
parent | dba52b539acd899e5713b86d92512e16597e72f5 (diff) | |
download | mariadb-git-915bdfbea873dd064edc28905945f2f098bb83e2.tar.gz |
Bug #2717: include/my_global.h mis-defines __attribute__
Fix when __attribute__() is stubbed out, add ATTRIBUTE_FORMAT() for specifying
__attribute__((format(...))) safely, make more use of the format attribute,
and fix some of the warnings that this turns up (plus a bonus unrelated one).
include/m_ctype.h:
Add ATTRIBUTE_FORMAT to printf-like functions.
include/m_string.h:
Add ATTRIBUTE_FORMAT to my_snprintf() declaration.
include/my_global.h:
Fix neutering of __attribute__() on old versions of GCC and non-GCC compilers.
Add ATTRIBUTE_FORMAT() macro for setting __attribute_((format(...)), since it
is available from different versions of gcc and g++.
include/my_sys.h:
Add ATTRIBUTE_FORMAT() to my_printf_error declaration
sql/item_subselect.cc:
Silence warning about members being initialized out-of-order
sql/item_timefunc.cc:
Fix format specifier in snprintf() calls with milliseconds
sql/mysql_priv.h:
Add ATTRIBUTE_FORMAT to printf-like functions.
sql/mysqld.cc:
Fix various format specifiers
Make sure that method_conv is always set by myisam_stats_method
sql/opt_range.cc:
Cast pointers to correct type for %lx
sql/set_var.cc:
Fix __attribute__((unused)) (missing inner set of parens)
sql/slave.cc:
Fix format specifier
sql/slave.h:
Add ATTRIBUTE_FORMAT to slave_print_error() declaration.
sql/sql_acl.cc:
Fix number of arguments passed for formatting, and fix acl_host_or_ip being
passed instead of just the hostname.
sql/sql_class.h:
Add ATTRIBUTE_FORMAT to MYSQL_LOG::write().
Diffstat (limited to 'include')
-rw-r--r-- | include/m_ctype.h | 5 | ||||
-rw-r--r-- | include/m_string.h | 3 | ||||
-rw-r--r-- | include/my_global.h | 22 | ||||
-rw-r--r-- | include/my_sys.h | 4 |
4 files changed, 28 insertions, 6 deletions
diff --git a/include/m_ctype.h b/include/m_ctype.h index cd1dac9dde8..b2bf8d3e30f 100644 --- a/include/m_ctype.h +++ b/include/m_ctype.h @@ -175,7 +175,7 @@ typedef struct my_charset_handler_st /* Charset dependant snprintf() */ int (*snprintf)(struct charset_info_st *, char *to, uint n, const char *fmt, - ...); + ...) ATTRIBUTE_FORMAT(printf, 4, 5); int (*long10_to_str)(struct charset_info_st *, char *to, uint n, int radix, long int val); int (*longlong10_to_str)(struct charset_info_st *, char *to, uint n, @@ -300,7 +300,8 @@ int my_wc_mb_8bit(CHARSET_INFO *cs,my_wc_t wc, uchar *s, uchar *e); ulong my_scan_8bit(CHARSET_INFO *cs, const char *b, const char *e, int sq); int my_snprintf_8bit(struct charset_info_st *, char *to, uint n, - const char *fmt, ...); + const char *fmt, ...) + ATTRIBUTE_FORMAT(printf, 4, 5); long my_strntol_8bit(CHARSET_INFO *, const char *s, uint l, int base, char **e, int *err); diff --git a/include/m_string.h b/include/m_string.h index d7edff4f626..08408c372b5 100644 --- a/include/m_string.h +++ b/include/m_string.h @@ -247,7 +247,8 @@ extern ulonglong strtoull(const char *str, char **ptr, int base); extern int my_vsnprintf( char *str, size_t n, const char *format, va_list ap ); -extern int my_snprintf(char* to, size_t n, const char* fmt, ...); +extern int my_snprintf(char *to, size_t n, const char *fmt, ...) + ATTRIBUTE_FORMAT(printf, 3, 4); #if defined(__cplusplus) && !defined(OS2) } diff --git a/include/my_global.h b/include/my_global.h index 6baa4558d50..2fbb1db4b77 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -414,14 +414,34 @@ typedef unsigned short ushort; #define function_volatile volatile #define my_reinterpret_cast(A) reinterpret_cast<A> #define my_const_cast(A) const_cast<A> +# ifndef GCC_VERSION +# define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__) +# endif #elif !defined(my_reinterpret_cast) #define my_reinterpret_cast(A) (A) #define my_const_cast(A) (A) #endif -#if !defined(__attribute__) && (defined(__cplusplus) || !defined(__GNUC__) || __GNUC__ == 2 && __GNUC_MINOR__ < 8) + +/* + Disable __attribute__() on GCC < 2.7 and non-GCC compilers +*/ +#if !defined(__attribute__) && (!defined(__GNUC__) || GCC_VERSION < 2007) #define __attribute__(A) #endif +/* + __attribute__((format(...))) is only supported in gcc >= 2.8 and g++ >= 3.4 +*/ +#ifndef ATTRIBUTE_FORMAT +# if defined(__GNUC__) && \ + ((!defined(__cplusplus__) && GCC_VERSION >= 2008) || \ + GCC_VERSION >= 3004) +# define ATTRIBUTE_FORMAT(style, m, n) __attribute__((format(style, m, n))) +# else +# define ATTRIBUTE_FORMAT(style, m, n) +# endif +#endif + /* From old s-system.h */ /* diff --git a/include/my_sys.h b/include/my_sys.h index 02ea188a18e..46e09e8ddf4 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -588,8 +588,8 @@ extern int my_chsize(File fd,my_off_t newlength, int filler, myf MyFlags); extern int my_sync(File fd, myf my_flags); extern int my_error _VARARGS((int nr,myf MyFlags, ...)); extern int my_printf_error _VARARGS((uint my_err, const char *format, - myf MyFlags, ...) - __attribute__ ((format (printf, 2, 4)))); + myf MyFlags, ...)) + ATTRIBUTE_FORMAT(printf, 2, 4); extern int my_message(uint my_err, const char *str,myf MyFlags); extern int my_message_no_curses(uint my_err, const char *str,myf MyFlags); extern int my_message_curses(uint my_err, const char *str,myf MyFlags); |