silence -Wstring-truncation for correct use of strncpy (#5146)

- ensuring header is zerod
This commit is contained in:
Nathan Schulte 2023-03-01 20:43:42 -06:00 committed by GitHub
parent 91c1d5aa63
commit c09c4ba374
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -43,10 +43,13 @@ void LogField::writeHeader(Writer& outBuffer) const {
buffer[54] = m_digits;
// Offset 55, (optional) category string
memset(&buffer[55], 0, 34);
if (m_category) {
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wstringop-truncation"
// strncpy's exclusion of null terminator is correct and appropriate behavior for this field
strncpy(&buffer[55], m_category, 34);
} else {
memset(&buffer[55], 0, 34);
#pragma GCC diagnostic pop
}
// Total size = 89