Skip to content

Commit

Permalink
Fix GCC 10.0 -Wstringop-overflow
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dr-m committed Mar 13, 2020
1 parent d9d3c22 commit ed21202
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions storage/myisammrg/myrg_open.c
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -62,17 +63,19 @@ 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++;
}

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] == '#')
Expand Down

0 comments on commit ed21202

Please sign in to comment.