mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
COMP: avoid -Wstringop-truncation warning
- the gcc c++/9 includes now inline strncpy, which obliterates the previous method of suppressing the warning. Now simply allocate additional space for the nul character. COMP: silence some icc warnings
This commit is contained in:
@ -166,19 +166,15 @@ Foam::Ostream& Foam::ensightFile::write
|
||||
|
||||
Foam::Ostream& Foam::ensightFile::write(const char* value)
|
||||
{
|
||||
// Parentheses around strncpy to silence the GCC -Wstringop-truncation
|
||||
// warning, which is spurious here.
|
||||
// The max-size and buffer-size *are* identical, which means the buffer
|
||||
// may not have a nul terminator. However, this is properly handled in
|
||||
// the subsequent binary write and the ASCII write explicitly adds
|
||||
// a nul terminator.
|
||||
// Output 80 chars, but allocate for trailing nul character
|
||||
// to avoid -Wstringop-truncation warnings/errors.
|
||||
|
||||
char buf[80];
|
||||
(strncpy(buf, value, 80)); // max 80 chars or padded with nul if smaller
|
||||
char buf[80+1];
|
||||
strncpy(buf, value, 80); // max 80 chars or padded with nul if smaller
|
||||
|
||||
if (format() == IOstream::BINARY)
|
||||
{
|
||||
write(buf, sizeof(buf));
|
||||
write(buf, 80);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user