diff options
author | Marc Chevrier <marc.chevrier@gmail.com> | 2023-05-28 14:27:03 (GMT) |
---|---|---|
committer | Marc Chevrier <marc.chevrier@gmail.com> | 2023-05-30 14:41:59 (GMT) |
commit | 4fc322bab421a83b12977aadc7dca247db8ae541 (patch) | |
tree | 3e57b548bd2326f3a848eb23ad66da33d28f60b5 /Source/cmTryRunCommand.cxx | |
parent | b0d1ddb7234950374977b83f8dbded806c15b356 (diff) | |
download | CMake-4fc322bab421a83b12977aadc7dca247db8ae541.zip CMake-4fc322bab421a83b12977aadc7dca247db8ae541.tar.gz CMake-4fc322bab421a83b12977aadc7dca247db8ae541.tar.bz2 |
AddCacheEntry: Suppress raw pointer usage
Diffstat (limited to 'Source/cmTryRunCommand.cxx')
-rw-r--r-- | Source/cmTryRunCommand.cxx | 27 |
1 files changed, 12 insertions, 15 deletions
diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx index 368155c..c24c418 100644 --- a/Source/cmTryRunCommand.cxx +++ b/Source/cmTryRunCommand.cxx @@ -2,7 +2,6 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmTryRunCommand.h" -#include <cstdio> #include <stdexcept> #include <cm/optional> @@ -293,11 +292,9 @@ void TryRunCommandImpl::RunExecutable(const std::string& runArgs, workDir ? workDir->c_str() : nullptr, cmSystemTools::OUTPUT_NONE, cmDuration::zero()); // set the run var - char retChar[16]; - const char* retStr; + std::string retStr; if (worked) { - snprintf(retChar, sizeof(retChar), "%i", retVal); - retStr = retChar; + retStr = std::to_string(retVal); } else { retStr = "FAILED_TO_RUN"; } @@ -351,7 +348,7 @@ void TryRunCommandImpl::DoNotRunExecutable( detailsString); this->Makefile->AddCacheDefinition(this->RunResultVariable, "PLEASE_FILL_OUT-FAILED_TO_RUN", - comment.c_str(), cmStateEnums::STRING); + comment, cmStateEnums::STRING); cmState* state = this->Makefile->GetState(); cmValue existingValue = state->GetCacheEntryValue(this->RunResultVariable); @@ -372,9 +369,9 @@ void TryRunCommandImpl::DoNotRunExecutable( "would have printed on stdout on its target platform.\n", detailsString); - this->Makefile->AddCacheDefinition( - internalRunOutputStdOutName, "PLEASE_FILL_OUT-NOTFOUND", - comment.c_str(), cmStateEnums::STRING); + this->Makefile->AddCacheDefinition(internalRunOutputStdOutName, + "PLEASE_FILL_OUT-NOTFOUND", comment, + cmStateEnums::STRING); cmState* state = this->Makefile->GetState(); cmValue existing = state->GetCacheEntryValue(internalRunOutputStdOutName); @@ -394,9 +391,9 @@ void TryRunCommandImpl::DoNotRunExecutable( "would have printed on stderr on its target platform.\n", detailsString); - this->Makefile->AddCacheDefinition( - internalRunOutputStdErrName, "PLEASE_FILL_OUT-NOTFOUND", - comment.c_str(), cmStateEnums::STRING); + this->Makefile->AddCacheDefinition(internalRunOutputStdErrName, + "PLEASE_FILL_OUT-NOTFOUND", comment, + cmStateEnums::STRING); cmState* state = this->Makefile->GetState(); cmValue existing = state->GetCacheEntryValue(internalRunOutputStdErrName); @@ -416,9 +413,9 @@ void TryRunCommandImpl::DoNotRunExecutable( "would have printed on stdout and stderr on its target platform.\n", detailsString); - this->Makefile->AddCacheDefinition( - internalRunOutputName, "PLEASE_FILL_OUT-NOTFOUND", comment.c_str(), - cmStateEnums::STRING); + this->Makefile->AddCacheDefinition(internalRunOutputName, + "PLEASE_FILL_OUT-NOTFOUND", comment, + cmStateEnums::STRING); cmState* state = this->Makefile->GetState(); cmValue existing = state->GetCacheEntryValue(internalRunOutputName); if (existing) { |