Commit 03094bbc authored by Sergei Golubchik's avatar Sergei Golubchik

cleanup: octet2hex takes an uchar* argument

char is a character, uchar is an octet.
casts removed (or added) as needed
parent d7699c51
...@@ -717,7 +717,7 @@ void scramble(char *to, const char *message, const char *password); ...@@ -717,7 +717,7 @@ void scramble(char *to, const char *message, const char *password);
my_bool check_scramble(const unsigned char *reply, const char *message, my_bool check_scramble(const unsigned char *reply, const char *message,
const unsigned char *hash_stage2); const unsigned char *hash_stage2);
void get_salt_from_password(unsigned char *res, const char *password); void get_salt_from_password(unsigned char *res, const char *password);
char *octet2hex(char *to, const char *str, size_t len); char *octet2hex(char *to, const unsigned char *str, size_t len);
/* end of password.c */ /* end of password.c */
......
...@@ -6547,7 +6547,7 @@ String *Item::check_well_formed_result(String *str, bool send_error) ...@@ -6547,7 +6547,7 @@ String *Item::check_well_formed_result(String *str, bool send_error)
char hexbuf[7]; char hexbuf[7];
uint diff= str->length() - wlen; uint diff= str->length() - wlen;
set_if_smaller(diff, 3); set_if_smaller(diff, 3);
octet2hex(hexbuf, str->ptr() + wlen, diff); octet2hex(hexbuf, (uchar*)str->ptr() + wlen, diff);
if (send_error) if (send_error)
{ {
my_error(ER_INVALID_CHARACTER_STRING, MYF(0), my_error(ER_INVALID_CHARACTER_STRING, MYF(0),
...@@ -6599,7 +6599,7 @@ String_copier_for_item::copy_with_warn(CHARSET_INFO *dstcs, String *dst, ...@@ -6599,7 +6599,7 @@ String_copier_for_item::copy_with_warn(CHARSET_INFO *dstcs, String *dst,
char buf[16]; char buf[16];
int mblen= srccs->charlen(pos, src + src_length); int mblen= srccs->charlen(pos, src + src_length);
DBUG_ASSERT(mblen > 0 && mblen * 2 + 1 <= (int) sizeof(buf)); DBUG_ASSERT(mblen > 0 && mblen * 2 + 1 <= (int) sizeof(buf));
octet2hex(buf, pos, mblen); octet2hex(buf, (uchar*)pos, mblen);
push_warning_printf(m_thd, Sql_condition::WARN_LEVEL_WARN, push_warning_printf(m_thd, Sql_condition::WARN_LEVEL_WARN,
ER_CANNOT_CONVERT_CHARACTER, ER_CANNOT_CONVERT_CHARACTER,
ER_THD(m_thd, ER_CANNOT_CONVERT_CHARACTER), ER_THD(m_thd, ER_CANNOT_CONVERT_CHARACTER),
......
...@@ -259,7 +259,7 @@ static inline bool read_str(const uchar **buf, const uchar *buf_end, ...@@ -259,7 +259,7 @@ static inline bool read_str(const uchar **buf, const uchar *buf_end,
Transforms a string into "" or its expression in X'HHHH' form. Transforms a string into "" or its expression in X'HHHH' form.
*/ */
char *str_to_hex(char *to, const char *from, size_t len) char *str_to_hex(char *to, const uchar *from, size_t len)
{ {
if (len) if (len)
{ {
......
...@@ -3746,7 +3746,7 @@ class Unknown_log_event: public Log_event ...@@ -3746,7 +3746,7 @@ class Unknown_log_event: public Log_event
bool is_valid() const { return 1; } bool is_valid() const { return 1; }
}; };
#endif #endif
char *str_to_hex(char *to, const char *from, size_t len); char *str_to_hex(char *to, const uchar *from, size_t len);
/** /**
@class Annotate_rows_log_event @class Annotate_rows_log_event
......
...@@ -1541,7 +1541,7 @@ bool Rows_log_event::print_verbose(IO_CACHE *file, ...@@ -1541,7 +1541,7 @@ bool Rows_log_event::print_verbose(IO_CACHE *file,
*/ */
const int buff_len= 2 + (256 * 2) + 1; const int buff_len= 2 + (256 * 2) + 1;
char buff[buff_len]; char buff[buff_len];
str_to_hex(buff, (const char*) &m_extra_row_data[EXTRA_ROW_INFO_HDR_BYTES], str_to_hex(buff, &m_extra_row_data[EXTRA_ROW_INFO_HDR_BYTES],
extra_payload_len); extra_payload_len);
if (my_b_printf(file, "%s", buff)) if (my_b_printf(file, "%s", buff))
goto err; goto err;
...@@ -2540,7 +2540,7 @@ bool User_var_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info) ...@@ -2540,7 +2540,7 @@ bool User_var_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info)
hex_str= (char *) my_malloc(PSI_NOT_INSTRUMENTED, 2 * val_len + 1 + 3, MYF(MY_WME)); hex_str= (char *) my_malloc(PSI_NOT_INSTRUMENTED, 2 * val_len + 1 + 3, MYF(MY_WME));
if (!hex_str) if (!hex_str)
goto err; goto err;
str_to_hex(hex_str, val, val_len); str_to_hex(hex_str, (uchar*)val, val_len);
/* /*
For proper behaviour when mysqlbinlog|mysql, we need to explicitly For proper behaviour when mysqlbinlog|mysql, we need to explicitly
specify the variable's collation. It will however cause problems when specify the variable's collation. It will however cause problems when
......
...@@ -503,7 +503,7 @@ int append_query_string(CHARSET_INFO *csinfo, String *to, ...@@ -503,7 +503,7 @@ int append_query_string(CHARSET_INFO *csinfo, String *to,
beg= (char*) to->ptr() + to->length(); beg= (char*) to->ptr() + to->length();
ptr= beg; ptr= beg;
if (csinfo->escape_with_backslash_is_dangerous) if (csinfo->escape_with_backslash_is_dangerous)
ptr= str_to_hex(ptr, str, len); ptr= str_to_hex(ptr, (uchar*)str, len);
else else
{ {
*ptr++= '\''; *ptr++= '\'';
...@@ -3885,7 +3885,7 @@ void User_var_log_event::pack_info(Protocol* protocol) ...@@ -3885,7 +3885,7 @@ void User_var_log_event::pack_info(Protocol* protocol)
MY_CS_COLLATION_NAME_SIZE)) MY_CS_COLLATION_NAME_SIZE))
return; return;
beg= const_cast<char *>(buf.ptr()) + old_len; beg= const_cast<char *>(buf.ptr()) + old_len;
end= str_to_hex(beg, val, val_len); end= str_to_hex(beg, (uchar*)val, val_len);
buf.length(old_len + (end - beg)); buf.length(old_len + (end - beg));
if (buf.append(STRING_WITH_LEN(" COLLATE ")) || if (buf.append(STRING_WITH_LEN(" COLLATE ")) ||
buf.append(cs->coll_name)) buf.append(cs->coll_name))
......
...@@ -296,13 +296,13 @@ void make_password_from_salt_323(char *to, const ulong *salt) ...@@ -296,13 +296,13 @@ void make_password_from_salt_323(char *to, const ulong *salt)
buf+len*2 buf+len*2
*/ */
char *octet2hex(char *to, const char *str, size_t len) char *octet2hex(char *to, const uchar *str, size_t len)
{ {
const char *str_end= str + len; const uchar *str_end= str + len;
for (; str != str_end; ++str) for (; str != str_end; ++str)
{ {
*to++= _dig_vec_upper[((uchar) *str) >> 4]; *to++= _dig_vec_upper[*str >> 4];
*to++= _dig_vec_upper[((uchar) *str) & 0x0F]; *to++= _dig_vec_upper[*str & 0x0F];
} }
*to= '\0'; *to= '\0';
return to; return to;
...@@ -399,7 +399,7 @@ void my_make_scrambled_password(char *to, const char *password, ...@@ -399,7 +399,7 @@ void my_make_scrambled_password(char *to, const char *password,
/* convert hash_stage2 to hex string */ /* convert hash_stage2 to hex string */
*to++= PVERSION41_CHAR; *to++= PVERSION41_CHAR;
octet2hex(to, (const char*) hash_stage2, MY_SHA1_HASH_SIZE); octet2hex(to, hash_stage2, MY_SHA1_HASH_SIZE);
} }
...@@ -519,6 +519,6 @@ void get_salt_from_password(uint8 *hash_stage2, const char *password) ...@@ -519,6 +519,6 @@ void get_salt_from_password(uint8 *hash_stage2, const char *password)
void make_password_from_salt(char *to, const uint8 *hash_stage2) void make_password_from_salt(char *to, const uint8 *hash_stage2)
{ {
*to++= PVERSION41_CHAR; *to++= PVERSION41_CHAR;
octet2hex(to, (const char*) hash_stage2, MY_SHA1_HASH_SIZE); octet2hex(to, hash_stage2, MY_SHA1_HASH_SIZE);
} }
...@@ -603,7 +603,7 @@ int Repl_semi_sync_master::report_reply_packet(uint32 server_id, ...@@ -603,7 +603,7 @@ int Repl_semi_sync_master::report_reply_packet(uint32 server_id,
if (result == -1) if (result == -1)
{ {
char buf[256]; char buf[256];
octet2hex(buf, (const char*) packet, std::min(static_cast<ulong>(sizeof(buf)-1), octet2hex(buf, packet, std::min(static_cast<ulong>(sizeof(buf)-1),
packet_len)); packet_len));
sql_print_information("First bytes of the packet from semisync slave " sql_print_information("First bytes of the packet from semisync slave "
"server-id %d: %s", server_id, buf); "server-id %d: %s", server_id, buf);
......
...@@ -922,7 +922,7 @@ static bool pack_header(THD *thd, uchar *forminfo, ...@@ -922,7 +922,7 @@ static bool pack_header(THD *thd, uchar *forminfo,
hex_length= length * 2; hex_length= length * 2;
tmpint->type_lengths[pos]= (uint) hex_length; tmpint->type_lengths[pos]= (uint) hex_length;
tmpint->type_names[pos]= dst= (char*) thd->alloc(hex_length + 1); tmpint->type_names[pos]= dst= (char*) thd->alloc(hex_length + 1);
octet2hex(dst, src, length); octet2hex(dst, (uchar*)src, length);
} }
} }
......
...@@ -1008,7 +1008,7 @@ static bool emit_key_part_element(String *to, KEY_PART_INFO *part, ...@@ -1008,7 +1008,7 @@ static bool emit_key_part_element(String *to, KEY_PART_INFO *part,
*buf++= '0'; *buf++= '0';
*buf++= 'x'; *buf++= 'x';
buf= octet2hex(buf, (char*) ptr, len); buf= octet2hex(buf, ptr, len);
if (to->append((char*) buff, (uint)(buf - buff))) if (to->append((char*) buff, (uint)(buf - buff)))
DBUG_RETURN(1); DBUG_RETURN(1);
} }
......
...@@ -952,7 +952,7 @@ static bool emit_key_part_element(String *to, KEY_PART_INFO *part, ...@@ -952,7 +952,7 @@ static bool emit_key_part_element(String *to, KEY_PART_INFO *part,
*buf++= '0'; *buf++= '0';
*buf++= 'x'; *buf++= 'x';
buf= octet2hex(buf, (char*) ptr, len); buf= octet2hex(buf, ptr, len);
if (to->append((char*) buff, (uint)(buf - buff))) if (to->append((char*) buff, (uint)(buf - buff)))
DBUG_RETURN(1); DBUG_RETURN(1);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment