1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-29 05:21:33 +03:00

WL#3817: Simplify string / memory area types and make things more consistent (first part)

The following type conversions was done:

- Changed byte to uchar
- Changed gptr to uchar*
- Change my_string to char *
- Change my_size_t to size_t
- Change size_s to size_t

Removed declaration of byte, gptr, my_string, my_size_t and size_s. 

Following function parameter changes was done:
- All string functions in mysys/strings was changed to use size_t
  instead of uint for string lengths.
- All read()/write() functions changed to use size_t (including vio).
- All protocoll functions changed to use size_t instead of uint
- Functions that used a pointer to a string length was changed to use size_t*
- Changed malloc(), free() and related functions from using gptr to use void *
  as this requires fewer casts in the code and is more in line with how the
  standard functions work.
- Added extra length argument to dirname_part() to return the length of the
  created string.
- Changed (at least) following functions to take uchar* as argument:
  - db_dump()
  - my_net_write()
  - net_write_command()
  - net_store_data()
  - DBUG_DUMP()
  - decimal2bin() & bin2decimal()
- Changed my_compress() and my_uncompress() to use size_t. Changed one
  argument to my_uncompress() from a pointer to a value as we only return
  one value (makes function easier to use).
- Changed type of 'pack_data' argument to packfrm() to avoid casts.
- Changed in readfrm() and writefrom(), ha_discover and handler::discover()
  the type for argument 'frmdata' to uchar** to avoid casts.
- Changed most Field functions to use uchar* instead of char* (reduced a lot of
  casts).
- Changed field->val_xxx(xxx, new_ptr) to take const pointers.

Other changes:
- Removed a lot of not needed casts
- Added a few new cast required by other changes
- Added some cast to my_multi_malloc() arguments for safety (as string lengths
  needs to be uint, not size_t).
- Fixed all calls to hash-get-key functions to use size_t*. (Needed to be done
  explicitely as this conflict was often hided by casting the function to
  hash_get_key).
- Changed some buffers to memory regions to uchar* to avoid casts.
- Changed some string lengths from uint to size_t.
- Changed field->ptr to be uchar* instead of char*. This allowed us to
  get rid of a lot of casts.
- Some changes from true -> TRUE, false -> FALSE, unsigned char -> uchar
- Include zlib.h in some files as we needed declaration of crc32()
- Changed MY_FILE_ERROR to be (size_t) -1.
- Changed many variables to hold the result of my_read() / my_write() to be
  size_t. This was needed to properly detect errors (which are
  returned as (size_t) -1).
- Removed some very old VMS code
- Changed packfrm()/unpackfrm() to not be depending on uint size
  (portability fix)
- Removed windows specific code to restore cursor position as this
  causes slowdown on windows and we should not mix read() and pread()
  calls anyway as this is not thread safe. Updated function comment to
  reflect this. Changed function that depended on original behavior of
  my_pwrite() to itself restore the cursor position (one such case).
- Added some missing checking of return value of malloc().
- Changed definition of MOD_PAD_CHAR_TO_FULL_LENGTH to avoid 'long' overflow.
- Changed type of table_def::m_size from my_size_t to ulong to reflect that
  m_size is the number of elements in the array, not a string/memory
  length.
- Moved THD::max_row_length() to table.cc (as it's not depending on THD).
  Inlined max_row_length_blob() into this function.
- More function comments
- Fixed some compiler warnings when compiled without partitions.
- Removed setting of LEX_STRING() arguments in declaration (portability fix).
- Some trivial indentation/variable name changes.
- Some trivial code simplifications:
  - Replaced some calls to alloc_root + memcpy to use
    strmake_root()/strdup_root().
  - Changed some calls from memdup() to strmake() (Safety fix)
  - Simpler loops in client-simple.c
This commit is contained in:
monty@mysql.com/narttu.mysql.fi
2007-05-10 12:59:39 +03:00
parent 9078e630c6
commit 088e2395f1
474 changed files with 8476 additions and 8346 deletions

View File

@ -44,12 +44,12 @@ const uint Buffer::MAX_BUFFER_SIZE= 16777216;
1 - got an error in reserve()
*/
int Buffer::append(uint position, const char *string, uint len_arg)
int Buffer::append(size_t position, const char *string, size_t len_arg)
{
if (reserve(position, len_arg))
return 1;
strnmov(buffer + position, string, len_arg);
strnmov((char*) buffer + position, string, len_arg);
return 0;
}
@ -75,20 +75,20 @@ int Buffer::append(uint position, const char *string, uint len_arg)
1 - realloc error or we have come to the 16Mb barrier
*/
int Buffer::reserve(uint position, uint len_arg)
int Buffer::reserve(size_t position, size_t len_arg)
{
if (position + len_arg >= MAX_BUFFER_SIZE)
goto err;
if (position + len_arg >= buffer_size)
{
buffer= (char*) my_realloc(buffer,
buffer= (uchar*) my_realloc(buffer,
min(MAX_BUFFER_SIZE,
max((uint) (buffer_size*1.5),
position + len_arg)), MYF(0));
if (!(buffer))
goto err;
buffer_size= (uint) (buffer_size*1.5);
buffer_size= (size_t) (buffer_size*1.5);
}
return 0;

View File

@ -45,7 +45,7 @@ public:
/*
As append() will invokes realloc() anyway, it's ok if malloc returns 0
*/
if (!(buffer= (char*) my_malloc(buffer_size, MYF(0))))
if (!(buffer= (uchar*) my_malloc(buffer_size, MYF(0))))
buffer_size= 0;
}
@ -55,11 +55,11 @@ public:
}
public:
char *buffer;
uchar *buffer;
int get_size();
int is_error();
int append(uint position, const char *string, uint len_arg);
int reserve(uint position, uint len_arg);
int append(size_t position, const char *string, size_t len_arg);
int reserve(size_t position, size_t len_arg);
};
#endif /* INCLUDES_MYSQL_INSTANCE_MANAGER_BUFFER_H */

View File

@ -170,7 +170,7 @@ int Show_instances::write_data(st_net *net)
while ((instance= iterator.next()))
{
Buffer send_buf; /* buffer for packets */
uint pos= 0;
size_t pos= 0;
instance->lock();
@ -356,7 +356,7 @@ int Show_instance_status::write_data(st_net *net, Instance *instance)
{
Buffer send_buf; /* buffer for packets */
char version_num_buf[MAX_VERSION_LENGTH];
uint pos= 0;
size_t pos= 0;
const char *state_name= instance->get_state_name();
const char *version_tag= "unknown";
@ -379,7 +379,7 @@ int Show_instance_status::write_data(st_net *net, Instance *instance)
store_to_protocol_packet(&send_buf, version_num, &pos) ||
store_to_protocol_packet(&send_buf, version_tag, &pos) ||
store_to_protocol_packet(&send_buf, mysqld_compatible_status, &pos) ||
my_net_write(net, send_buf.buffer, (uint) pos))
my_net_write(net, send_buf.buffer, pos))
{
return ER_OUT_OF_RESOURCES;
}
@ -455,7 +455,7 @@ int Show_instance_options::write_header(st_net *net)
int Show_instance_options::write_data(st_net *net, Instance *instance)
{
Buffer send_buff; /* buffer for packets */
uint pos= 0;
size_t pos= 0;
if (store_to_protocol_packet(&send_buff, "instance_name", &pos) ||
store_to_protocol_packet(&send_buff, get_instance_name()->str, &pos) ||
@ -618,7 +618,7 @@ bool Create_instance::init(const char **text)
bool Create_instance::parse_args(const char **text)
{
uint len;
size_t len;
/* Check if we have something (and trim leading spaces). */
@ -991,13 +991,13 @@ int Show_instance_log::write_header(st_net *net)
int Show_instance_log::write_data(st_net *net, Instance *instance)
{
Buffer send_buff; /* buffer for packets */
uint pos= 0;
size_t pos= 0;
const char *logpath= instance->options.logs[log_type];
File fd;
size_t buff_size;
int read_len;
size_t read_len;
MY_STAT file_stat;
Buffer read_buff;
@ -1020,8 +1020,8 @@ int Show_instance_log::write_data(st_net *net, Instance *instance)
/* read in one chunk */
read_len= (int)my_seek(fd, file_stat.st_size - size, MY_SEEK_SET, MYF(0));
if ((read_len= my_read(fd, (byte*) read_buff.buffer,
buff_size, MYF(0))) < 0)
if ((read_len= my_read(fd, read_buff.buffer, buff_size, MYF(0))) ==
MY_FILE_ERROR)
{
close(fd);
return ER_READ_FILE;
@ -1029,7 +1029,8 @@ int Show_instance_log::write_data(st_net *net, Instance *instance)
close(fd);
if (store_to_protocol_packet(&send_buff, read_buff.buffer, &pos, read_len) ||
if (store_to_protocol_packet(&send_buff, (char*) read_buff.buffer, &pos,
read_len) ||
my_net_write(net, send_buff.buffer, pos))
{
return ER_OUT_OF_RESOURCES;
@ -1142,7 +1143,7 @@ int Show_instance_log_files::write_data(st_net *net, Instance *instance)
enum { LOG_NAME_BUFFER_SIZE= 20 };
char buff[LOG_NAME_BUFFER_SIZE];
uint pos= 0;
size_t pos= 0;
const char *log_path= "";
const char *log_size= "0";
@ -1227,12 +1228,12 @@ bool Instance_options_list::init()
C_MODE_START
static byte* get_item_key(const byte* item, uint* len,
my_bool __attribute__((unused)) t)
static uchar* get_item_key(const uchar* item, size_t* len,
my_bool __attribute__((unused)) t)
{
const Instance_options_list *lst= (const Instance_options_list *) item;
*len= lst->get_instance_name()->length;
return (byte *) lst->get_instance_name()->str;
return (uchar *) lst->get_instance_name()->str;
}
static void delete_item(void *item)
@ -1358,7 +1359,7 @@ Abstract_option_cmd::get_instance_options_list(const LEX_STRING *instance_name)
{
Instance_options_list *lst=
(Instance_options_list *) hash_search(&instance_options_map,
(byte *) instance_name->str,
(uchar *) instance_name->str,
instance_name->length);
if (!lst)
@ -1368,7 +1369,7 @@ Abstract_option_cmd::get_instance_options_list(const LEX_STRING *instance_name)
if (!lst)
return NULL;
if (lst->init() || my_hash_insert(&instance_options_map, (byte *) lst))
if (lst->init() || my_hash_insert(&instance_options_map, (uchar *) lst))
{
delete lst;
return NULL;
@ -1458,7 +1459,7 @@ int Abstract_option_cmd::execute_impl(st_net *net, ulong connection_id)
bool Set_option::parse_args(const char **text)
{
uint len;
size_t len;
/* Check if we have something (and trim leading spaces). */
@ -1632,7 +1633,7 @@ int Set_option::process_option(Instance *instance, Named_value *option)
bool Unset_option::parse_args(const char **text)
{
uint len;
size_t len;
/* Check if we have something (and trim leading spaces). */

View File

@ -37,12 +37,12 @@ C_MODE_START
HASH-routines: get key of instance for storing in hash.
*/
static byte* get_instance_key(const byte* u, uint* len,
my_bool __attribute__((unused)) t)
static uchar* get_instance_key(const uchar* u, size_t* len,
my_bool __attribute__((unused)) t)
{
const Instance *instance= (const Instance *) u;
*len= instance->options.instance_name.length;
return (byte *) instance->options.instance_name.str;
return (uchar *) instance->options.instance_name.str;
}
/**
@ -165,7 +165,7 @@ int Instance_map::process_one_option(const LEX_STRING *group,
return 0;
}
if (!(instance= (Instance *) hash_search(&hash, (byte *) group->str,
if (!(instance= (Instance *) hash_search(&hash, (uchar *) group->str,
group->length)))
{
if (!(instance= new Instance()))
@ -332,7 +332,7 @@ bool Instance_map::is_there_active_instance()
int Instance_map::add_instance(Instance *instance)
{
return my_hash_insert(&hash, (byte *) instance);
return my_hash_insert(&hash, (uchar *) instance);
}
@ -344,7 +344,7 @@ int Instance_map::add_instance(Instance *instance)
int Instance_map::remove_instance(Instance *instance)
{
return hash_delete(&hash, (byte *) instance);
return hash_delete(&hash, (uchar *) instance);
}
@ -425,7 +425,7 @@ int Instance_map::create_instance(const LEX_STRING *instance_name,
Instance * Instance_map::find(const LEX_STRING *name)
{
return (Instance *) hash_search(&hash, (byte *) name->str, name->length);
return (Instance *) hash_search(&hash, (uchar *) name->str, name->length);
}
@ -603,12 +603,12 @@ int create_instance_in_file(const LEX_STRING *instance_name,
return ER_ACCESS_OPTION_FILE;
}
if (my_write(cnf_file, (byte*)NEWLINE, NEWLINE_LEN, MYF(MY_NABP)) ||
my_write(cnf_file, (byte*)"[", 1, MYF(MY_NABP)) ||
my_write(cnf_file, (byte*)instance_name->str, instance_name->length,
if (my_write(cnf_file, (uchar*)NEWLINE, NEWLINE_LEN, MYF(MY_NABP)) ||
my_write(cnf_file, (uchar*)"[", 1, MYF(MY_NABP)) ||
my_write(cnf_file, (uchar*)instance_name->str, instance_name->length,
MYF(MY_NABP)) ||
my_write(cnf_file, (byte*)"]", 1, MYF(MY_NABP)) ||
my_write(cnf_file, (byte*)NEWLINE, NEWLINE_LEN, MYF(MY_NABP)))
my_write(cnf_file, (uchar*)"]", 1, MYF(MY_NABP)) ||
my_write(cnf_file, (uchar*)NEWLINE, NEWLINE_LEN, MYF(MY_NABP)))
{
log_error("Can not write to configuration file (%s): %s.",
(const char *) Options::Main::config_file,
@ -631,8 +631,8 @@ int create_instance_in_file(const LEX_STRING *instance_name,
option_str_len= ptr - option_str;
if (my_write(cnf_file, (byte*)option_str, option_str_len, MYF(MY_NABP)) ||
my_write(cnf_file, (byte*)NEWLINE, NEWLINE_LEN, MYF(MY_NABP)))
if (my_write(cnf_file, (uchar*)option_str, option_str_len, MYF(MY_NABP)) ||
my_write(cnf_file, (uchar*)NEWLINE, NEWLINE_LEN, MYF(MY_NABP)))
{
log_error("Can not write to configuration file (%s): %s.",
(const char *) Options::Main::config_file,

View File

@ -156,7 +156,7 @@ int Instance_options::get_default_option(char *result, size_t result_len,
goto err;
/* +2 eats first "--" from the option string (E.g. "--datadir") */
rc= parse_output_and_get_value(cmd.buffer, option_name + 2,
rc= parse_output_and_get_value((char*) cmd.buffer, option_name + 2,
result, result_len, GET_VALUE);
err:
return rc;
@ -194,7 +194,7 @@ bool Instance_options::fill_instance_version()
bzero(result, MAX_VERSION_LENGTH);
if (parse_output_and_get_value(cmd.buffer, "Ver", result,
if (parse_output_and_get_value((char*) cmd.buffer, "Ver", result,
MAX_VERSION_LENGTH, GET_LINE))
{
log_error("Failed to get version of '%s': unexpected output.",
@ -255,7 +255,7 @@ bool Instance_options::fill_mysqld_real_path()
bzero(result, FN_REFLEN);
if (parse_output_and_get_value(cmd.buffer, "Usage: ",
if (parse_output_and_get_value((char*) cmd.buffer, "Usage: ",
result, FN_REFLEN,
GET_LINE))
{
@ -466,13 +466,9 @@ bool Instance_options::complete_initialization()
Need to copy the path to allocated memory, as convert_dirname() might
need to change it
*/
mysqld_path.str=
alloc_root(&alloc, strlen(Options::Main::default_mysqld_path) + 1);
mysqld_path.str= strdup_root(&alloc, Options::Main::default_mysqld_path);
if (!mysqld_path.str)
return TRUE;
strcpy(mysqld_path.str, Options::Main::default_mysqld_path);
}
mysqld_path.length= strlen(mysqld_path.str);

View File

@ -147,12 +147,12 @@ int Mysql_connection::check_connection()
ulong pkt_len=0; // to hold client reply length
/* buffer for the first packet */ /* packet contains: */
char buff[MAX_VERSION_LENGTH + 1 + // server version, 0-ended
4 + // connection id
SCRAMBLE_LENGTH + 2 + // scramble (in 2 pieces)
18]; // server variables: flags,
uchar buff[MAX_VERSION_LENGTH + 1 + // server version, 0-ended
4 + // connection id
SCRAMBLE_LENGTH + 2 + // scramble (in 2 pieces)
18]; // server variables: flags,
// charset number, status,
char *pos= buff;
uchar *pos= buff;
ulong server_flags;
memcpy(pos, mysqlmanager_version.str, mysqlmanager_version.length + 1);
@ -195,7 +195,8 @@ int Mysql_connection::check_connection()
/* write connection message and read reply */
enum { MIN_HANDSHAKE_SIZE= 2 };
if (net_write_command(&net, protocol_version, "", 0, buff, pos - buff) ||
if (net_write_command(&net, protocol_version, (uchar*) "", 0,
buff, pos - buff) ||
(pkt_len= my_net_read(&net)) == packet_error ||
pkt_len < MIN_HANDSHAKE_SIZE)
{
@ -211,17 +212,17 @@ int Mysql_connection::check_connection()
}
client_capabilities|= ((ulong) uint2korr(net.read_pos + 2)) << 16;
pos= (char*) net.read_pos + 32;
pos= net.read_pos + 32;
/* At least one byte for username and one byte for password */
if (pos >= (char*) net.read_pos + pkt_len + 2)
if (pos >= net.read_pos + pkt_len + 2)
{
/*TODO add user and password handling in error messages*/
net_send_error(&net, ER_HANDSHAKE_ERROR);
return 1;
}
const char *user= pos;
const char *user= (char*) pos;
const char *password= strend(user)+1;
ulong password_len= *password++;
LEX_STRING user_name= { (char *) user, password - user - 2 };

View File

@ -152,14 +152,14 @@ static struct my_option my_long_options[] =
#ifndef __WIN__
{ "angel-pid-file", OPT_ANGEL_PID_FILE, "Pid file for angel process.",
(gptr *) &Options::Daemon::angel_pid_file_name,
(gptr *) &Options::Daemon::angel_pid_file_name,
(uchar* *) &Options::Daemon::angel_pid_file_name,
(uchar* *) &Options::Daemon::angel_pid_file_name,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
#endif
{ "bind-address", OPT_BIND_ADDRESS, "Bind address to use for connection.",
(gptr *) &Options::Main::bind_address,
(gptr *) &Options::Main::bind_address,
(uchar* *) &Options::Main::bind_address,
(uchar* *) &Options::Main::bind_address,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "check-password-file", OPT_CHECK_PASSWORD_FILE,
@ -172,15 +172,15 @@ static struct my_option my_long_options[] =
#ifndef DBUG_OFF
{"debug", '#', "Debug log.",
(gptr *) &Options::Debug::config_str,
(gptr *) &Options::Debug::config_str,
(uchar* *) &Options::Debug::config_str,
(uchar* *) &Options::Debug::config_str,
0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0},
#endif
{ "default-mysqld-path", OPT_MYSQLD_PATH, "Where to look for MySQL"
" Server binary.",
(gptr *) &Options::Main::default_mysqld_path,
(gptr *) &Options::Main::default_mysqld_path,
(uchar* *) &Options::Main::default_mysqld_path,
(uchar* *) &Options::Main::default_mysqld_path,
0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0 },
{ "drop-user", OPT_DROP_USER,
@ -193,8 +193,8 @@ static struct my_option my_long_options[] =
#ifdef __WIN__
{ "install", OPT_INSTALL_SERVICE, "Install as system service.",
(gptr *) &Options::Service::install_as_service,
(gptr *) &Options::Service::install_as_service,
(uchar* *) &Options::Service::install_as_service,
(uchar* *) &Options::Service::install_as_service,
0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 0, 0 },
#endif
@ -204,22 +204,22 @@ static struct my_option my_long_options[] =
#ifndef __WIN__
{ "log", OPT_LOG, "Path to log file. Used only with --run-as-service.",
(gptr *) &Options::Daemon::log_file_name,
(gptr *) &Options::Daemon::log_file_name,
(uchar* *) &Options::Daemon::log_file_name,
(uchar* *) &Options::Daemon::log_file_name,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
#endif
{ "monitoring-interval", OPT_MONITORING_INTERVAL, "Interval to monitor"
" instances in seconds.",
(gptr *) &Options::Main::monitoring_interval,
(gptr *) &Options::Main::monitoring_interval,
(uchar* *) &Options::Main::monitoring_interval,
(uchar* *) &Options::Main::monitoring_interval,
0, GET_UINT, REQUIRED_ARG, DEFAULT_MONITORING_INTERVAL,
0, 0, 0, 0, 0 },
{ "mysqld-safe-compatible", OPT_MYSQLD_SAFE_COMPATIBLE,
"Start Instance Manager in mysqld_safe compatible manner",
(gptr *) &Options::Main::mysqld_safe_compatible,
(gptr *) &Options::Main::mysqld_safe_compatible,
(uchar* *) &Options::Main::mysqld_safe_compatible,
(uchar* *) &Options::Main::mysqld_safe_compatible,
0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 0, 0 },
{ "print-password-line", OPT_PRINT_PASSWORD_LINE,
@ -227,61 +227,61 @@ static struct my_option my_long_options[] =
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 },
{ "password", OPT_PASSWORD, "Password to update the password file",
(gptr *) &Options::User_management::password,
(gptr *) &Options::User_management::password,
(uchar* *) &Options::User_management::password,
(uchar* *) &Options::User_management::password,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "password-file", OPT_PASSWORD_FILE,
"Look for Instance Manager users and passwords here.",
(gptr *) &Options::Main::password_file_name,
(gptr *) &Options::Main::password_file_name,
(uchar* *) &Options::Main::password_file_name,
(uchar* *) &Options::Main::password_file_name,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "pid-file", OPT_PID_FILE, "Pid file to use.",
(gptr *) &Options::Main::pid_file_name,
(gptr *) &Options::Main::pid_file_name,
(uchar* *) &Options::Main::pid_file_name,
(uchar* *) &Options::Main::pid_file_name,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "port", OPT_PORT, "Port number to use for connections",
(gptr *) &Options::Main::port_number,
(gptr *) &Options::Main::port_number,
(uchar* *) &Options::Main::port_number,
(uchar* *) &Options::Main::port_number,
0, GET_UINT, REQUIRED_ARG, DEFAULT_PORT, 0, 0, 0, 0, 0 },
#ifdef __WIN__
{ "remove", OPT_REMOVE_SERVICE, "Remove system service.",
(gptr *) &Options::Service::remove_service,
(gptr *) &Options::Service::remove_service,
(uchar* *) &Options::Service::remove_service,
(uchar* *) &Options::Service::remove_service,
0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 0, 0},
#else
{ "run-as-service", OPT_RUN_AS_SERVICE,
"Daemonize and start angel process.",
(gptr *) &Options::Daemon::run_as_service,
(uchar* *) &Options::Daemon::run_as_service,
0, 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 0, 0 },
#endif
#ifndef __WIN__
{ "socket", OPT_SOCKET, "Socket file to use for connection.",
(gptr *) &Options::Main::socket_file_name,
(gptr *) &Options::Main::socket_file_name,
(uchar* *) &Options::Main::socket_file_name,
(uchar* *) &Options::Main::socket_file_name,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
#endif
#ifdef __WIN__
{ "standalone", OPT_STAND_ALONE, "Run the application in stand alone mode.",
(gptr *) &Options::Service::stand_alone,
(gptr *) &Options::Service::stand_alone,
(uchar* *) &Options::Service::stand_alone,
(uchar* *) &Options::Service::stand_alone,
0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 0, 0},
#else
{ "user", OPT_USER, "Username to start mysqlmanager",
(gptr *) &Options::Daemon::user,
(gptr *) &Options::Daemon::user,
(uchar* *) &Options::Daemon::user,
(uchar* *) &Options::Daemon::user,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
#endif
{ "username", OPT_USERNAME,
"Username to update the password file",
(gptr *) &Options::User_management::user_name,
(gptr *) &Options::User_management::user_name,
(uchar* *) &Options::User_management::user_name,
(uchar* *) &Options::User_management::user_name,
0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },
{ "version", 'V', "Output version information and exit.", 0, 0, 0,
@ -289,8 +289,8 @@ static struct my_option my_long_options[] =
{ "wait-timeout", OPT_WAIT_TIMEOUT, "The number of seconds IM waits "
"for activity on a connection before closing it.",
(gptr *) &net_read_timeout,
(gptr *) &net_read_timeout,
(uchar* *) &net_read_timeout,
(uchar* *) &net_read_timeout,
0, GET_ULONG, REQUIRED_ARG, NET_WAIT_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0 },
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 }

View File

@ -105,7 +105,7 @@ Named_value_arr::~Named_value_arr()
TOK_NOT_FOUND
*/
inline Token find_token(const char *word, uint word_len)
inline Token find_token(const char *word, size_t word_len)
{
int i= 0;
do
@ -119,7 +119,7 @@ inline Token find_token(const char *word, uint word_len)
}
Token get_token(const char **text, uint *word_len)
Token get_token(const char **text, size_t *word_len)
{
get_word(text, word_len);
if (*word_len)
@ -128,7 +128,7 @@ Token get_token(const char **text, uint *word_len)
}
Token shift_token(const char **text, uint *word_len)
Token shift_token(const char **text, size_t *word_len)
{
Token save= get_token(text, word_len);
(*text)+= *word_len;
@ -157,7 +157,7 @@ static bool parse_long(const LEX_STRING *token, long *value)
}
bool parse_option_value(const char *text, uint *text_len, char **value)
bool parse_option_value(const char *text, size_t *text_len, char **value)
{
char beginning_quote;
const char *text_start_ptr;
@ -270,7 +270,7 @@ void skip_spaces(const char **text)
Command *parse_command(const char *text)
{
uint word_len;
size_t word_len;
LEX_STRING instance_name;
Command *command= 0;

View File

@ -30,7 +30,7 @@ enum Log_type
Command *parse_command(const char *text);
bool parse_option_value(const char *text, uint *text_len, char **value);
bool parse_option_value(const char *text, size_t *text_len, char **value);
void skip_spaces(const char **text);
@ -138,7 +138,7 @@ inline Named_value Named_value_arr::get_element(int idx) const
DBUG_ASSERT(0 <= idx && (uint) idx < arr.elements);
Named_value option;
get_dynamic((DYNAMIC_ARRAY *) &arr, (gptr) &option, idx);
get_dynamic((DYNAMIC_ARRAY *) &arr, (uchar*) &option, idx);
return option;
}
@ -156,7 +156,7 @@ inline void Named_value_arr::remove_element(int idx)
inline bool Named_value_arr::add_element(Named_value *option)
{
return insert_dynamic(&arr, (gptr) option);
return insert_dynamic(&arr, (uchar*) option);
}
@ -166,7 +166,7 @@ inline bool Named_value_arr::replace_element(int idx, Named_value *option)
get_element(idx).free();
return set_dynamic(&arr, (gptr) option, idx);
return set_dynamic(&arr, (uchar*) option, idx);
}
/************************************************************************/
@ -177,7 +177,7 @@ inline bool Named_value_arr::replace_element(int idx, Named_value *option)
if not found returns pointer to first non-space or to '\0', word_len == 0
*/
inline void get_word(const char **text, uint *word_len,
inline void get_word(const char **text, size_t *word_len,
enum_seek_method seek_method= ALPHANUM)
{
const char *word_end;

View File

@ -21,7 +21,7 @@
#include <m_string.h>
static char eof_buff[1]= { (char) 254 }; /* Marker for end of fields */
static uchar eof_buff[1]= { (char) 254 }; /* Marker for end of fields */
static const char ERROR_PACKET_CODE= (char) 255;
@ -38,7 +38,7 @@ int net_send_ok(struct st_net *net, unsigned long connection_id,
1-9 + message length message to send (isn't stored if no message)
*/
Buffer buff;
char *pos= buff.buffer;
uchar *pos= buff.buffer;
/* check that we have space to hold mandatory fields */
buff.reserve(0, 23);
@ -53,7 +53,7 @@ int net_send_ok(struct st_net *net, unsigned long connection_id,
int2store(pos, 0);
pos+= 2;
uint position= pos - buff.buffer; /* we might need it for message */
size_t position= pos - buff.buffer; /* we might need it for message */
if (message != NULL)
{
@ -82,7 +82,8 @@ int net_send_error(struct st_net *net, uint sql_errno)
memcpy(pos, errno_to_sqlstate(sql_errno), SQLSTATE_LENGTH);
pos+= SQLSTATE_LENGTH;
pos= strmake(pos, err, MYSQL_ERRMSG_SIZE - 1) + 1;
return my_net_write(net, buff, pos - buff) || net_flush(net);
return (my_net_write(net, (uchar*) buff, (size_t) (pos - buff)) ||
net_flush(net));
}
@ -98,7 +99,8 @@ int net_send_error_323(struct st_net *net, uint sql_errno)
int2store(pos, sql_errno);
pos+= 2;
pos= strmake(pos, err, MYSQL_ERRMSG_SIZE - 1) + 1;
return my_net_write(net, buff, pos - buff) || net_flush(net);
return (my_net_write(net, (uchar*) buff, (size_t) (pos - buff)) ||
net_flush(net));
}
char *net_store_length(char *pkg, uint length)
@ -115,8 +117,8 @@ char *net_store_length(char *pkg, uint length)
}
int store_to_protocol_packet(Buffer *buf, const char *string, uint *position,
uint string_len)
int store_to_protocol_packet(Buffer *buf, const char *string, size_t *position,
size_t string_len)
{
uint currpos;
@ -135,9 +137,10 @@ err:
}
int store_to_protocol_packet(Buffer *buf, const char *string, uint *position)
int store_to_protocol_packet(Buffer *buf, const char *string,
size_t *position)
{
uint string_len;
size_t string_len;
string_len= strlen(string);
return store_to_protocol_packet(buf, string, position, string_len);
@ -153,15 +156,16 @@ int send_eof(struct st_net *net)
buff[0]=254;
int2store(buff+1, 0);
int2store(buff+3, 0);
return my_net_write(net, (char*) buff, sizeof buff);
return my_net_write(net, buff, sizeof(buff));
}
int send_fields(struct st_net *net, LIST *fields)
{
LIST *tmp= fields;
Buffer send_buff;
char small_buff[4];
uint position= 0;
uchar small_buff[4];
size_t position= 0;
LEX_STRING *field;
/* send the number of fileds */

View File

@ -36,10 +36,11 @@ int send_fields(struct st_net *net, LIST *fields);
char *net_store_length(char *pkg, uint length);
int store_to_protocol_packet(Buffer *buf, const char *string, uint *position);
int store_to_protocol_packet(Buffer *buf, const char *string,
size_t *position);
int store_to_protocol_packet(Buffer *buf, const char *string, uint *position,
uint string_len);
int store_to_protocol_packet(Buffer *buf, const char *string, size_t *position,
size_t string_len);
int send_eof(struct st_net *net);

View File

@ -97,12 +97,12 @@ int User::init(const char *line)
C_MODE_START
static byte* get_user_key(const byte* u, uint* len,
my_bool __attribute__((unused)) t)
static uchar* get_user_key(const uchar* u, size_t* len,
my_bool __attribute__((unused)) t)
{
const User *user= (const User *) u;
*len= user->user_length;
return (byte *) user->user;
return (uchar *) user->user;
}
static void delete_user(void *u)
@ -133,7 +133,7 @@ int User_map::init()
{
enum { START_HASH_SIZE= 16 };
if (hash_init(&hash, default_charset_info, START_HASH_SIZE, 0, 0,
get_user_key, delete_user, 0))
get_user_key, delete_user, 0))
return 1;
initialized= TRUE;
@ -274,7 +274,7 @@ int User_map::load(const char *password_file_name, const char **err_msg)
return ERR_PASSWORD_FILE_CORRUPTED;
}
if (my_hash_insert(&hash, (byte *) user))
if (my_hash_insert(&hash, (uchar *) user))
{
delete user;
my_fclose(file, MYF(0));
@ -374,7 +374,7 @@ int User_map::authenticate(const LEX_STRING *user_name,
User *User_map::find_user(const LEX_STRING *user_name)
{
return (User*) hash_search(&hash, (byte*) user_name->str, user_name->length);
return (User*) hash_search(&hash, (uchar*) user_name->str, user_name->length);
}
const User *User_map::find_user(const LEX_STRING *user_name) const
@ -385,11 +385,11 @@ const User *User_map::find_user(const LEX_STRING *user_name) const
bool User_map::add_user(User *user)
{
return my_hash_insert(&hash, (byte*) user) == 0 ? FALSE : TRUE;
return my_hash_insert(&hash, (uchar*) user) == 0 ? FALSE : TRUE;
}
bool User_map::remove_user(User *user)
{
return hash_delete(&hash, (byte*) user) == 0 ? FALSE : TRUE;
return hash_delete(&hash, (uchar*) user) == 0 ? FALSE : TRUE;
}