Skip to content

Commit

Permalink
Remove most 'register' use in C++
Browse files Browse the repository at this point in the history
Modern compilers (such as GCC 8) emit warnings that the
'register' keyword is deprecated and not valid C++17.

Let us remove most use of the 'register' keyword.
Code in 'extra/' is not touched.
  • Loading branch information
dr-m committed Apr 24, 2018
1 parent 2a00bde commit 39a4985
Show file tree
Hide file tree
Showing 33 changed files with 107 additions and 113 deletions.
2 changes: 1 addition & 1 deletion include/heap.h
Expand Up @@ -217,7 +217,7 @@ extern int heap_write(HP_INFO *info,const uchar *buff);
extern int heap_update(HP_INFO *info,const uchar *old,const uchar *newdata);
extern int heap_rrnd(HP_INFO *info,uchar *buf,uchar *pos);
extern int heap_scan_init(HP_INFO *info);
extern int heap_scan(register HP_INFO *info, uchar *record);
extern int heap_scan(HP_INFO *info, uchar *record);
extern int heap_delete(HP_INFO *info,const uchar *buff);
extern int heap_info(HP_INFO *info,HEAPINFO *x,int flag);
extern int heap_create(const char *name,
Expand Down
2 changes: 1 addition & 1 deletion include/maria.h
Expand Up @@ -366,7 +366,7 @@ int maria_sort_index(HA_CHECK *param, MARIA_HA *info, char * name);
int maria_zerofill(HA_CHECK *param, MARIA_HA *info, const char *name);
int maria_repair_by_sort(HA_CHECK *param, MARIA_HA *info,
const char *name, my_bool rep_quick);
int maria_repair_parallel(HA_CHECK *param, register MARIA_HA *info,
int maria_repair_parallel(HA_CHECK *param, MARIA_HA *info,
const char *name, my_bool rep_quick);
int maria_change_to_newfile(const char *filename, const char *old_ext,
const char *new_ext, time_t backup_time,
Expand Down
13 changes: 6 additions & 7 deletions include/myisam.h
Expand Up @@ -373,7 +373,7 @@ typedef struct st_mi_sort_param
int (*key_read)(struct st_mi_sort_param *,void *);
int (*key_write)(struct st_mi_sort_param *, const void *);
void (*lock_in_memory)(HA_CHECK *);
int (*write_keys)(struct st_mi_sort_param *, register uchar **,
int (*write_keys)(struct st_mi_sort_param *, uchar **,
ulonglong , struct st_buffpek *, IO_CACHE *);
my_off_t (*read_to_buffer)(IO_CACHE *,struct st_buffpek *, uint);
int (*write_key)(struct st_mi_sort_param *, IO_CACHE *,uchar *,
Expand All @@ -383,16 +383,15 @@ typedef struct st_mi_sort_param
/* functions in mi_check */
void myisamchk_init(HA_CHECK *param);
int chk_status(HA_CHECK *param, MI_INFO *info);
int chk_del(HA_CHECK *param, register MI_INFO *info, ulonglong test_flag);
int chk_del(HA_CHECK *param, MI_INFO *info, ulonglong test_flag);
int chk_size(HA_CHECK *param, MI_INFO *info);
int chk_key(HA_CHECK *param, MI_INFO *info);
int chk_data_link(HA_CHECK *param, MI_INFO *info, my_bool extend);
int mi_repair(HA_CHECK *param, register MI_INFO *info,
char * name, int rep_quick);
int mi_sort_index(HA_CHECK *param, register MI_INFO *info, char * name);
int mi_repair_by_sort(HA_CHECK *param, register MI_INFO *info,
int mi_repair(HA_CHECK *param, MI_INFO *info, char * name, int rep_quick);
int mi_sort_index(HA_CHECK *param, MI_INFO *info, char * name);
int mi_repair_by_sort(HA_CHECK *param, MI_INFO *info,
const char * name, int rep_quick);
int mi_repair_parallel(HA_CHECK *param, register MI_INFO *info,
int mi_repair_parallel(HA_CHECK *param, MI_INFO *info,
const char * name, int rep_quick);
int change_to_newfile(const char * filename, const char * old_ext,
const char * new_ext, time_t backup_time, myf myflags);
Expand Down
2 changes: 1 addition & 1 deletion sql/field.h
Expand Up @@ -1504,7 +1504,7 @@ class Field: public Value_source
/* Mark field in read map. Updates also virtual fields */
void register_field_in_read_map();

friend int cre_myisam(char * name, register TABLE *form, uint options,
friend int cre_myisam(char * name, TABLE *form, uint options,
ulonglong auto_increment_value);
friend class Copy_field;
friend class Item_avg_field;
Expand Down
9 changes: 4 additions & 5 deletions sql/filesort.cc
Expand Up @@ -1165,8 +1165,7 @@ Type_handler_real_result::make_sort_key(uchar *to, Item *item,

/** Make a sort-key from record. */

static void make_sortkey(register Sort_param *param,
register uchar *to, uchar *ref_pos)
static void make_sortkey(Sort_param *param, uchar *to, uchar *ref_pos)
{
reg3 Field *field;
reg1 SORT_FIELD *sort_field;
Expand Down Expand Up @@ -1458,7 +1457,7 @@ bool check_if_pq_applicable(Sort_param *param,
int merge_many_buff(Sort_param *param, uchar *sort_buffer,
BUFFPEK *buffpek, uint *maxbuffer, IO_CACHE *t_file)
{
register uint i;
uint i;
IO_CACHE t_file2,*from_file,*to_file,*temp;
BUFFPEK *lastbuff;
DBUG_ENTER("merge_many_buff");
Expand Down Expand Up @@ -1513,7 +1512,7 @@ int merge_many_buff(Sort_param *param, uchar *sort_buffer,
uint read_to_buffer(IO_CACHE *fromfile, BUFFPEK *buffpek,
uint rec_length)
{
register uint count;
uint count;
uint length;

if ((count=(uint) MY_MIN((ha_rows) buffpek->max_keys,buffpek->count)))
Expand Down Expand Up @@ -1817,7 +1816,7 @@ int merge_buffers(Sort_param *param, IO_CACHE *from_file,
}
else
{
register uchar *end;
uchar *end;
src= buffpek->key+offset;
for (end= src+buffpek->mem_count*rec_length ;
src != end ;
Expand Down
30 changes: 15 additions & 15 deletions sql/gen_lex_hash.cc
Expand Up @@ -403,8 +403,8 @@ int main(int argc,char **argv)
static SYMBOL *get_hash_symbol(const char *s,\n\
unsigned int len,bool function)\n\
{\n\
register uchar *hash_map;\n\
register const char *cur_str= s;\n\
uchar *hash_map;\n\
const char *cur_str= s;\n\
\n\
if (len == 0) {\n\
DBUG_PRINT(\"warning\", (\"get_hash_symbol() received a request for a zero-length symbol, which is probably a mistake.\"));\
Expand All @@ -416,25 +416,25 @@ static SYMBOL *get_hash_symbol(const char *s,\n\
if (function){\n\
if (len>sql_functions_max_len) return 0;\n\
hash_map= sql_functions_map;\n\
register uint32 cur_struct= uint4korr(hash_map+((len-1)*4));\n\
uint32 cur_struct= uint4korr(hash_map+((len-1)*4));\n\
\n\
for (;;){\n\
register uchar first_char= (uchar)cur_struct;\n\
uchar first_char= (uchar)cur_struct;\n\
\n\
if (first_char == 0)\n\
{\n\
register int16 ires= (int16)(cur_struct>>16);\n\
int16 ires= (int16)(cur_struct>>16);\n\
if (ires==array_elements(symbols)) return 0;\n\
register SYMBOL *res;\n\
SYMBOL *res;\n\
if (ires>=0) \n\
res= symbols+ires;\n\
else\n\
res= sql_functions-ires-1;\n\
register uint count= (uint) (cur_str - s);\n\
uint count= (uint) (cur_str - s);\n\
return lex_casecmp(cur_str,res->name+count,len-count) ? 0 : res;\n\
}\n\
\n\
register uchar cur_char= (uchar)to_upper_lex[(uchar)*cur_str];\n\
uchar cur_char= (uchar)to_upper_lex[(uchar)*cur_str];\n\
if (cur_char<first_char) return 0;\n\
cur_struct>>=8;\n\
if (cur_char>(uchar)cur_struct) return 0;\n\
Expand All @@ -450,20 +450,20 @@ static SYMBOL *get_hash_symbol(const char *s,\n\
}else{\n\
if (len>symbols_max_len) return 0;\n\
hash_map= symbols_map;\n\
register uint32 cur_struct= uint4korr(hash_map+((len-1)*4));\n\
uint32 cur_struct= uint4korr(hash_map+((len-1)*4));\n\
\n\
for (;;){\n\
register uchar first_char= (uchar)cur_struct;\n\
uchar first_char= (uchar)cur_struct;\n\
\n\
if (first_char==0){\n\
register int16 ires= (int16)(cur_struct>>16);\n\
if (first_char==0) {\n\
int16 ires= (int16)(cur_struct>>16);\n\
if (ires==array_elements(symbols)) return 0;\n\
register SYMBOL *res= symbols+ires;\n\
register uint count= (uint) (cur_str - s);\n\
SYMBOL *res= symbols+ires;\n\
uint count= (uint) (cur_str - s);\n\
return lex_casecmp(cur_str,res->name+count,len-count)!=0 ? 0 : res;\n\
}\n\
\n\
register uchar cur_char= (uchar)to_upper_lex[(uchar)*cur_str];\n\
uchar cur_char= (uchar)to_upper_lex[(uchar)*cur_str];\n\
if (cur_char<first_char) return 0;\n\
cur_struct>>=8;\n\
if (cur_char>(uchar)cur_struct) return 0;\n\
Expand Down
2 changes: 1 addition & 1 deletion sql/handler.cc
Expand Up @@ -2798,7 +2798,7 @@ int handler::ha_rnd_init_with_error(bool scan)
*/
int handler::read_first_row(uchar * buf, uint primary_key)
{
register int error;
int error;
DBUG_ENTER("handler::read_first_row");

/*
Expand Down
12 changes: 6 additions & 6 deletions sql/item_cmpfunc.cc
Expand Up @@ -5810,8 +5810,8 @@ void Item_func_like::turboBM_compute_bad_character_shifts()

bool Item_func_like::turboBM_matches(const char* text, int text_len) const
{
register int bcShift;
register int turboShift;
int bcShift;
int turboShift;
int shift = pattern_len;
int j = 0;
int u = 0;
Expand All @@ -5825,7 +5825,7 @@ bool Item_func_like::turboBM_matches(const char* text, int text_len) const
{
while (j <= tlmpl)
{
register int i= plm1;
int i= plm1;
while (i >= 0 && pattern[i] == text[i + j])
{
i--;
Expand All @@ -5835,7 +5835,7 @@ bool Item_func_like::turboBM_matches(const char* text, int text_len) const
if (i < 0)
return 1;

register const int v = plm1 - i;
const int v= plm1 - i;
turboShift = u - v;
bcShift = bmBc[(uint) (uchar) text[i + j]] - plm1 + i;
shift = MY_MAX(turboShift, bcShift);
Expand All @@ -5856,7 +5856,7 @@ bool Item_func_like::turboBM_matches(const char* text, int text_len) const
{
while (j <= tlmpl)
{
register int i = plm1;
int i= plm1;
while (i >= 0 && likeconv(cs,pattern[i]) == likeconv(cs,text[i + j]))
{
i--;
Expand All @@ -5866,7 +5866,7 @@ bool Item_func_like::turboBM_matches(const char* text, int text_len) const
if (i < 0)
return 1;

register const int v = plm1 - i;
const int v= plm1 - i;
turboShift = u - v;
bcShift = bmBc[(uint) likeconv(cs, text[i + j])] - plm1 + i;
shift = MY_MAX(turboShift, bcShift);
Expand Down
4 changes: 2 additions & 2 deletions sql/item_func.cc
Expand Up @@ -3244,8 +3244,8 @@ longlong Item_func_ord::val_int()
#ifdef USE_MB
if (use_mb(res->charset()))
{
register const char *str=res->ptr();
register uint32 n=0, l=my_ismbchar(res->charset(),str,str+res->length());
const char *str=res->ptr();
uint32 n=0, l=my_ismbchar(res->charset(),str,str+res->length());
if (!l)
return (longlong)((uchar) *str);
while (l--)
Expand Down
14 changes: 7 additions & 7 deletions sql/item_strfunc.cc
Expand Up @@ -1038,7 +1038,7 @@ String *Item_func_reverse::val_str(String *str)
#ifdef USE_MB
if (use_mb(res->charset()))
{
register uint32 l;
uint32 l;
while (ptr < end)
{
if ((l= my_ismbchar(res->charset(),ptr,end)))
Expand Down Expand Up @@ -1087,7 +1087,7 @@ String *Item_func_replace::val_str(String *str)
bool alloced=0;
#ifdef USE_MB
const char *ptr,*end,*strend,*search,*search_end;
register uint32 l;
uint32 l;
bool binary_cmp;
#endif
THD *thd= 0;
Expand Down Expand Up @@ -1140,7 +1140,7 @@ String *Item_func_replace::val_str(String *str)
{
if (*ptr == *search)
{
register char *i,*j;
char *i,*j;
i=(char*) ptr+1; j=(char*) search+1;
while (j != search_end)
if (*i++ != *j++) goto skip;
Expand Down Expand Up @@ -1748,14 +1748,14 @@ String *Item_func_substr_index::val_str(String *str)
const char *search= delimiter->ptr();
const char *search_end= search+delimiter_length;
int32 n=0,c=count,pass;
register uint32 l;
uint32 l;
for (pass=(count>0);pass<2;++pass)
{
while (ptr < end)
{
if (*ptr == *search)
{
register char *i,*j;
char *i,*j;
i=(char*) ptr+1; j=(char*) search+1;
while (j != search_end)
if (*i++ != *j++) goto skip;
Expand Down Expand Up @@ -1923,7 +1923,7 @@ String *Item_func_rtrim::val_str(String *str)
end= ptr+res->length();
#ifdef USE_MB
char *p=ptr;
register uint32 l;
uint32 l;
#endif
if (remove_length == 1)
{
Expand Down Expand Up @@ -2008,7 +2008,7 @@ String *Item_func_trim::val_str(String *str)
if (use_mb(collation.collation))
{
char *p=ptr;
register uint32 l;
uint32 l;
loop:
while (ptr + remove_length < end)
{
Expand Down
2 changes: 1 addition & 1 deletion sql/key.cc
Expand Up @@ -497,7 +497,7 @@ int key_cmp(KEY_PART_INFO *key_part, const uchar *key, uint key_length)
if (key_part->null_bit)
{
/* This key part allows null values; NULL is lower than everything */
register bool field_is_null= key_part->field->is_null();
bool field_is_null= key_part->field->is_null();
if (*key) // If range key is null
{
/* the range is expecting a null value */
Expand Down
3 changes: 1 addition & 2 deletions sql/log.cc
Expand Up @@ -8480,8 +8480,7 @@ void MYSQL_BIN_LOG::set_max_size(ulong max_size_arg)
0 String is not a number
*/

static bool test_if_number(register const char *str,
ulong *res, bool allow_wildcards)
static bool test_if_number(const char *str, ulong *res, bool allow_wildcards)
{
reg2 int flag;
const char *start;
Expand Down
3 changes: 1 addition & 2 deletions sql/mf_iocache.cc
Expand Up @@ -49,8 +49,7 @@ extern "C" {
*/


int _my_b_net_read(register IO_CACHE *info, uchar *Buffer,
size_t Count __attribute__((unused)))
int _my_b_net_read(IO_CACHE *info, uchar *Buffer, size_t)
{
ulong read_length;
NET *net= &(current_thd)->net;
Expand Down
4 changes: 2 additions & 2 deletions sql/password.c
Expand Up @@ -90,7 +90,7 @@

void hash_password(ulong *result, const char *password, uint password_len)
{
register ulong nr=1345345333L, add=7, nr2=0x12345671L;
ulong nr=1345345333L, add=7, nr2=0x12345671L;
ulong tmp;
const char *password_end= password + password_len;
for (; password < password_end; password++)
Expand Down Expand Up @@ -325,7 +325,7 @@ hex2octet(uint8 *to, const char *str, uint len)
const char *str_end= str + len;
while (str < str_end)
{
register char tmp= char_val(*str++);
char tmp= char_val(*str++);
*to++= (tmp << 4) | char_val(*str++);
}
}
Expand Down
10 changes: 5 additions & 5 deletions sql/plistsort.c
Expand Up @@ -91,7 +91,7 @@ LS_SCOPE LS_LIST_ITEM* LS_NAME(LS_COMPARE_FUNC_DECL LS_LIST_ITEM *list, int list
}

{
register struct LS_STRUCT_NAME *sp0= sp++;
struct LS_STRUCT_NAME *sp0= sp++;
sp->list_len= sp0->list_len >> 1;
sp0->list_len-= sp->list_len;
sp->return_point= 0;
Expand All @@ -100,17 +100,17 @@ LS_SCOPE LS_LIST_ITEM* LS_NAME(LS_COMPARE_FUNC_DECL LS_LIST_ITEM *list, int list
return_point0:
sp->list1= sorted_list;
{
register struct LS_STRUCT_NAME *sp0= sp++;
struct LS_STRUCT_NAME *sp0= sp++;
list= list_end;
sp->list_len= sp0->list_len;
sp->return_point= 1;
}
goto recursion_point;
return_point1:
{
register LS_LIST_ITEM **hook= &sorted_list;
register LS_LIST_ITEM *list1= sp->list1;
register LS_LIST_ITEM *list2= sorted_list;
LS_LIST_ITEM **hook= &sorted_list;
LS_LIST_ITEM *list1= sp->list1;
LS_LIST_ITEM *list2= sorted_list;

if (LS_COMPARE_FUNC_CALL(list1, list2))
{
Expand Down
2 changes: 1 addition & 1 deletion sql/slave.cc
Expand Up @@ -218,7 +218,7 @@ static void set_slave_max_allowed_packet(THD *thd, MYSQL *mysql)
void init_thread_mask(int* mask,Master_info* mi,bool inverse)
{
bool set_io = mi->slave_running, set_sql = mi->rli.slave_running;
register int tmp_mask=0;
int tmp_mask=0;
DBUG_ENTER("init_thread_mask");

if (set_io)
Expand Down
2 changes: 1 addition & 1 deletion sql/sql_db.cc
Expand Up @@ -338,7 +338,7 @@ static void del_dbopt(const char *path)
static bool write_db_opt(THD *thd, const char *path,
Schema_specification_st *create)
{
register File file;
File file;
char buf[256]; // Should be enough for one option
bool error=1;

Expand Down

0 comments on commit 39a4985

Please sign in to comment.