summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavi Arnaut <Davi.Arnaut@Sun.COM>2010-07-09 09:00:17 -0300
committerDavi Arnaut <Davi.Arnaut@Sun.COM>2010-07-09 09:00:17 -0300
commit11fae04527098cb6c266eae41188504bd22a5b52 (patch)
tree92777d90b1eaff5ab0cb99603ecd3c4abf18d145
parentcd37b73fe5107098c669fcbf569e9f20de013141 (diff)
downloadmariadb-git-11fae04527098cb6c266eae41188504bd22a5b52.tar.gz
Bug#45288: pb2 returns a lot of compilation warnings on linux
Although the C standard mandates that sprintf return the number of bytes written, some very ancient systems (i.e. SunOS 4) returned a pointer to the buffer instead. Since these systems are not supported anymore and are hopefully long dead by now, simply remove the portability wrapper that dealt with this discrepancy. The autoconf check was causing trouble with GCC.
-rw-r--r--client/mysqlbinlog.cc2
-rw-r--r--client/mysqlcheck.c3
-rw-r--r--client/sql_string.cc5
-rw-r--r--configure.in34
-rw-r--r--include/my_global.h11
-rw-r--r--sql-common/my_time.c23
-rw-r--r--sql/field.cc10
-rw-r--r--sql/item_timefunc.cc24
-rw-r--r--sql/log_event.cc32
-rw-r--r--sql/my_decimal.cc8
-rw-r--r--sql/partition_info.cc6
-rw-r--r--sql/protocol.cc24
-rw-r--r--sql/sql_acl.cc10
-rw-r--r--sql/sql_analyse.cc10
-rw-r--r--sql/sql_show.cc2
-rw-r--r--sql/sql_string.cc5
-rw-r--r--storage/federated/ha_federated.cc17
-rw-r--r--strings/decimal.c2
-rw-r--r--tests/mysql_client_test.c26
19 files changed, 90 insertions, 164 deletions
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc
index 30bdb58153f..dec3f142798 100644
--- a/client/mysqlbinlog.cc
+++ b/client/mysqlbinlog.cc
@@ -437,7 +437,7 @@ Exit_status Load_log_processor::process_first_event(const char *bname,
ptr= fname + target_dir_name_len;
memcpy(ptr,bname,blen);
ptr+= blen;
- ptr+= my_sprintf(ptr, (ptr, "-%x", file_id));
+ ptr+= sprintf(ptr, "-%x", file_id);
if ((file= create_unique_file(fname,ptr)) < 0)
{
diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c
index 4183ab1dd5e..78c4b79085e 100644
--- a/client/mysqlcheck.c
+++ b/client/mysqlcheck.c
@@ -703,8 +703,7 @@ static int handle_request_for_tables(char *tables, uint length)
if (opt_all_in_1)
{
/* No backticks here as we added them before */
- query_length= my_sprintf(query,
- (query, "%s TABLE %s %s", op, tables, options));
+ query_length= sprintf(query, "%s TABLE %s %s", op, tables, options);
}
else
{
diff --git a/client/sql_string.cc b/client/sql_string.cc
index dc6147b563f..50fb4a5b777 100644
--- a/client/sql_string.cc
+++ b/client/sql_string.cc
@@ -122,7 +122,8 @@ bool String::set(double num,uint decimals, CHARSET_INFO *cs)
str_charset=cs;
if (decimals >= NOT_FIXED_DEC)
{
- uint32 len= my_sprintf(buff,(buff, "%.15g",num));// Enough for a DATETIME
+ // Enough for a DATETIME
+ uint32 len= sprintf(buff, "%.15g", num);
return copy(buff, len, &my_charset_latin1, cs, &dummy_errors);
}
#ifdef HAVE_FCONVERT
@@ -674,7 +675,7 @@ void String::qs_append(const char *str, uint32 len)
void String::qs_append(double d)
{
char *buff = Ptr + str_length;
- str_length+= my_sprintf(buff, (buff, "%.15g", d));
+ str_length+= sprintf(buff, buff, "%.15g", d);
}
void String::qs_append(double *d)
diff --git a/configure.in b/configure.in
index bc1d7df6703..0264c351b07 100644
--- a/configure.in
+++ b/configure.in
@@ -278,40 +278,6 @@ AC_CHECK_PROGS(YACC, ['bison -y -p MYSQL'])
AC_CHECK_PROG(PDFMANUAL, pdftex, manual.pdf)
AC_CHECK_PROG(DVIS, tex, manual.dvi)
-#check the return type of sprintf
-AC_MSG_CHECKING("return type of sprintf")
-AC_TRY_RUN([
- int main()
- {
- char* s = "hello";
- char buf[6];
- if((int)sprintf(buf, s) == strlen(s))
- return 0;
-
- return -1;
- }
- ],
- [AC_DEFINE(SPRINTF_RETURNS_INT, [1], [POSIX sprintf])
- AC_MSG_RESULT("int")],
- [AC_TRY_RUN([
- int main()
- {
- char* s = "hello";
- char buf[6];
- if((char*)sprintf(buf,s) == buf + strlen(s))
- return 0;
- return -1;
- } ],
- [AC_DEFINE(SPRINTF_RETURNS_PTR, [1], [Broken sprintf])
- AC_MSG_RESULT("ptr")],
- [AC_DEFINE(SPRINTF_RETURNS_GARBAGE, [1], [Broken sprintf])
- AC_MSG_RESULT("garbage")]
- )],
- # Cross compile, assume POSIX
- [AC_DEFINE(SPRINTF_RETURNS_INT, [1], [POSIX sprintf])
- AC_MSG_RESULT("int (we assume)")]
-)
-
AC_PATH_PROG(uname_prog, uname, no)
# We should go through this and put all the explictly system dependent
diff --git a/include/my_global.h b/include/my_global.h
index 572df6a584d..f03ed665d5a 100644
--- a/include/my_global.h
+++ b/include/my_global.h
@@ -1467,17 +1467,6 @@ do { doubleget_union _tmp; \
#endif /* WORDS_BIGENDIAN */
-/* sprintf does not always return the number of bytes :- */
-#ifdef SPRINTF_RETURNS_INT
-#define my_sprintf(buff,args) sprintf args
-#else
-#ifdef SPRINTF_RETURNS_PTR
-#define my_sprintf(buff,args) ((int)(sprintf args - buff))
-#else
-#define my_sprintf(buff,args) ((ulong) sprintf args, (ulong) strlen(buff))
-#endif
-#endif
-
#ifndef THREAD
#define thread_safe_increment(V,L) (V)++
#define thread_safe_decrement(V,L) (V)--
diff --git a/sql-common/my_time.c b/sql-common/my_time.c
index 95078a50097..c4e917801d5 100644
--- a/sql-common/my_time.c
+++ b/sql-common/my_time.c
@@ -1024,30 +1024,21 @@ void set_zero_time(MYSQL_TIME *tm, enum enum_mysql_timestamp_type time_type)
int my_time_to_str(const MYSQL_TIME *l_time, char *to)
{
uint extra_hours= 0;
- return my_sprintf(to, (to, "%s%02u:%02u:%02u",
- (l_time->neg ? "-" : ""),
- extra_hours+ l_time->hour,
- l_time->minute,
- l_time->second));
+ return sprintf(to, "%s%02u:%02u:%02u", (l_time->neg ? "-" : ""),
+ extra_hours+ l_time->hour, l_time->minute, l_time->second);
}
int my_date_to_str(const MYSQL_TIME *l_time, char *to)
{
- return my_sprintf(to, (to, "%04u-%02u-%02u",
- l_time->year,
- l_time->month,
- l_time->day));
+ return sprintf(to, "%04u-%02u-%02u",
+ l_time->year, l_time->month, l_time->day);
}
int my_datetime_to_str(const MYSQL_TIME *l_time, char *to)
{
- return my_sprintf(to, (to, "%04u-%02u-%02u %02u:%02u:%02u",
- l_time->year,
- l_time->month,
- l_time->day,
- l_time->hour,
- l_time->minute,
- l_time->second));
+ return sprintf(to, "%04u-%02u-%02u %02u:%02u:%02u",
+ l_time->year, l_time->month, l_time->day,
+ l_time->hour, l_time->minute, l_time->second);
}
diff --git a/sql/field.cc b/sql/field.cc
index 2229bc19b3c..c648b53e139 100644
--- a/sql/field.cc
+++ b/sql/field.cc
@@ -2277,7 +2277,7 @@ int Field_decimal::store(double nr)
snprintf(buff,sizeof(buff)-1, "%.*f",(int) dec,nr);
length= strlen(buff);
#else
- length= my_sprintf(buff,(buff,"%.*f",dec,nr));
+ length= sprintf(buff, "%.*f", dec, nr);
#endif
if (length > field_length)
@@ -4259,7 +4259,7 @@ String *Field_float::val_str(String *val_buffer,
snprintf(to,to_length-1,"%.*f",dec,nr);
to=strend(to);
#else
- to+= my_sprintf(to,(to,"%.*f",dec,nr));
+ to+= sprintf(to, "%.*f", dec, nr);
#endif
#endif
}
@@ -4617,7 +4617,7 @@ String *Field_double::val_str(String *val_buffer,
snprintf(to,to_length-1,"%.*f",dec,nr);
to=strend(to);
#else
- to+= my_sprintf(to,(to,"%.*f",dec,nr));
+ to+= sprintf(to, "%.*f", dec, nr);
#endif
#endif
}
@@ -6461,7 +6461,7 @@ int Field_str::store(double nr)
/* Limit precision to DBL_DIG to avoid garbage past significant digits */
set_if_smaller(digits, DBL_DIG);
- length= (uint) my_sprintf(buff, (buff, "%-.*g", digits, nr));
+ length= (uint) sprintf(buff, "%-.*g", digits, nr);
#ifdef __WIN__
/*
@@ -10419,7 +10419,7 @@ Field::set_datetime_warning(MYSQL_ERROR::enum_warning_level level, uint code,
{
/* DBL_DIG is enough to print '-[digits].E+###' */
char str_nr[DBL_DIG + 8];
- uint str_len= my_sprintf(str_nr, (str_nr, "%g", nr));
+ uint str_len= sprintf(str_nr, "%g", nr);
make_truncated_value_warning(thd, level, str_nr, str_len, ts_type,
field_name);
}
diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc
index 4248c2e6b4f..dff4d20f347 100644
--- a/sql/item_timefunc.cc
+++ b/sql/item_timefunc.cc
@@ -754,13 +754,11 @@ bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time,
str->append(hours_i < 12 ? "AM" : "PM",2);
break;
case 'r':
- length= my_sprintf(intbuff,
- (intbuff,
- ((l_time->hour % 24) < 12) ?
- "%02d:%02d:%02d AM" : "%02d:%02d:%02d PM",
- (l_time->hour+11)%12+1,
- l_time->minute,
- l_time->second));
+ length= sprintf(intbuff, ((l_time->hour % 24) < 12) ?
+ "%02d:%02d:%02d AM" : "%02d:%02d:%02d PM",
+ (l_time->hour+11)%12+1,
+ l_time->minute,
+ l_time->second);
str->append(intbuff, length);
break;
case 'S':
@@ -769,12 +767,8 @@ bool make_date_time(DATE_TIME_FORMAT *format, MYSQL_TIME *l_time,
str->append_with_prefill(intbuff, length, 2, '0');
break;
case 'T':
- length= my_sprintf(intbuff,
- (intbuff,
- "%02d:%02d:%02d",
- l_time->hour,
- l_time->minute,
- l_time->second));
+ length= sprintf(intbuff, "%02d:%02d:%02d",
+ l_time->hour, l_time->minute, l_time->second);
str->append(intbuff, length);
break;
case 'U':
@@ -2985,12 +2979,12 @@ String *Item_func_maketime::val_str(String *str)
char buf[28];
char *ptr= longlong10_to_str(hour, buf, args[0]->unsigned_flag ? 10 : -10);
int len = (int)(ptr - buf) +
- my_sprintf(ptr, (ptr, ":%02u:%02u", (uint)minute, (uint)second));
+ sprintf(ptr, ":%02u:%02u", (uint) minute, (uint) second);
make_truncated_value_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
buf, len, MYSQL_TIMESTAMP_TIME,
NullS);
}
-
+
if (make_time_with_warn((DATE_TIME_FORMAT *) 0, &ltime, str))
{
null_value= 1;
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 93d170e1510..7becdf51747 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -1664,17 +1664,17 @@ beg:
int i, end;
char buff[512], *pos;
pos= buff;
- pos+= my_sprintf(buff, (buff, "%s", dec.sign() ? "-" : ""));
+ pos+= sprintf(buff, "%s", dec.sign() ? "-" : "");
end= ROUND_UP(dec.frac) + ROUND_UP(dec.intg)-1;
for (i=0; i < end; i++)
- pos+= my_sprintf(pos, (pos, "%09d.", dec.buf[i]));
- pos+= my_sprintf(pos, (pos, "%09d", dec.buf[i]));
+ pos+= sprintf(pos, "%09d.", dec.buf[i]);
+ pos+= sprintf(pos, "%09d", dec.buf[i]);
my_b_printf(file, "%s", buff);
my_snprintf(typestr, typestr_length, "DECIMAL(%d,%d)",
precision, decimals);
return bin_size;
}
-
+
case MYSQL_TYPE_FLOAT:
{
float fl;
@@ -5481,8 +5481,7 @@ void User_var_log_event::pack_info(Protocol* protocol)
if (!(buf= (char*) my_malloc(val_offset + FLOATING_POINT_BUFFER,
MYF(MY_WME))))
return;
- event_len+= my_sprintf(buf + val_offset,
- (buf + val_offset, "%.14g", real_val));
+ event_len+= sprintf(buf + val_offset, "%.14g", real_val);
break;
case INT_RESULT:
if (!(buf= (char*) my_malloc(val_offset + 22, MYF(MY_WME))))
@@ -5664,7 +5663,7 @@ void User_var_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info)
double real_val;
char real_buf[FMT_G_BUFSIZE(14)];
float8get(real_val, val);
- my_sprintf(real_buf, (real_buf, "%.14g", real_val));
+ sprintf(real_buf, "%.14g", real_val);
my_b_printf(&cache, ":=%s%s\n", real_buf, print_event_info->delimiter);
break;
case INT_RESULT:
@@ -6414,10 +6413,9 @@ void Append_block_log_event::print(FILE* file,
void Append_block_log_event::pack_info(Protocol *protocol)
{
char buf[256];
- uint length;
- length= (uint) my_sprintf(buf,
- (buf, ";file_id=%u;block_len=%u", file_id,
- block_len));
+ size_t length;
+ length= my_snprintf(buf, sizeof(buf), ";file_id=%u;block_len=%u",
+ file_id, block_len);
protocol->store(buf, length, &my_charset_bin);
}
@@ -6566,9 +6564,9 @@ void Delete_file_log_event::print(FILE* file,
void Delete_file_log_event::pack_info(Protocol *protocol)
{
char buf[64];
- uint length;
- length= (uint) my_sprintf(buf, (buf, ";file_id=%u", (uint) file_id));
- protocol->store(buf, (int32) length, &my_charset_bin);
+ size_t length;
+ length= my_snprintf(buf, sizeof(buf), ";file_id=%u", (uint) file_id);
+ protocol->store(buf, length, &my_charset_bin);
}
#endif
@@ -6664,9 +6662,9 @@ void Execute_load_log_event::print(FILE* file,
void Execute_load_log_event::pack_info(Protocol *protocol)
{
char buf[64];
- uint length;
- length= (uint) my_sprintf(buf, (buf, ";file_id=%u", (uint) file_id));
- protocol->store(buf, (int32) length, &my_charset_bin);
+ size_t length;
+ length= my_snprintf(buf, sizeof(buf), ";file_id=%u", (uint) file_id);
+ protocol->store(buf, length, &my_charset_bin);
}
diff --git a/sql/my_decimal.cc b/sql/my_decimal.cc
index 208ddefb890..3aa01880b83 100644
--- a/sql/my_decimal.cc
+++ b/sql/my_decimal.cc
@@ -249,12 +249,12 @@ print_decimal(const my_decimal *dec)
int i, end;
char buff[512], *pos;
pos= buff;
- pos+= my_sprintf(buff, (buff, "Decimal: sign: %d intg: %d frac: %d { ",
- dec->sign(), dec->intg, dec->frac));
+ pos+= sprintf(buff, "Decimal: sign: %d intg: %d frac: %d { ",
+ dec->sign(), dec->intg, dec->frac);
end= ROUND_UP(dec->frac)+ROUND_UP(dec->intg)-1;
for (i=0; i < end; i++)
- pos+= my_sprintf(pos, (pos, "%09d, ", dec->buf[i]));
- pos+= my_sprintf(pos, (pos, "%09d }\n", dec->buf[i]));
+ pos+= sprintf(pos, "%09d, ", dec->buf[i]);
+ pos+= sprintf(pos, "%09d }\n", dec->buf[i]);
fputs(buff, DBUG_FILE);
}
diff --git a/sql/partition_info.cc b/sql/partition_info.cc
index 6e2f7dfad26..d85888e295c 100644
--- a/sql/partition_info.cc
+++ b/sql/partition_info.cc
@@ -103,8 +103,8 @@ char *partition_info::create_default_partition_names(uint part_no,
{
do
{
- my_sprintf(move_ptr, (move_ptr,"p%u", (start_no + i)));
- move_ptr+=MAX_PART_NAME_SIZE;
+ sprintf(move_ptr, "p%u", (start_no + i));
+ move_ptr+= MAX_PART_NAME_SIZE;
} while (++i < no_parts_arg);
}
else
@@ -135,7 +135,7 @@ char *partition_info::create_subpartition_name(uint subpart_no,
if (likely(ptr != NULL))
{
- my_sprintf(ptr, (ptr, "%ssp%u", part_name, subpart_no));
+ my_snprintf(ptr, size_alloc, "%ssp%u", part_name, subpart_no);
}
else
{
diff --git a/sql/protocol.cc b/sql/protocol.cc
index dc53e029647..eaf01ecd550 100644
--- a/sql/protocol.cc
+++ b/sql/protocol.cc
@@ -1003,16 +1003,12 @@ bool Protocol_text::store(MYSQL_TIME *tm)
#endif
char buff[40];
uint length;
- length= my_sprintf(buff,(buff, "%04d-%02d-%02d %02d:%02d:%02d",
- (int) tm->year,
- (int) tm->month,
- (int) tm->day,
- (int) tm->hour,
- (int) tm->minute,
- (int) tm->second));
+ length= sprintf(buff, "%04d-%02d-%02d %02d:%02d:%02d",
+ (int) tm->year, (int) tm->month,
+ (int) tm->day, (int) tm->hour,
+ (int) tm->minute, (int) tm->second);
if (tm->second_part)
- length+= my_sprintf(buff+length,(buff+length, ".%06d",
- (int)tm->second_part));
+ length+= sprintf(buff+length, ".%06d", (int) tm->second_part);
return net_store_data((uchar*) buff, length);
}
@@ -1046,13 +1042,11 @@ bool Protocol_text::store_time(MYSQL_TIME *tm)
char buff[40];
uint length;
uint day= (tm->year || tm->month) ? 0 : tm->day;
- length= my_sprintf(buff,(buff, "%s%02ld:%02d:%02d",
- tm->neg ? "-" : "",
- (long) day*24L+(long) tm->hour,
- (int) tm->minute,
- (int) tm->second));
+ length= sprintf(buff, "%s%02ld:%02d:%02d", tm->neg ? "-" : "",
+ (long) day*24L+(long) tm->hour, (int) tm->minute,
+ (int) tm->second);
if (tm->second_part)
- length+= my_sprintf(buff+length,(buff+length, ".%06d", (int)tm->second_part));
+ length+= sprintf(buff+length, ".%06d", (int) tm->second_part);
return net_store_data((uchar*) buff, length);
}
diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc
index 9640b8db1b2..90eef872115 100644
--- a/sql/sql_acl.cc
+++ b/sql/sql_acl.cc
@@ -1653,12 +1653,10 @@ bool change_password(THD *thd, const char *host, const char *user,
result= 0;
if (mysql_bin_log.is_open())
{
- query_length=
- my_sprintf(buff,
- (buff,"SET PASSWORD FOR '%-.120s'@'%-.120s'='%-.120s'",
- acl_user->user ? acl_user->user : "",
- acl_user->host.hostname ? acl_user->host.hostname : "",
- new_password));
+ query_length= sprintf(buff, "SET PASSWORD FOR '%-.120s'@'%-.120s'='%-.120s'",
+ acl_user->user ? acl_user->user : "",
+ acl_user->host.hostname ? acl_user->host.hostname : "",
+ new_password);
thd->clear_error();
result= thd->binlog_query(THD::MYSQL_QUERY_TYPE, buff, query_length,
FALSE, FALSE, 0);
diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc
index d273b3319ee..29ba956bf6c 100644
--- a/sql/sql_analyse.cc
+++ b/sql/sql_analyse.cc
@@ -408,7 +408,7 @@ void field_real::add()
if ((decs = decimals()) == NOT_FIXED_DEC)
{
- length= my_sprintf(buff, (buff, "%g", num));
+ length= sprintf(buff, "%g", num);
if (rint(num) != num)
max_notzero_dec_len = 1;
}
@@ -419,7 +419,7 @@ void field_real::add()
snprintf(buff, sizeof(buff)-1, "%-.*f", (int) decs, num);
length = (uint) strlen(buff);
#else
- length= my_sprintf(buff, (buff, "%-.*f", (int) decs, num));
+ length= sprintf(buff, "%-.*f", (int) decs, num);
#endif
// We never need to check further than this
@@ -1006,9 +1006,9 @@ void field_decimal::get_opt_type(String *answer,
my_decimal_set_zero(&zero);
my_bool is_unsigned= (my_decimal_cmp(&zero, &min_arg) >= 0);
- length= my_sprintf(buff, (buff, "DECIMAL(%d, %d)",
- (int) (max_length - (item->decimals ? 1 : 0)),
- item->decimals));
+ length= my_snprintf(buff, sizeof(buff), "DECIMAL(%d, %d)",
+ (int) (max_length - (item->decimals ? 1 : 0)),
+ item->decimals);
if (is_unsigned)
length= (uint) (strmov(buff+length, " UNSIGNED")- buff);
answer->append(buff, length);
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 17fbf62b097..ca0d16697cd 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -2278,7 +2278,7 @@ static bool show_status_array(THD *thd, const char *wild,
value= ((char *) status_var + (ulong) value);
/* fall through */
case SHOW_DOUBLE:
- end= buff + my_sprintf(buff, (buff, "%f", *(double*) value));
+ end= buff + sprintf(buff, "%f", *(double*) value);
break;
case SHOW_LONG_STATUS:
value= ((char *) status_var + (ulong) value);
diff --git a/sql/sql_string.cc b/sql/sql_string.cc
index 7c9793b273b..a41f4d52101 100644
--- a/sql/sql_string.cc
+++ b/sql/sql_string.cc
@@ -112,7 +112,8 @@ bool String::set_real(double num,uint decimals, CHARSET_INFO *cs)
str_charset=cs;
if (decimals >= NOT_FIXED_DEC)
{
- uint32 len= my_sprintf(buff,(buff, "%.15g",num));// Enough for a DATETIME
+ // Enough for a DATETIME
+ uint32 len= sprintf(buff, "%.15g", num);
return copy(buff, len, &my_charset_latin1, cs, &dummy_errors);
}
#ifdef HAVE_FCONVERT
@@ -676,7 +677,7 @@ void String::qs_append(const char *str, uint32 len)
void String::qs_append(double d)
{
char *buff = Ptr + str_length;
- str_length+= my_sprintf(buff, (buff, "%.15g", d));
+ str_length+= sprintf(buff, "%.15g", d);
}
void String::qs_append(double *d)
diff --git a/storage/federated/ha_federated.cc b/storage/federated/ha_federated.cc
index 955c35ad71b..e881b253274 100644
--- a/storage/federated/ha_federated.cc
+++ b/storage/federated/ha_federated.cc
@@ -561,7 +561,6 @@ static int parse_url_error(FEDERATED_SHARE *share, TABLE *table, int error_num)
int get_connection(MEM_ROOT *mem_root, FEDERATED_SHARE *share)
{
int error_num= ER_FOREIGN_SERVER_DOESNT_EXIST;
- char error_buffer[FEDERATED_QUERY_BUFFER_SIZE];
FOREIGN_SERVER *server, server_buffer;
DBUG_ENTER("ha_federated::get_connection");
@@ -613,10 +612,8 @@ int get_connection(MEM_ROOT *mem_root, FEDERATED_SHARE *share)
DBUG_RETURN(0);
error:
- my_sprintf(error_buffer,
- (error_buffer, "server name: '%s' doesn't exist!",
- share->connection_string));
- my_error(error_num, MYF(0), error_buffer);
+ my_printf_error(error_num, "server name: '%s' doesn't exist!",
+ MYF(0), share->connection_string);
DBUG_RETURN(error_num);
}
@@ -2405,8 +2402,8 @@ int ha_federated::index_read_idx_with_result_set(uchar *buf, uint index,
if (real_query(sql_query.ptr(), sql_query.length()))
{
- my_sprintf(error_buffer, (error_buffer, "error: %d '%s'",
- mysql_errno(mysql), mysql_error(mysql)));
+ sprintf(error_buffer, "error: %d '%s'",
+ mysql_errno(mysql), mysql_error(mysql));
retval= ER_QUERY_ON_FOREIGN_DATA_SOURCE;
goto error;
}
@@ -2775,7 +2772,6 @@ int ha_federated::rnd_pos(uchar *buf, uchar *pos)
int ha_federated::info(uint flag)
{
- char error_buffer[FEDERATED_QUERY_BUFFER_SIZE];
char status_buf[FEDERATED_QUERY_BUFFER_SIZE];
int error;
uint error_code;
@@ -2859,9 +2855,8 @@ error:
mysql_free_result(result);
if (mysql)
{
- my_sprintf(error_buffer, (error_buffer, ": %d : %s",
- mysql_errno(mysql), mysql_error(mysql)));
- my_error(error_code, MYF(0), error_buffer);
+ my_printf_error(error_code, ": %d : %s", MYF(0),
+ mysql_errno(mysql), mysql_error(mysql));
}
else
if (remote_error_number != -1 /* error already reported */)
diff --git a/strings/decimal.c b/strings/decimal.c
index d6c33baf713..4403fc9fd6b 100644
--- a/strings/decimal.c
+++ b/strings/decimal.c
@@ -994,7 +994,7 @@ int double2decimal(double from, decimal_t *to)
char buff[400], *end;
int length, res;
DBUG_ENTER("double2decimal");
- length= my_sprintf(buff, (buff, "%.16G", from));
+ length= sprintf(buff, "%.16G", from);
DBUG_PRINT("info",("from: %g from_as_str: %s", from, buff));
end= buff+length;
res= string2decimal(buff, to, &end);
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c
index c492db723b0..00389d431fa 100644
--- a/tests/mysql_client_test.c
+++ b/tests/mysql_client_test.c
@@ -1685,7 +1685,7 @@ static void test_prepare()
/* now, execute the prepared statement to insert 10 records.. */
for (tiny_data= 0; tiny_data < 100; tiny_data++)
{
- length[1]= my_sprintf(str_data, (str_data, "MySQL%d", int_data));
+ length[1]= sprintf(str_data, "MySQL%d", int_data);
rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc);
int_data += 25;
@@ -1724,7 +1724,7 @@ static void test_prepare()
/* now, execute the prepared statement to insert 10 records.. */
for (o_tiny_data= 0; o_tiny_data < 100; o_tiny_data++)
{
- len= my_sprintf(data, (data, "MySQL%d", o_int_data));
+ len= sprintf(data, "MySQL%d", o_int_data);
rc= mysql_stmt_fetch(stmt);
check_execute(stmt, rc);
@@ -3090,7 +3090,7 @@ static void test_simple_update()
my_bind[0].buffer= szData; /* string data */
my_bind[0].buffer_length= sizeof(szData);
my_bind[0].length= &length[0];
- length[0]= my_sprintf(szData, (szData, "updated-data"));
+ length[0]= sprintf(szData, "updated-data");
my_bind[1].buffer= (void *) &nData;
my_bind[1].buffer_type= MYSQL_TYPE_LONG;
@@ -3286,7 +3286,7 @@ static void test_long_data_str()
DIE_UNLESS(rc == 1);
mysql_free_result(result);
- my_sprintf(data, (data, "%d", i*5));
+ sprintf(data, "%d", i*5);
verify_col_data("test_long_data_str", "LENGTH(longstr)", data);
data[0]= '\0';
while (i--)
@@ -3344,7 +3344,7 @@ static void test_long_data_str1()
rc= mysql_stmt_bind_param(stmt, my_bind);
check_execute(stmt, rc);
- length= my_sprintf(data, (data, "MySQL AB"));
+ length= sprintf(data, "MySQL AB");
/* supply data in pieces */
for (i= 0; i < 3; i++)
@@ -3384,10 +3384,10 @@ static void test_long_data_str1()
DIE_UNLESS(rc == 1);
mysql_free_result(result);
- my_sprintf(data, (data, "%ld", (long)i*length));
+ sprintf(data, "%ld", (long)i*length);
verify_col_data("test_long_data_str", "length(longstr)", data);
- my_sprintf(data, (data, "%d", i*2));
+ sprintf(data, "%d", i*2);
verify_col_data("test_long_data_str", "length(blb)", data);
/* Test length of field->max_length */
@@ -3659,7 +3659,7 @@ static void test_update()
my_bind[0].buffer= szData;
my_bind[0].buffer_length= sizeof(szData);
my_bind[0].length= &length[0];
- length[0]= my_sprintf(szData, (szData, "inserted-data"));
+ length[0]= sprintf(szData, "inserted-data");
my_bind[1].buffer= (void *)&nData;
my_bind[1].buffer_type= MYSQL_TYPE_LONG;
@@ -3688,7 +3688,7 @@ static void test_update()
my_bind[0].buffer= szData;
my_bind[0].buffer_length= sizeof(szData);
my_bind[0].length= &length[0];
- length[0]= my_sprintf(szData, (szData, "updated-data"));
+ length[0]= sprintf(szData, "updated-data");
my_bind[1].buffer= (void *)&nData;
my_bind[1].buffer_type= MYSQL_TYPE_LONG;
@@ -4257,7 +4257,7 @@ static void bind_fetch(int row_count)
/* CHAR */
{
char buff[20];
- long len= my_sprintf(buff, (buff, "%d", rc));
+ long len= sprintf(buff, "%d", rc);
DIE_UNLESS(strcmp(s_data, buff) == 0);
DIE_UNLESS(length[6] == (ulong) len);
}
@@ -4850,7 +4850,7 @@ static void test_insert()
/* now, execute the prepared statement to insert 10 records.. */
for (tiny_data= 0; tiny_data < 3; tiny_data++)
{
- length= my_sprintf(str_data, (str_data, "MySQL%d", tiny_data));
+ length= sprintf(str_data, "MySQL%d", tiny_data);
rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc);
}
@@ -17512,7 +17512,7 @@ static void test_wl4166_1()
/* now, execute the prepared statement to insert 10 records.. */
for (tiny_data= 0; tiny_data < 10; tiny_data++)
{
- length[1]= my_sprintf(str_data, (str_data, "MySQL%d", int_data));
+ length[1]= sprintf(str_data, "MySQL%d", int_data);
rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc);
int_data += 25;
@@ -17535,7 +17535,7 @@ static void test_wl4166_1()
for (tiny_data= 50; tiny_data < 60; tiny_data++)
{
- length[1]= my_sprintf(str_data, (str_data, "MySQL%d", int_data));
+ length[1]= sprintf(str_data, "MySQL%d", int_data);
rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc);
int_data += 25;