Skip to content

Commit 69575a7

Browse files
author
Tor Didriksen
committed
Bug#11765003 - 57912 Use memset() rather than the deprecated bfill() and bzero()
1 parent 8319da5 commit 69575a7

194 files changed

Lines changed: 810 additions & 827 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

client/completion_hash.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ Bucket *find_longest_match(HashTable *ht, char *str, uint length,
205205
void completion_hash_clean(HashTable *ht)
206206
{
207207
free_root(&ht->mem_root,MYF(0));
208-
bzero((char*) ht->arBuckets,ht->nTableSize*sizeof(Bucket *));
208+
memset(ht->arBuckets, 0, ht->nTableSize * sizeof(Bucket *));
209209
}
210210

211211

client/mysql.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1209,7 +1209,7 @@ int main(int argc,char *argv[])
12091209
glob_buffer.realloc(512);
12101210
completion_hash_init(&ht, 128);
12111211
init_alloc_root(&hash_mem_root, 16384, 0);
1212-
bzero((char*) &mysql, sizeof(mysql));
1212+
memset(&mysql, 0, sizeof(mysql));
12131213
if (sql_connect(current_host,current_db,current_user,opt_password,
12141214
opt_silent))
12151215
{
@@ -3989,7 +3989,7 @@ com_connect(String *buffer, char *line)
39893989
bool save_rehash= opt_rehash;
39903990
int error;
39913991

3992-
bzero(buff, sizeof(buff));
3992+
memset(buff, 0, sizeof(buff));
39933993
if (buffer)
39943994
{
39953995
/*
@@ -4075,7 +4075,7 @@ static int com_source(String *buffer __attribute__((unused)),
40754075

40764076
/* Save old status */
40774077
old_status=status;
4078-
bfill((char*) &status,sizeof(status),(char) 0);
4078+
memset(&status, 0, sizeof(status));
40794079

40804080
status.batch=old_status.batch; // Run in batch mode
40814081
status.line_buff=line_buff;
@@ -4125,7 +4125,7 @@ com_use(String *buffer __attribute__((unused)), char *line)
41254125
char *tmp, buff[FN_REFLEN + 1];
41264126
int select_db;
41274127

4128-
bzero(buff, sizeof(buff));
4128+
memset(buff, 0, sizeof(buff));
41294129
strmake(buff, line, sizeof(buff) - 1);
41304130
tmp= get_arg(buff, 0);
41314131
if (!tmp || !*tmp)

client/mysql_upgrade.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ static int upgrade_already_done(void)
608608
Read from file, don't care if it fails since it
609609
will be detected by the strncmp
610610
*/
611-
bzero(buf, sizeof(buf));
611+
memset(buf, 0, sizeof(buf));
612612
res= fgets(buf, sizeof(buf), in);
613613

614614
my_fclose(in, MYF(0));

client/mysqlbinlog.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ class Load_log_processor
226226
{
227227
my_free(ptr->fname);
228228
delete ptr->event;
229-
bzero((char *)ptr, sizeof(File_name_record));
229+
memset(ptr, 0, sizeof(File_name_record));
230230
}
231231
}
232232

@@ -257,7 +257,7 @@ class Load_log_processor
257257
return 0;
258258
ptr= dynamic_element(&file_names, file_id, File_name_record*);
259259
if ((res= ptr->event))
260-
bzero((char *)ptr, sizeof(File_name_record));
260+
memset(ptr, 0, sizeof(File_name_record));
261261
return res;
262262
}
263263

@@ -287,7 +287,7 @@ class Load_log_processor
287287
if (!ptr->event)
288288
{
289289
res= ptr->fname;
290-
bzero((char *)ptr, sizeof(File_name_record));
290+
memset(ptr, 0, sizeof(File_name_record));
291291
}
292292
return res;
293293
}

client/mysqldump.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5185,7 +5185,7 @@ int main(int argc, char **argv)
51855185

51865186
compatible_mode_normal_str[0]= 0;
51875187
default_charset= (char *)mysql_universal_client_charset;
5188-
bzero((char*) &ignore_table, sizeof(ignore_table));
5188+
memset(&ignore_table, 0, sizeof(ignore_table));
51895189

51905190
exit_code= get_options(&argc, &argv);
51915191
if (exit_code)

client/mysqlslap.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ void concurrency_loop(MYSQL *mysql, uint current, option_string *eptr)
434434
head_sptr= (stats *)my_malloc(sizeof(stats) * iterations,
435435
MYF(MY_ZEROFILL|MY_FAE|MY_WME));
436436

437-
bzero(&conclusion, sizeof(conclusions));
437+
memset(&conclusion, 0, sizeof(conclusions));
438438

439439
if (auto_actual_queries)
440440
client_limit= auto_actual_queries;

client/mysqltest.cc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ class LogFile {
542542
size_t m_bytes_written;
543543
public:
544544
LogFile() : m_file(NULL), m_bytes_written(0) {
545-
bzero(m_file_name, sizeof(m_file_name));
545+
memset(m_file_name, 0, sizeof(m_file_name));
546546
}
547547

548548
~LogFile() {
@@ -9057,8 +9057,8 @@ void do_get_replace(struct st_command *command)
90579057

90589058
free_replace();
90599059

9060-
bzero((char*) &to_array,sizeof(to_array));
9061-
bzero((char*) &from_array,sizeof(from_array));
9060+
memset(&to_array, 0, sizeof(to_array));
9061+
memset(&from_array, 0, sizeof(from_array));
90629062
if (!*from)
90639063
die("Missing argument in %s", command->query);
90649064
start= buff= (char*)my_malloc(strlen(from)+1,MYF(MY_WME | MY_FAE));
@@ -9264,7 +9264,7 @@ struct st_replace_regex* init_replace_regex(char* expr)
92649264
/* for each regexp substitution statement */
92659265
while (p < expr_end)
92669266
{
9267-
bzero(&reg,sizeof(reg));
9267+
memset(&reg, 0, sizeof(reg));
92689268
/* find the start of the statement */
92699269
while (p < expr_end)
92709270
{
@@ -9717,7 +9717,7 @@ REPLACE *init_replace(char * *from, char * *to,uint count,
97179717
if (len > max_length)
97189718
max_length=len;
97199719
}
9720-
bzero((char*) is_word_end,sizeof(is_word_end));
9720+
memset(is_word_end, 0, sizeof(is_word_end));
97219721
for (i=0 ; word_end_chars[i] ; i++)
97229722
is_word_end[(uchar) word_end_chars[i]]=1;
97239723

@@ -9808,7 +9808,7 @@ REPLACE *init_replace(char * *from, char * *to,uint count,
98089808
or_bits(sets.set+used_sets,sets.set); /* Can restart from start */
98099809

98109810
/* Find all chars that follows current sets */
9811-
bzero((char*) used_chars,sizeof(used_chars));
9811+
memset(used_chars, 0, sizeof(used_chars));
98129812
for (i= (uint) ~0; (i=get_next_bit(sets.set+used_sets,i)) ;)
98139813
{
98149814
used_chars[follow[i].chr]=1;
@@ -9942,7 +9942,7 @@ REPLACE *init_replace(char * *from, char * *to,uint count,
99429942

99439943
int init_sets(REP_SETS *sets,uint states)
99449944
{
9945-
bzero((char*) sets,sizeof(*sets));
9945+
memset(sets, 0, sizeof(*sets));
99469946
sets->size_of_bits=((states+7)/8);
99479947
if (!(sets->set_buffer=(REP_SET*) my_malloc(sizeof(REP_SET)*SET_MALLOC_HUNC,
99489948
MYF(MY_WME))))
@@ -9973,8 +9973,8 @@ REP_SET *make_new_set(REP_SETS *sets)
99739973
{
99749974
sets->extra--;
99759975
set=sets->set+ sets->count++;
9976-
bzero((char*) set->bits,sizeof(uint)*sets->size_of_bits);
9977-
bzero((char*) &set->next[0],sizeof(set->next[0])*LAST_CHAR_CODE);
9976+
memset(set->bits, 0, sizeof(uint)*sets->size_of_bits);
9977+
memset(&set->next[0], 0, sizeof(set->next[0])*LAST_CHAR_CODE);
99789978
set->found_offset=0;
99799979
set->found_len=0;
99809980
set->table_offset= (uint) ~0;

client/sql_string.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ bool String::copy_aligned(const char *str,uint32 arg_length, uint32 offset,
237237
If we add big-endian UCS-2 sometimes, this code
238238
will be more complicated. But it's OK for now.
239239
*/
240-
bzero((char*) Ptr, offset);
240+
memset(Ptr, 0, offset);
241241
memcpy(Ptr + offset, str, arg_length);
242242
Ptr[aligned_length]=0;
243243
/* str_length is always >= 0 as arg_length is != 0 */
@@ -328,7 +328,7 @@ bool String::fill(uint32 max_length,char fill_char)
328328
{
329329
if (realloc(max_length))
330330
return TRUE;
331-
bfill(Ptr+str_length,max_length-str_length,fill_char);
331+
memset(Ptr+str_length, fill_char, max_length-str_length);
332332
str_length=max_length;
333333
}
334334
return FALSE;
@@ -465,7 +465,7 @@ bool String::append_with_prefill(const char *s,uint32 arg_length,
465465
t_length= full_length - arg_length;
466466
if (t_length > 0)
467467
{
468-
bfill(Ptr+str_length, t_length, fill_char);
468+
memset(Ptr+str_length, fill_char, t_length);
469469
str_length=str_length + t_length;
470470
}
471471
append(s, arg_length);

cmake/os/WindowsCache.cmake

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,10 @@ SET(HAVE_ASM_MSR_H CACHE INTERNAL "")
3030
SET(HAVE_BACKTRACE CACHE INTERNAL "")
3131
SET(HAVE_BACKTRACE_SYMBOLS CACHE INTERNAL "")
3232
SET(HAVE_BACKTRACE_SYMBOLS_FD CACHE INTERNAL "")
33-
SET(HAVE_BFILL CACHE INTERNAL "")
3433
SET(HAVE_BMOVE CACHE INTERNAL "")
3534
SET(HAVE_BSD_SIGNALS CACHE INTERNAL "")
3635
SET(HAVE_BSEARCH 1 CACHE INTERNAL "")
3736
SET(HAVE_BSS_START CACHE INTERNAL "")
38-
SET(HAVE_BZERO CACHE INTERNAL "")
3937
SET(HAVE_CHOWN CACHE INTERNAL "")
4038
SET(HAVE_CLOCK_GETTIME CACHE INTERNAL "")
4139
SET(HAVE_COMPRESS CACHE INTERNAL "")

config.h.cmake

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,7 @@
130130
#cmakedefine HAVE_AIOWAIT 1
131131
#cmakedefine HAVE_ALARM 1
132132
#cmakedefine HAVE_ALLOCA 1
133-
#cmakedefine HAVE_BFILL 1
134133
#cmakedefine HAVE_BMOVE 1
135-
#cmakedefine HAVE_BZERO 1
136134
#cmakedefine HAVE_INDEX 1
137135
#cmakedefine HAVE_CHOWN 1
138136
#cmakedefine HAVE_CLOCK_GETTIME 1

0 commit comments

Comments
 (0)