mtr_t::log_file_op(): Fix -Wnonnull
GCC 12.2.0 could issue -Wnonnull for an unreachable call to strlen(new_path). Let us prevent that by replacing the condition (type == FILE_RENAME) with the equivalent (new_path). This should also optimize the generated code, because the life time of the parameter "type" will be reduced.
This commit is contained in:
parent
b331cde26b
commit
4010dff058
@ -1554,17 +1554,18 @@ inline void mtr_t::log_file_op(mfile_type_t type, ulint space_id,
|
|||||||
m_last= nullptr;
|
m_last= nullptr;
|
||||||
|
|
||||||
const size_t len= strlen(path);
|
const size_t len= strlen(path);
|
||||||
const size_t new_len= type == FILE_RENAME ? 1 + strlen(new_path) : 0;
|
const size_t new_len= new_path ? 1 + strlen(new_path) : 0;
|
||||||
ut_ad(len > 0);
|
ut_ad(len > 0);
|
||||||
byte *const log_ptr= m_log.open(1 + 3/*length*/ + 5/*space_id*/ +
|
byte *const log_ptr= m_log.open(1 + 3/*length*/ + 5/*space_id*/ +
|
||||||
1/*page_no=0*/);
|
1/*page_no=0*/);
|
||||||
|
*log_ptr= type;
|
||||||
byte *end= log_ptr + 1;
|
byte *end= log_ptr + 1;
|
||||||
end= mlog_encode_varint(end, space_id);
|
end= mlog_encode_varint(end, space_id);
|
||||||
*end++= 0;
|
*end++= 0;
|
||||||
if (UNIV_LIKELY(end + len + new_len >= &log_ptr[16]))
|
const byte *const final_end= end + len + new_len;
|
||||||
|
if (UNIV_LIKELY(final_end >= &log_ptr[16]))
|
||||||
{
|
{
|
||||||
*log_ptr= type;
|
size_t total_len= final_end - log_ptr - 15;
|
||||||
size_t total_len= len + new_len + end - log_ptr - 15;
|
|
||||||
if (total_len >= MIN_3BYTE)
|
if (total_len >= MIN_3BYTE)
|
||||||
total_len+= 2;
|
total_len+= 2;
|
||||||
else if (total_len >= MIN_2BYTE)
|
else if (total_len >= MIN_2BYTE)
|
||||||
@ -1575,13 +1576,13 @@ inline void mtr_t::log_file_op(mfile_type_t type, ulint space_id,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*log_ptr= static_cast<byte>(type | (end + len + new_len - &log_ptr[1]));
|
*log_ptr= static_cast<byte>(*log_ptr | (final_end - &log_ptr[1]));
|
||||||
ut_ad(*log_ptr & 15);
|
ut_ad(*log_ptr & 15);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_log.close(end);
|
m_log.close(end);
|
||||||
|
|
||||||
if (type == FILE_RENAME)
|
if (new_path)
|
||||||
{
|
{
|
||||||
ut_ad(strchr(new_path, OS_PATH_SEPARATOR));
|
ut_ad(strchr(new_path, OS_PATH_SEPARATOR));
|
||||||
m_log.push(reinterpret_cast<const byte*>(path), uint32_t(len + 1));
|
m_log.push(reinterpret_cast<const byte*>(path), uint32_t(len + 1));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user