summaryrefslogtreecommitdiff
path: root/mysys
diff options
context:
space:
mode:
authorMichael Widenius <monty@mysql.com>2009-04-25 13:05:32 +0300
committerMichael Widenius <monty@mysql.com>2009-04-25 13:05:32 +0300
commite726e587ec6287472dd450dbcbddf07669b3e028 (patch)
treee644a6134bfe892512501c648c938a2e93f08130 /mysys
parent210a412522b10115d34b431c66acf403faab7bfe (diff)
parent086185089e6c7bef58dde49b02950689af9fee63 (diff)
downloadmariadb-git-e726e587ec6287472dd450dbcbddf07669b3e028.tar.gz
Merged with mysql-5.1 tree.
client/mysqltest.cc: Manually merged configure.in: Manually merged mysql-test/r/variables.result: Manually merged mysql-test/t/variables.test: Manually merged mysys/my_pread.c: Manually merged mysys/my_read.c: Manually merged sql/mysqld.cc: Manually merged storage/csv/ha_tina.h: Manually merged storage/myisam/ha_myisam.cc: Manually merged storage/myisam/mi_check.c: Manually merged storage/myisam/mi_search.c: Manually merged
Diffstat (limited to 'mysys')
-rw-r--r--mysys/array.c2
-rw-r--r--mysys/base64.c2
-rw-r--r--mysys/charset.c2
-rw-r--r--mysys/default.c81
-rw-r--r--mysys/default_modify.c4
-rw-r--r--mysys/hash.c13
-rw-r--r--mysys/mf_keycache.c2
-rw-r--r--mysys/mf_tempdir.c2
-rw-r--r--mysys/my_append.c2
-rw-r--r--mysys/my_conio.c2
-rw-r--r--mysys/my_copy.c2
-rw-r--r--mysys/my_error.c13
-rw-r--r--mysys/my_getopt.c6
-rw-r--r--mysys/my_getwd.c2
-rw-r--r--mysys/my_new.cc5
-rw-r--r--mysys/my_pread.c4
-rw-r--r--mysys/my_quick.c4
-rw-r--r--mysys/my_read.c2
-rw-r--r--mysys/string.c8
19 files changed, 100 insertions, 58 deletions
diff --git a/mysys/array.c b/mysys/array.c
index b31260344a9..62d6b1ed4e9 100644
--- a/mysys/array.c
+++ b/mysys/array.c
@@ -366,7 +366,7 @@ void freeze_size(DYNAMIC_ARRAY *array)
int get_index_dynamic(DYNAMIC_ARRAY *array, uchar* element)
{
- uint ret;
+ size_t ret;
if (array->buffer > element)
return -1;
diff --git a/mysys/base64.c b/mysys/base64.c
index 6157dcaa5af..ab66715c929 100644
--- a/mysys/base64.c
+++ b/mysys/base64.c
@@ -223,7 +223,7 @@ base64_decode(const char *src_base, size_t len,
The variable 'i' is set to 'len' when padding has been read, so it
does not actually reflect the number of bytes read from 'src'.
*/
- return i != len ? -1 : d - dst_base;
+ return i != len ? -1 : (int) (d - dst_base);
}
diff --git a/mysys/charset.c b/mysys/charset.c
index 8f47b4027ef..e61995de1d8 100644
--- a/mysys/charset.c
+++ b/mysys/charset.c
@@ -328,7 +328,7 @@ static my_bool my_read_charset_file(const char *filename, myf myflags)
{
uchar *buf;
int fd;
- uint len, tmp_len;
+ size_t len, tmp_len;
MY_STAT stat_info;
if (!my_stat(filename, &stat_info, MYF(myflags)) ||
diff --git a/mysys/default.c b/mysys/default.c
index c7e1e513e1e..1c021b4584f 100644
--- a/mysys/default.c
+++ b/mysys/default.c
@@ -152,7 +152,7 @@ static char *remove_end_comment(char *ptr);
int my_search_option_files(const char *conf_file, int *argc, char ***argv,
uint *args_used, Process_option_func func,
- void *func_ctx)
+ void *func_ctx, const char **default_directories)
{
const char **dirs, *forced_default_file, *forced_extra_defaults;
int error= 0;
@@ -183,7 +183,7 @@ int my_search_option_files(const char *conf_file, int *argc, char ***argv,
/* Handle --defaults-group-suffix= */
uint i;
const char **extra_groups;
- const uint instance_len= strlen(my_defaults_group_suffix);
+ const size_t instance_len= strlen(my_defaults_group_suffix);
struct handle_option_ctx *ctx= (struct handle_option_ctx*) func_ctx;
char *ptr;
TYPELIB *group= ctx->group;
@@ -195,12 +195,12 @@ int my_search_option_files(const char *conf_file, int *argc, char ***argv,
for (i= 0; i < group->count; i++)
{
- uint len;
+ size_t len;
extra_groups[i]= group->type_names[i]; /** copy group */
len= strlen(extra_groups[i]);
- if (!(ptr= alloc_root(ctx->alloc, len+instance_len+1)))
- DBUG_RETURN(2);
+ if (!(ptr= alloc_root(ctx->alloc, (uint) (len+instance_len+1))))
+ DBUG_RETURN(2);
extra_groups[i+group->count]= ptr;
@@ -359,18 +359,46 @@ int get_defaults_options(int argc, char **argv,
return org_argc - argc;
}
+/*
+ Wrapper around my_load_defaults() for interface compatibility.
+
+ SYNOPSIS
+ load_defaults()
+ conf_file Basename for configuration file to search for.
+ If this is a path, then only this file is read.
+ groups Which [group] entrys to read.
+ Points to an null terminated array of pointers
+ argc Pointer to argc of original program
+ argv Pointer to argv of original program
+
+ NOTES
+
+ This function is NOT thread-safe as it uses a global pointer internally.
+ See also notes for my_load_defaults().
+
+ RETURN
+ 0 ok
+ 1 The given conf_file didn't exists
+*/
+int load_defaults(const char *conf_file, const char **groups,
+ int *argc, char ***argv)
+{
+ return my_load_defaults(conf_file, groups, argc, argv, &default_directories);
+}
/*
Read options from configurations files
SYNOPSIS
- load_defaults()
+ my_load_defaults()
conf_file Basename for configuration file to search for.
If this is a path, then only this file is read.
groups Which [group] entrys to read.
Points to an null terminated array of pointers
argc Pointer to argc of original program
argv Pointer to argv of original program
+ default_directories Pointer to a location where a pointer to the list
+ of default directories will be stored
IMPLEMENTATION
@@ -386,13 +414,18 @@ int get_defaults_options(int argc, char **argv,
that was put in *argv
RETURN
- 0 ok
- 1 The given conf_file didn't exists
+ - If successful, 0 is returned. If 'default_directories' is not NULL,
+ a pointer to the array of default directory paths is stored to a location
+ it points to. That stored value must be passed to my_search_option_files()
+ later.
+
+ - 1 is returned if the given conf_file didn't exist. In this case, the
+ value pointed to by default_directories is undefined.
*/
-int load_defaults(const char *conf_file, const char **groups,
- int *argc, char ***argv)
+int my_load_defaults(const char *conf_file, const char **groups,
+ int *argc, char ***argv, const char ***default_directories)
{
DYNAMIC_ARRAY args;
TYPELIB group;
@@ -402,10 +435,11 @@ int load_defaults(const char *conf_file, const char **groups,
MEM_ROOT alloc;
char *ptr,**res;
struct handle_option_ctx ctx;
+ const char **dirs;
DBUG_ENTER("load_defaults");
init_alloc_root(&alloc,512,0);
- if ((default_directories= init_default_directories(&alloc)) == NULL)
+ if ((dirs= init_default_directories(&alloc)) == NULL)
goto err;
/*
Check if the user doesn't want any default option processing
@@ -426,6 +460,8 @@ int load_defaults(const char *conf_file, const char **groups,
(*argc)--;
*argv=res;
*(MEM_ROOT*) ptr= alloc; /* Save alloc root for free */
+ if (default_directories)
+ *default_directories= dirs;
DBUG_RETURN(0);
}
@@ -444,7 +480,8 @@ int load_defaults(const char *conf_file, const char **groups,
ctx.group= &group;
error= my_search_option_files(conf_file, argc, argv, &args_used,
- handle_default_option, (void *) &ctx);
+ handle_default_option, (void *) &ctx,
+ dirs);
/*
Here error contains <> 0 only if we have a fully specified conf_file
or a forced default file
@@ -490,6 +527,10 @@ int load_defaults(const char *conf_file, const char **groups,
puts("");
exit(0);
}
+
+ if (error == 0 && default_directories)
+ *default_directories= dirs;
+
DBUG_RETURN(error);
err:
@@ -895,15 +936,11 @@ void my_print_default_files(const char *conf_file)
fputs(conf_file,stdout);
else
{
- /*
- If default_directories is already initialized, use it. Otherwise,
- use a private MEM_ROOT.
- */
- const char **dirs = default_directories;
+ const char **dirs;
MEM_ROOT alloc;
init_alloc_root(&alloc,512,0);
- if (!dirs && (dirs= init_default_directories(&alloc)) == NULL)
+ if ((dirs= init_default_directories(&alloc)) == NULL)
{
fputs("Internal error initializing default directories list", stdout);
}
@@ -970,7 +1007,7 @@ void print_defaults(const char *conf_file, const char **groups)
static int add_directory(MEM_ROOT *alloc, const char *dir, const char **dirs)
{
char buf[FN_REFLEN];
- uint len;
+ size_t len;
char *p;
my_bool err __attribute__((unused));
@@ -1004,14 +1041,14 @@ static size_t my_get_system_windows_directory(char *buffer, size_t size)
"GetSystemWindowsDirectoryA");
if (func_ptr)
- return func_ptr(buffer, size);
+ return func_ptr(buffer, (uint) size);
/*
Windows NT 4.0 Terminal Server Edition:
To retrieve the shared Windows directory, call GetSystemDirectory and
trim the "System32" element from the end of the returned path.
*/
- count= GetSystemDirectory(buffer, size);
+ count= GetSystemDirectory(buffer, (uint) size);
if (count > 8 && stricmp(buffer+(count-8), "\\System32") == 0)
{
count-= 8;
@@ -1090,7 +1127,7 @@ static const char **init_default_directories(MEM_ROOT *alloc)
errors += add_directory(alloc, "/etc/mysql/", dirs);
#if defined(DEFAULT_SYSCONFDIR)
- if (DEFAULT_SYSCONFDIR != "")
+ if (DEFAULT_SYSCONFDIR[0])
errors += add_directory(alloc, DEFAULT_SYSCONFDIR, dirs);
#endif /* DEFAULT_SYSCONFDIR */
diff --git a/mysys/default_modify.c b/mysys/default_modify.c
index 78f6105b071..88df0122da2 100644
--- a/mysys/default_modify.c
+++ b/mysys/default_modify.c
@@ -68,11 +68,9 @@ int modify_defaults_file(const char *file_location, const char *option,
FILE *cnf_file;
MY_STAT file_stat;
char linebuff[BUFF_SIZE], *src_ptr, *dst_ptr, *file_buffer;
- size_t opt_len= 0, optval_len= 0, sect_len;
+ size_t opt_len= 0, optval_len= 0, sect_len, new_opt_len, reserve_extended;
uint nr_newlines= 0, buffer_size;
my_bool in_section= FALSE, opt_applied= 0;
- uint reserve_extended;
- uint new_opt_len;
int reserve_occupied= 0;
DBUG_ENTER("modify_defaults_file");
diff --git a/mysys/hash.c b/mysys/hash.c
index 63aad7d30ed..5443dedf7e0 100644
--- a/mysys/hash.c
+++ b/mysys/hash.c
@@ -33,7 +33,7 @@ typedef struct st_hash_info {
uchar *data; /* data for current entry */
} HASH_LINK;
-static uint my_hash_mask(uint hashnr, uint buffmax, uint maxlength);
+static uint my_hash_mask(size_t hashnr, size_t buffmax, size_t maxlength);
static void movelink(HASH_LINK *array,uint pos,uint next_link,uint newlink);
static int hashcmp(const HASH *hash, HASH_LINK *pos, const uchar *key,
size_t length);
@@ -157,14 +157,14 @@ my_hash_key(const HASH *hash, const uchar *record, size_t *length,
/* Calculate pos according to keys */
-static uint my_hash_mask(uint hashnr, uint buffmax, uint maxlength)
+static uint my_hash_mask(size_t hashnr, size_t buffmax, size_t maxlength)
{
if ((hashnr & (buffmax-1)) < maxlength) return (hashnr & (buffmax-1));
return (hashnr & ((buffmax >> 1) -1));
}
static uint my_hash_rec_mask(const HASH *hash, HASH_LINK *pos,
- uint buffmax, uint maxlength)
+ size_t buffmax, size_t maxlength)
{
size_t length;
uchar *key= (uchar*) my_hash_key(hash, pos->data, &length, 0);
@@ -315,8 +315,7 @@ static int hashcmp(const HASH *hash, HASH_LINK *pos, const uchar *key,
my_bool my_hash_insert(HASH *info, const uchar *record)
{
int flag;
- size_t idx;
- uint halfbuff,hash_nr,first_index;
+ size_t idx,halfbuff,hash_nr,first_index;
uchar *ptr_to_rec,*ptr_to_rec2;
HASH_LINK *data,*empty,*gpos,*gpos2,*pos;
@@ -556,8 +555,8 @@ exit:
my_bool my_hash_update(HASH *hash, uchar *record, uchar *old_key,
size_t old_key_length)
{
- uint new_index,new_pos_index,blength,records,empty;
- size_t idx;
+ uint new_index,new_pos_index,blength,records;
+ size_t idx,empty;
HASH_LINK org_link,*data,*previous,*pos;
DBUG_ENTER("my_hash_update");
diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c
index 81066a51f7b..ea0c97f5913 100644
--- a/mysys/mf_keycache.c
+++ b/mysys/mf_keycache.c
@@ -2404,7 +2404,7 @@ static void read_block(KEY_CACHE *keycache,
BLOCK_LINK *block, uint read_length,
uint min_length, my_bool primary)
{
- uint got_length;
+ size_t got_length;
/* On entry cache_lock is locked */
diff --git a/mysys/mf_tempdir.c b/mysys/mf_tempdir.c
index d6492c90965..f41bbab946f 100644
--- a/mysys/mf_tempdir.c
+++ b/mysys/mf_tempdir.c
@@ -47,7 +47,7 @@ my_bool init_tmpdir(MY_TMPDIR *tmpdir, const char *pathlist)
}
do
{
- uint length;
+ size_t length;
end=strcend(pathlist, DELIM);
strmake(buff, pathlist, (uint) (end-pathlist));
length= cleanup_dirname(buff, buff);
diff --git a/mysys/my_append.c b/mysys/my_append.c
index 35881a959d5..d8789f95d95 100644
--- a/mysys/my_append.c
+++ b/mysys/my_append.c
@@ -36,7 +36,7 @@ struct utimbuf {
int my_append(const char *from, const char *to, myf MyFlags)
{
- uint Count;
+ size_t Count;
File from_file,to_file;
uchar buff[IO_SIZE];
DBUG_ENTER("my_append");
diff --git a/mysys/my_conio.c b/mysys/my_conio.c
index b78966446ee..5dbd31193a9 100644
--- a/mysys/my_conio.c
+++ b/mysys/my_conio.c
@@ -172,7 +172,7 @@ char* my_cgets(char *buffer, size_t clen, size_t* plen)
do
{
clen= min(clen, (size_t) csbi.dwSize.X*csbi.dwSize.Y);
- if (!ReadConsole((HANDLE)my_coninpfh, (LPVOID)buffer, clen - 1, &plen_res,
+ if (!ReadConsole((HANDLE)my_coninpfh, (LPVOID)buffer, (DWORD) clen - 1, &plen_res,
NULL))
{
result= NULL;
diff --git a/mysys/my_copy.c b/mysys/my_copy.c
index cd741b1eb52..5679d13d39d 100644
--- a/mysys/my_copy.c
+++ b/mysys/my_copy.c
@@ -50,7 +50,7 @@ struct utimbuf {
int my_copy(const char *from, const char *to, myf MyFlags)
{
- uint Count;
+ size_t Count;
my_bool new_file_stat= 0; /* 1 if we could stat "to" */
int create_flag;
File from_file,to_file;
diff --git a/mysys/my_error.c b/mysys/my_error.c
index 7f9850ac94d..4e04d4fadc2 100644
--- a/mysys/my_error.c
+++ b/mysys/my_error.c
@@ -276,11 +276,16 @@ const char **my_error_unregister(int first, int last)
void my_error_unregister_all(void)
{
- struct my_err_head *list, *next;
- for (list= my_errmsgs_globerrs.meh_next; list; list= next)
+ struct my_err_head *cursor, *saved_next;
+
+ for (cursor= my_errmsgs_globerrs.meh_next; cursor != NULL; cursor= saved_next)
{
- next= list->meh_next;
- my_free((uchar*) list, MYF(0));
+ /* We need this ptr, but we're about to free its container, so save it. */
+ saved_next= cursor->meh_next;
+
+ my_free((uchar*) cursor, MYF(0));
}
+ my_errmsgs_globerrs.meh_next= NULL; /* Freed in first iteration above. */
+
my_errmsgs_list= &my_errmsgs_globerrs;
}
diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c
index 7a292065477..da7e997d629 100644
--- a/mysys/my_getopt.c
+++ b/mysys/my_getopt.c
@@ -845,7 +845,8 @@ longlong getopt_ll_limit_value(longlong num, const struct my_option *optp,
if (num < optp->min_value)
{
num= optp->min_value;
- adjusted= TRUE;
+ if (old < optp->min_value)
+ adjusted= TRUE;
}
if (fix)
@@ -916,7 +917,8 @@ ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp,
if (num < (ulonglong) optp->min_value)
{
num= (ulonglong) optp->min_value;
- adjusted= TRUE;
+ if (old < (ulonglong) optp->min_value)
+ adjusted= TRUE;
}
if (fix)
diff --git a/mysys/my_getwd.c b/mysys/my_getwd.c
index cbfebcf2374..e0c5b94b53e 100644
--- a/mysys/my_getwd.c
+++ b/mysys/my_getwd.c
@@ -55,7 +55,7 @@ int my_getwd(char * buf, size_t size, myf MyFlags)
else
{
#if defined(HAVE_GETCWD)
- if (!getcwd(buf,size-2) && MyFlags & MY_WME)
+ if (!getcwd(buf,(uint) (size-2)) && MyFlags & MY_WME)
{
my_errno=errno;
my_error(EE_GETWD,MYF(ME_BELL+ME_WAITTANG),errno);
diff --git a/mysys/my_new.cc b/mysys/my_new.cc
index babfe04d695..7da54ffac87 100644
--- a/mysys/my_new.cc
+++ b/mysys/my_new.cc
@@ -46,8 +46,9 @@ void operator delete[] (void *ptr) throw ()
C_MODE_START
-int __cxa_pure_virtual() {
- assert("Pure virtual method called." == "Aborted");
+int __cxa_pure_virtual()
+{
+ assert(! "Aborted: pure virtual method called.");
return 0;
}
diff --git a/mysys/my_pread.c b/mysys/my_pread.c
index bb82fde069a..836f5a92963 100644
--- a/mysys/my_pread.c
+++ b/mysys/my_pread.c
@@ -65,7 +65,7 @@ size_t my_pread(File Filedes, uchar *Buffer, size_t Count, my_off_t offset,
pthread_mutex_lock(&my_file_info[Filedes].mutex);
readbytes= (uint) -1;
error= (lseek(Filedes, offset, MY_SEEK_SET) == (my_off_t) -1 ||
- (readbytes= read(Filedes, Buffer, Count)) != Count);
+ (readbytes= read(Filedes, Buffer, (uint) Count)) != Count);
save_errno= errno;
pthread_mutex_unlock(&my_file_info[Filedes].mutex);
if (error)
@@ -151,7 +151,7 @@ size_t my_pwrite(int Filedes, const uchar *Buffer, size_t Count,
writenbytes= (size_t) -1;
pthread_mutex_lock(&my_file_info[Filedes].mutex);
error= (lseek(Filedes, offset, MY_SEEK_SET) != (my_off_t) -1 &&
- (writenbytes = write(Filedes, Buffer, Count)) == Count);
+ (writenbytes = write(Filedes, Buffer, (uint) Count)) == Count);
pthread_mutex_unlock(&my_file_info[Filedes].mutex);
if (error)
break;
diff --git a/mysys/my_quick.c b/mysys/my_quick.c
index c19fe08572d..0ba20a5bdee 100644
--- a/mysys/my_quick.c
+++ b/mysys/my_quick.c
@@ -23,7 +23,7 @@ size_t my_quick_read(File Filedes,uchar *Buffer,size_t Count,myf MyFlags)
{
size_t readbytes;
- if ((readbytes = read(Filedes, Buffer, Count)) != Count)
+ if ((readbytes = read(Filedes, Buffer, (uint) Count)) != Count)
{
#ifndef DBUG_OFF
if ((readbytes == 0 || readbytes == (size_t) -1) && errno == EINTR)
@@ -50,7 +50,7 @@ size_t my_quick_write(File Filedes,const uchar *Buffer,size_t Count)
#ifndef DBUG_OFF
writtenbytes =
#endif
- (size_t) write(Filedes,Buffer,Count)) != Count)
+ (size_t) write(Filedes,Buffer, (uint) Count)) != Count)
{
#ifndef DBUG_OFF
if ((writtenbytes == 0 || writtenbytes == (size_t) -1) && errno == EINTR)
diff --git a/mysys/my_read.c b/mysys/my_read.c
index 8e098924e43..25ffe73d813 100644
--- a/mysys/my_read.c
+++ b/mysys/my_read.c
@@ -44,7 +44,7 @@ size_t my_read(File Filedes, uchar *Buffer, size_t Count, myf MyFlags)
for (;;)
{
errno= 0; /* Linux, Windows don't reset this on EOF/success */
- if ((readbytes= read(Filedes, Buffer, Count)) != Count)
+ if ((readbytes= read(Filedes, Buffer, (uint) Count)) != Count)
{
my_errno= errno;
if (errno == 0 || (readbytes != (size_t) -1 &&
diff --git a/mysys/string.c b/mysys/string.c
index b234a589406..10a72b8a295 100644
--- a/mysys/string.c
+++ b/mysys/string.c
@@ -25,7 +25,7 @@
my_bool init_dynamic_string(DYNAMIC_STRING *str, const char *init_str,
size_t init_alloc, size_t alloc_increment)
{
- uint length;
+ size_t length;
DBUG_ENTER("init_dynamic_string");
if (!alloc_increment)
@@ -100,7 +100,7 @@ my_bool dynstr_append_mem(DYNAMIC_STRING *str, const char *append,
char *new_ptr;
if (str->length+length >= str->max_length)
{
- uint new_length=(str->length+length+str->alloc_increment)/
+ size_t new_length=(str->length+length+str->alloc_increment)/
str->alloc_increment;
new_length*=str->alloc_increment;
if (!(new_ptr=(char*) my_realloc(str->str,new_length,MYF(MY_WME))))
@@ -160,12 +160,12 @@ my_bool dynstr_append_os_quoted(DYNAMIC_STRING *str, const char *append, ...)
/* Search for quote in each string and replace with escaped quote */
while(*(next_pos= strcend(cur_pos, quote_str[0])) != '\0')
{
- ret&= dynstr_append_mem(str, cur_pos, next_pos - cur_pos);
+ ret&= dynstr_append_mem(str, cur_pos, (uint) (next_pos - cur_pos));
ret&= dynstr_append_mem(str ,"\\", 1);
ret&= dynstr_append_mem(str, quote_str, quote_len);
cur_pos= next_pos + 1;
}
- ret&= dynstr_append_mem(str, cur_pos, next_pos - cur_pos);
+ ret&= dynstr_append_mem(str, cur_pos, (uint) (next_pos - cur_pos));
append= va_arg(dirty_text, char *);
}
va_end(dirty_text);