Commit ee17f728 authored by Marko Mäkelä's avatar Marko Mäkelä

TruncateLogParser::scan(): Simplify string operations

This also fixes -Wstringop-truncation that GCC 8 issued for strncpy().
parent 945edfff
......@@ -563,7 +563,7 @@ TruncateLogParser::scan(
while (fil_file_readdir_next_file(
&err, dir_path, dir, &fileinfo) == 0) {
ulint nm_len = strlen(fileinfo.name);
const size_t nm_len = strlen(fileinfo.name);
if (fileinfo.type == OS_FILE_TYPE_FILE
&& nm_len > sizeof "ib_trunc.log"
......@@ -586,18 +586,13 @@ TruncateLogParser::scan(
err = DB_OUT_OF_MEMORY;
break;
}
memset(log_file_name, 0, sz);
strncpy(log_file_name, dir_path, dir_len);
ulint log_file_name_len = strlen(log_file_name);
if (log_file_name[log_file_name_len - 1]
!= OS_PATH_SEPARATOR) {
log_file_name[log_file_name_len]
= OS_PATH_SEPARATOR;
log_file_name_len = strlen(log_file_name);
memcpy(log_file_name, dir_path, dir_len);
char* e = log_file_name + dir_len;
if (e[-1] != OS_PATH_SEPARATOR) {
*e++ = OS_PATH_SEPARATOR;
}
strcat(log_file_name, fileinfo.name);
strcpy(e, fileinfo.name);
log_files.push_back(log_file_name);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment