diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2020-03-13 12:09:19 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2020-03-13 12:09:19 +0200 |
commit | ed21202a14e981a997061db12b2a377910fb02d5 (patch) | |
tree | f24c753931f6d31feee5d4382b8436c952903e9f | |
parent | d9d3c222caefd77fabe172f8396dc42041066ccf (diff) | |
download | mariadb-git-ed21202a14e981a997061db12b2a377910fb02d5.tar.gz |
Fix GCC 10.0 -Wstringop-overflow
myrg_open(): Reduce the scope of the variable 'end' and
simplify the code.
For some reason, I got no warning for this code in the 10.2
branch, only 10.3 or later.
The ENGINE=MERGE is covered by the tests main.merge, main.merge_debug,
and main.merge-big.
-rw-r--r-- | storage/myisammrg/myrg_open.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/storage/myisammrg/myrg_open.c b/storage/myisammrg/myrg_open.c index 46a801802a1..bf91213dbb0 100644 --- a/storage/myisammrg/myrg_open.c +++ b/storage/myisammrg/myrg_open.c @@ -1,5 +1,6 @@ /* Copyright (c) 2000, 2011, Oracle and/or its affiliates + Copyright (c) 2010, 2020, MariaDB Corporation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -38,7 +39,7 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) int save_errno,errpos=0; uint files= 0, i, dir_length, length, UNINIT_VAR(key_parts), min_keys= 0; ulonglong file_offset=0; - char name_buff[FN_REFLEN*2],buff[FN_REFLEN],*end; + char name_buff[FN_REFLEN*2],buff[FN_REFLEN]; MYRG_INFO *m_info=0; File fd; IO_CACHE file; @@ -62,8 +63,9 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) dir_length=dirname_part(name_buff, name, &name_buff_length); while ((length=my_b_gets(&file,buff,FN_REFLEN-1))) { - if ((end=buff+length)[-1] == '\n') - end[-1]='\0'; + char *end= &buff[length - 1]; + if (*end == '\n') + *end= '\0'; if (buff[0] && buff[0] != '#') files++; } @@ -71,8 +73,9 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) my_b_seek(&file, 0); while ((length=my_b_gets(&file,buff,FN_REFLEN-1))) { - if ((end=buff+length)[-1] == '\n') - *--end='\0'; + char *end= &buff[length - 1]; + if (*end == '\n') + *end= '\0'; if (!buff[0]) continue; /* Skip empty lines */ if (buff[0] == '#') |