diff options
author | Brad King <brad.king@kitware.com> | 2022-01-28 12:57:35 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-01-28 13:06:13 (GMT) |
commit | ae101921e8441d2a87ce0f09804cad2409726cc5 (patch) | |
tree | 9e458983716b161f24bf971ebbdec8979dc8f464 /Source/cmLocalUnixMakefileGenerator3.cxx | |
parent | ee1bed5058c69061dbc2c64871cabd8c2ab82d0e (diff) | |
download | CMake-ae101921e8441d2a87ce0f09804cad2409726cc5.zip CMake-ae101921e8441d2a87ce0f09804cad2409726cc5.tar.gz CMake-ae101921e8441d2a87ce0f09804cad2409726cc5.tar.bz2 |
Source: Avoid gcc 12 compilation warning
GCC 12 warns:
warning: '%04d' directive output may be truncated writing between
4 and 11 bytes into a region of size 5 [-Wformat-truncation=]
The surrounding logic guarantees the formatted integer will never
be more than 4 bytes, but it doesn't hurt to use a larger buffer.
This GCC behavior is documented:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=104012#c5
Diffstat (limited to 'Source/cmLocalUnixMakefileGenerator3.cxx')
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator3.cxx | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 2700ded..0f8cdca 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1274,7 +1274,7 @@ std::string cmLocalUnixMakefileGenerator3::CreateMakeVariable( cmSystemTools::ReplaceString(ret, "-", "__"); cmSystemTools::ReplaceString(ret, "+", "___"); int ni = 0; - char buffer[5]; + char buffer[12]; // make sure the _ version is not already used, if // it is used then add number to the end of the variable while (this->ShortMakeVariableMap.count(ret) && ni < 1000) { @@ -1302,7 +1302,7 @@ std::string cmLocalUnixMakefileGenerator3::CreateMakeVariable( if (static_cast<int>(str1.size()) + static_cast<int>(str2.size()) > size) { str1 = str1.substr(0, size - str2.size()); } - char buffer[5]; + char buffer[12]; int ni = 0; snprintf(buffer, sizeof(buffer), "%04d", ni); ret = str1 + str2 + buffer; |