From 113c332f0ee20e854954026eaf4981234c34b78d Mon Sep 17 00:00:00 2001 From: Sean McBride Date: Thu, 26 Dec 2024 21:28:10 -0500 Subject: [PATCH] COMP: fixed cppcheck warnings about unneeded c_str() calls --- Examples/IO/IOPlugin.cxx | 2 +- Modules/Core/Common/src/itkObjectFactoryBase.cxx | 6 +++--- Modules/Core/TestKernel/src/itkTestDriver.cxx | 8 ++++---- .../Core/TestKernel/src/itkTestDriverInclude.cxx | 2 +- Modules/IO/BMP/src/itkBMPImageIO.cxx | 4 ++-- .../itkHDF5ImageIOStreamingReadWriteTest.cxx | 2 +- Modules/IO/HDF5/test/itkHDF5ImageIOTest.cxx | 2 +- Modules/IO/IPL/src/itkIPLCommonImageIO.cxx | 2 +- .../IO/ImageBase/include/itkImageFileWriter.hxx | 2 +- .../src/itkArchetypeSeriesFileNames.cxx | 6 +++--- Modules/IO/ImageBase/src/itkImageIOBase.cxx | 2 +- .../src/itkRegularExpressionSeriesFileNames.cxx | 4 ++-- .../IO/ImageBase/src/itkStreamingImageIOBase.cxx | 2 +- ...ileWriterStreamingPastingCompressingTest1.cxx | 2 +- Modules/IO/JPEG2000/src/itkJPEG2000ImageIO.cxx | 2 +- Modules/IO/MINC/src/itkMINCImageIO.cxx | 16 ++++++++-------- Modules/IO/MINC/test/itkMINCImageIOTest.cxx | 2 +- .../IO/MeshBase/include/itkMeshFileReader.hxx | 2 +- .../IO/MeshBase/include/itkMeshFileWriter.hxx | 2 +- Modules/IO/Meta/src/itkMetaImageIO.cxx | 2 +- .../itkPolygonGroupSpatialObjectXMLFileTest.cxx | 2 +- Modules/IO/Stimulate/src/itkStimulateImageIO.cxx | 4 ++-- .../test/itkIOTransformTxtTest.cxx | 2 +- Modules/IO/XML/include/itkFileTools.h | 10 +++++----- Modules/IO/XML/src/itkXMLFile.cxx | 2 +- Modules/IO/XML/test/itkDOMTest8.cxx | 2 +- .../include/itkLevelSetEquationTermContainer.hxx | 2 +- 27 files changed, 48 insertions(+), 48 deletions(-) diff --git a/Examples/IO/IOPlugin.cxx b/Examples/IO/IOPlugin.cxx index c20c683d8b4..7803596f48c 100644 --- a/Examples/IO/IOPlugin.cxx +++ b/Examples/IO/IOPlugin.cxx @@ -48,7 +48,7 @@ main(int argc, char * argv[]) #endif } myenv += std::string(argv[3]); - itksys::SystemTools::PutEnv(myenv.c_str()); + itksys::SystemTools::PutEnv(myenv); itk::ObjectFactoryBase::ReHash(); } diff --git a/Modules/Core/Common/src/itkObjectFactoryBase.cxx b/Modules/Core/Common/src/itkObjectFactoryBase.cxx index 9515b1e235d..1d99d69f466 100644 --- a/Modules/Core/Common/src/itkObjectFactoryBase.cxx +++ b/Modules/Core/Common/src/itkObjectFactoryBase.cxx @@ -605,7 +605,7 @@ ObjectFactoryBase::PrintSelf(std::ostream & os, Indent indent) const { Superclass::PrintSelf(os, indent); - os << indent << "Factory DLL path: " << m_LibraryPath.c_str() << '\n'; + os << indent << "Factory DLL path: " << m_LibraryPath << '\n'; os << indent << "Factory description: " << this->GetDescription() << std::endl; auto num = static_cast(m_OverrideMap->size()); @@ -614,8 +614,8 @@ ObjectFactoryBase::PrintSelf(std::ostream & os, Indent indent) const indent = indent.GetNextIndent(); for (auto & i : *m_OverrideMap) { - os << indent << "Class : " << i.first.c_str() << '\n'; - os << indent << "Overridden with: " << i.second.m_OverrideWithName.c_str() << std::endl; + os << indent << "Class : " << i.first << '\n'; + os << indent << "Overridden with: " << i.second.m_OverrideWithName << std::endl; os << indent << "Enable flag: " << i.second.m_EnabledFlag << std::endl; os << indent << "Create object: " << i.second.m_CreateObject << std::endl; os << std::endl; diff --git a/Modules/Core/TestKernel/src/itkTestDriver.cxx b/Modules/Core/TestKernel/src/itkTestDriver.cxx index d8862be649b..90f3ef3b73e 100644 --- a/Modules/Core/TestKernel/src/itkTestDriver.cxx +++ b/Modules/Core/TestKernel/src/itkTestDriver.cxx @@ -105,7 +105,7 @@ AddEntriesBeforeLibraryPath(const ArgumentsList & args) libpath += ITK_TEST_DRIVER_PATH_SEP; libpath += oldenv; } - itksys::SystemTools::PutEnv(libpath.c_str()); + itksys::SystemTools::PutEnv(libpath); // on some 64 bit systems, LD_LIBRARY_PATH_64 is used before // LD_LIBRARY_PATH if it is set. It can lead the test to load // the system library instead of the expected one, so this @@ -121,7 +121,7 @@ AddEntriesBeforeLibraryPath(const ArgumentsList & args) libpath64 += ITK_TEST_DRIVER_PATH_SEP; libpath64 += oldenv64; } - itksys::SystemTools::PutEnv(libpath64.c_str()); + itksys::SystemTools::PutEnv(libpath64); } ++i; @@ -145,7 +145,7 @@ AddEntriesBeforeEnvironment(const ArgumentsList & args) env += ITK_TEST_DRIVER_PATH_SEP; env += oldenv; } - itksys::SystemTools::PutEnv(env.c_str()); + itksys::SystemTools::PutEnv(env); i += 2; } @@ -168,7 +168,7 @@ AddEntriesBeforeEnvironmentWithSeparator(const ArgumentsList & args) env += args[i + 2]; env += oldenv; } - itksys::SystemTools::PutEnv(env.c_str()); + itksys::SystemTools::PutEnv(env); i += 3; } diff --git a/Modules/Core/TestKernel/src/itkTestDriverInclude.cxx b/Modules/Core/TestKernel/src/itkTestDriverInclude.cxx index a168aa4f8de..5967ec5ac14 100644 --- a/Modules/Core/TestKernel/src/itkTestDriverInclude.cxx +++ b/Modules/Core/TestKernel/src/itkTestDriverInclude.cxx @@ -259,7 +259,7 @@ ProcessArguments(int * argc, ArgumentStringType * argv, ProcessedOutputType * pr // set the environment which will be read by the subprocess std::string threadEnv = "ITK_GLOBAL_DEFAULT_NUMBER_OF_THREADS="; threadEnv += (*argv)[i + 1]; - itksys::SystemTools::PutEnv(threadEnv.c_str()); + itksys::SystemTools::PutEnv(threadEnv); // and set the number of threads locally for the comparison itk::MultiThreaderBase::SetGlobalDefaultNumberOfThreads(std::stoi((*argv)[i + 1])); *argv += 2; diff --git a/Modules/IO/BMP/src/itkBMPImageIO.cxx b/Modules/IO/BMP/src/itkBMPImageIO.cxx index 3e6b04b3b61..aabdf3cb576 100644 --- a/Modules/IO/BMP/src/itkBMPImageIO.cxx +++ b/Modules/IO/BMP/src/itkBMPImageIO.cxx @@ -395,7 +395,7 @@ BMPImageIO::ReadImageInformation() // error checking if ((infoSize != 40) && (infoSize != 12)) { - itkExceptionMacro("Unknown file type! " << m_FileName.c_str() << " is not a Windows BMP file!"); + itkExceptionMacro("Unknown file type! " << m_FileName << " is not a Windows BMP file!"); } // there are two different types of BMP files @@ -429,7 +429,7 @@ BMPImageIO::ReadImageInformation() // error checking if ((infoSize != 40) && (infoSize != 12)) { - itkExceptionMacro("Unknown file type! " << m_FileName.c_str() << " is not a Windows BMP file!"); + itkExceptionMacro("Unknown file type! " << m_FileName << " is not a Windows BMP file!"); } // there are two different types of BMP files diff --git a/Modules/IO/HDF5/test/itkHDF5ImageIOStreamingReadWriteTest.cxx b/Modules/IO/HDF5/test/itkHDF5ImageIOStreamingReadWriteTest.cxx index bc265b06447..726ddbe17c1 100644 --- a/Modules/IO/HDF5/test/itkHDF5ImageIOStreamingReadWriteTest.cxx +++ b/Modules/IO/HDF5/test/itkHDF5ImageIOStreamingReadWriteTest.cxx @@ -239,7 +239,7 @@ itkHDF5ImageIOStreamingReadWriteTest(int argc, char * argv[]) { prefix = *++argv; --argc; - itksys::SystemTools::ChangeDirectory(prefix.c_str()); + itksys::SystemTools::ChangeDirectory(prefix); } itk::ObjectFactoryBase::RegisterFactory(itk::HDF5ImageIOFactory::New()); diff --git a/Modules/IO/HDF5/test/itkHDF5ImageIOTest.cxx b/Modules/IO/HDF5/test/itkHDF5ImageIOTest.cxx index f569243465f..121feb6d600 100644 --- a/Modules/IO/HDF5/test/itkHDF5ImageIOTest.cxx +++ b/Modules/IO/HDF5/test/itkHDF5ImageIOTest.cxx @@ -345,7 +345,7 @@ itkHDF5ImageIOTest(int argc, char * argv[]) { prefix = *++argv; --argc; - itksys::SystemTools::ChangeDirectory(prefix.c_str()); + itksys::SystemTools::ChangeDirectory(prefix); } itk::ObjectFactoryBase::RegisterFactory(itk::HDF5ImageIOFactory::New()); diff --git a/Modules/IO/IPL/src/itkIPLCommonImageIO.cxx b/Modules/IO/IPL/src/itkIPLCommonImageIO.cxx index c5f9671ac14..3eeb3cc9022 100644 --- a/Modules/IO/IPL/src/itkIPLCommonImageIO.cxx +++ b/Modules/IO/IPL/src/itkIPLCommonImageIO.cxx @@ -128,7 +128,7 @@ IPLCommonImageIO::ReadImageInformation() // TODO -- use std::string instead of C strings char imageMask[IOCommon::ITK_MAXPATHLEN + 1]; char imagePath[IOCommon::ITK_MAXPATHLEN + 1]; - const std::string _imagePath = itksys::SystemTools::CollapseFullPath(FileNameToRead.c_str()); + const std::string _imagePath = itksys::SystemTools::CollapseFullPath(FileNameToRead); FileNameToRead = _imagePath; diff --git a/Modules/IO/ImageBase/include/itkImageFileWriter.hxx b/Modules/IO/ImageBase/include/itkImageFileWriter.hxx index 702ed3051f8..7fe12a99e29 100644 --- a/Modules/IO/ImageBase/include/itkImageFileWriter.hxx +++ b/Modules/IO/ImageBase/include/itkImageFileWriter.hxx @@ -117,7 +117,7 @@ ImageFileWriter::Write() ImageFileWriterException e(__FILE__, __LINE__); std::ostringstream msg; const std::list allobjects = ObjectFactoryBase::CreateAllInstance("itkImageIOBase"); - msg << " Could not create IO object for writing file " << m_FileName.c_str() << std::endl; + msg << " Could not create IO object for writing file " << m_FileName << std::endl; if (!allobjects.empty()) { msg << " Tried to create one of the following:" << std::endl; diff --git a/Modules/IO/ImageBase/src/itkArchetypeSeriesFileNames.cxx b/Modules/IO/ImageBase/src/itkArchetypeSeriesFileNames.cxx index 40d0b3e7534..6c6bf5bbbbe 100644 --- a/Modules/IO/ImageBase/src/itkArchetypeSeriesFileNames.cxx +++ b/Modules/IO/ImageBase/src/itkArchetypeSeriesFileNames.cxx @@ -84,14 +84,14 @@ ArchetypeSeriesFileNames::Scan() std::string unixArchetype = m_Archetype; itksys::SystemTools::ConvertToUnixSlashes(unixArchetype); - if (itksys::SystemTools::FileIsDirectory(unixArchetype.c_str())) + if (itksys::SystemTools::FileIsDirectory(unixArchetype)) { return; } // Parse the fileNameName and fileNamePath - const std::string origFileName = itksys::SystemTools::GetFilenameName(unixArchetype.c_str()); - std::string fileNamePath = itksys::SystemTools::GetFilenamePath(unixArchetype.c_str()); + const std::string origFileName = itksys::SystemTools::GetFilenameName(unixArchetype); + std::string fileNamePath = itksys::SystemTools::GetFilenamePath(unixArchetype); std::string pathPrefix; // "Clean" the filename by escaping any special characters with backslashes. diff --git a/Modules/IO/ImageBase/src/itkImageIOBase.cxx b/Modules/IO/ImageBase/src/itkImageIOBase.cxx index 76f8b9e0de0..30b57082ca6 100644 --- a/Modules/IO/ImageBase/src/itkImageIOBase.cxx +++ b/Modules/IO/ImageBase/src/itkImageIOBase.cxx @@ -674,7 +674,7 @@ ImageIOBase::OpenFileForWriting(std::ofstream & outputStream, const std::string // opening a nonexistent file for reading + writing is not allowed on some platforms if (!itksys::SystemTools::FileExists(filename.c_str())) { - itksys::SystemTools::Touch(filename.c_str(), true); + itksys::SystemTools::Touch(filename, true); // don't worry about failure here, errors should be detected later when the file // is "actually" opened, unless there is a race condition } diff --git a/Modules/IO/ImageBase/src/itkRegularExpressionSeriesFileNames.cxx b/Modules/IO/ImageBase/src/itkRegularExpressionSeriesFileNames.cxx index d0527a1be13..6913a28230d 100644 --- a/Modules/IO/ImageBase/src/itkRegularExpressionSeriesFileNames.cxx +++ b/Modules/IO/ImageBase/src/itkRegularExpressionSeriesFileNames.cxx @@ -60,9 +60,9 @@ RegularExpressionSeriesFileNames::GetFileNames() // Process all files in the directory itksys::Directory fileDir; - if (!fileDir.Load(m_Directory.c_str())) + if (!fileDir.Load(m_Directory)) { - itkExceptionMacro("Directory " << m_Directory.c_str() << " cannot be read!"); + itkExceptionMacro("Directory " << m_Directory << " cannot be read!"); } std::vector> sortedBySubMatch; diff --git a/Modules/IO/ImageBase/src/itkStreamingImageIOBase.cxx b/Modules/IO/ImageBase/src/itkStreamingImageIOBase.cxx index 27901661689..1c180da1ecc 100644 --- a/Modules/IO/ImageBase/src/itkStreamingImageIOBase.cxx +++ b/Modules/IO/ImageBase/src/itkStreamingImageIOBase.cxx @@ -345,7 +345,7 @@ StreamingImageIOBase::GetActualNumberOfSplitsForWriting(unsigned int nu // need to remove the file incase the file doesn't match our // current header/meta data information - if (!itksys::SystemTools::RemoveFile(m_FileName.c_str())) + if (!itksys::SystemTools::RemoveFile(m_FileName)) { itkExceptionMacro("Unable to remove file for streaming: " << m_FileName); } diff --git a/Modules/IO/ImageBase/test/itkImageFileWriterStreamingPastingCompressingTest1.cxx b/Modules/IO/ImageBase/test/itkImageFileWriterStreamingPastingCompressingTest1.cxx index 08f186df9b4..f3ef5843e11 100644 --- a/Modules/IO/ImageBase/test/itkImageFileWriterStreamingPastingCompressingTest1.cxx +++ b/Modules/IO/ImageBase/test/itkImageFileWriterStreamingPastingCompressingTest1.cxx @@ -111,7 +111,7 @@ ActualTest(std::string inputFileName, // We remove the output file // NOTE ALEX: should we check it exists first? - itksys::SystemTools::RemoveFile(outputFileName.c_str()); + itksys::SystemTools::RemoveFile(outputFileName); using PixelType = unsigned char; using ImageType = itk::Image; diff --git a/Modules/IO/JPEG2000/src/itkJPEG2000ImageIO.cxx b/Modules/IO/JPEG2000/src/itkJPEG2000ImageIO.cxx index 6f113aa5426..0ecbc1bd25a 100644 --- a/Modules/IO/JPEG2000/src/itkJPEG2000ImageIO.cxx +++ b/Modules/IO/JPEG2000/src/itkJPEG2000ImageIO.cxx @@ -712,7 +712,7 @@ JPEG2000ImageIO::Write(const void * buffer) opj_cparameters_t parameters; opj_set_default_encoder_parameters(¶meters); - const std::string extension = itksys::SystemTools::GetFilenameLastExtension(this->m_FileName.c_str()); + const std::string extension = itksys::SystemTools::GetFilenameLastExtension(this->m_FileName); if (extension == ".j2k") { parameters.cod_format = static_cast(JPEG2000ImageIOInternal::DecodingFormatEnum::J2K_CFMT); diff --git a/Modules/IO/MINC/src/itkMINCImageIO.cxx b/Modules/IO/MINC/src/itkMINCImageIO.cxx index b30cd550875..19c5fe38f1c 100644 --- a/Modules/IO/MINC/src/itkMINCImageIO.cxx +++ b/Modules/IO/MINC/src/itkMINCImageIO.cxx @@ -292,7 +292,7 @@ MINCImageIO::ReadImageInformation() if (miopen_volume(m_FileName.c_str(), MI2_OPEN_READ, &m_MINCPImpl->m_Volume) < 0) { // Error opening the volume - itkExceptionMacro("Could not open file \"" << m_FileName.c_str() << "\"."); + itkExceptionMacro("Could not open file \"" << m_FileName << "\"."); } // find out how many dimensions are there regularly sampled @@ -1059,7 +1059,7 @@ MINCImageIO::WriteImageInformation() if (ExposeMetaData(thisDic, "dimension_order", dimension_order)) { // the format should be ((+|-)(X|Y|Z|V|T))* - // std::cout<<"Restoring original dimension order:"<m_NDims - 1 - ((nComp > 1 ? 1 : 0) + 2); break; default: - itkDebugMacro("Dimension order is incorrect " << dimension_order.c_str()); + itkDebugMacro("Dimension order is incorrect " << dimension_order); dimorder_good = false; j = 0; break; @@ -1140,7 +1140,7 @@ MINCImageIO::WriteImageInformation() } else { - itkDebugMacro("Dimension order is incorrect " << dimension_order.c_str()); + itkDebugMacro("Dimension order is incorrect " << dimension_order); } } @@ -1196,14 +1196,14 @@ MINCImageIO::WriteImageInformation() // Error opening the volume MINCIOFreeTmpDimHandle(minc_dimensions, m_MINCPImpl->m_MincApparentDims); mifree_volume_props(hprops); - itkExceptionMacro("Could not open file \"" << m_FileName.c_str() << "\"."); + itkExceptionMacro("Could not open file \"" << m_FileName << "\"."); } if (micreate_volume_image(m_MINCPImpl->m_Volume) < 0) { // Error opening the volume mifree_volume_props(hprops); - itkExceptionMacro("Could not create image in file \"" << m_FileName.c_str() << "\"."); + itkExceptionMacro("Could not create image in file \"" << m_FileName << "\"."); } if (miset_apparent_dimension_order(m_MINCPImpl->m_Volume, minc_dimensions, m_MINCPImpl->m_MincApparentDims) < 0) diff --git a/Modules/IO/MINC/test/itkMINCImageIOTest.cxx b/Modules/IO/MINC/test/itkMINCImageIOTest.cxx index 22ac5b558c9..9e46fa38674 100644 --- a/Modules/IO/MINC/test/itkMINCImageIOTest.cxx +++ b/Modules/IO/MINC/test/itkMINCImageIOTest.cxx @@ -780,7 +780,7 @@ itkMINCImageIOTest(int argc, char * argv[]) { prefix = *++argv; --argc; - itksys::SystemTools::ChangeDirectory(prefix.c_str()); + itksys::SystemTools::ChangeDirectory(prefix); } itk::ObjectFactoryBase::RegisterFactory(itk::MINCImageIOFactory::New(), diff --git a/Modules/IO/MeshBase/include/itkMeshFileReader.hxx b/Modules/IO/MeshBase/include/itkMeshFileReader.hxx index 91fde04f9c3..3ba8b9bcba4 100644 --- a/Modules/IO/MeshBase/include/itkMeshFileReader.hxx +++ b/Modules/IO/MeshBase/include/itkMeshFileReader.hxx @@ -450,7 +450,7 @@ MeshFileReader::Ge if (m_MeshIO.IsNull()) { std::ostringstream msg; - msg << " Could not create IO object for file " << m_FileName.c_str() << std::endl; + msg << " Could not create IO object for file " << m_FileName << std::endl; if (!m_ExceptionMessage.empty()) { msg << m_ExceptionMessage; diff --git a/Modules/IO/MeshBase/include/itkMeshFileWriter.hxx b/Modules/IO/MeshBase/include/itkMeshFileWriter.hxx index 699dce9e9ff..034bba7c362 100644 --- a/Modules/IO/MeshBase/include/itkMeshFileWriter.hxx +++ b/Modules/IO/MeshBase/include/itkMeshFileWriter.hxx @@ -101,7 +101,7 @@ MeshFileWriter::Write() { MeshFileWriterException e(__FILE__, __LINE__); std::ostringstream msg; - msg << " Could not create IO object for file " << m_FileName.c_str() << std::endl + msg << " Could not create IO object for file " << m_FileName << std::endl << " Tried to create one of the following:" << std::endl; { for (auto & allobject : ObjectFactoryBase::CreateAllInstance("itkMeshIOBase")) diff --git a/Modules/IO/Meta/src/itkMetaImageIO.cxx b/Modules/IO/Meta/src/itkMetaImageIO.cxx index 15a94439bcd..b31b46755c0 100644 --- a/Modules/IO/Meta/src/itkMetaImageIO.cxx +++ b/Modules/IO/Meta/src/itkMetaImageIO.cxx @@ -1046,7 +1046,7 @@ MetaImageIO::GetActualNumberOfSplitsForWriting(unsigned int numberOfReq // need to remove the file incase the file doesn't match our // current header/meta data information - if (!itksys::SystemTools::RemoveFile(m_FileName.c_str())) + if (!itksys::SystemTools::RemoveFile(m_FileName)) { itkExceptionMacro("Unable to remove file for streaming: " << m_FileName); } diff --git a/Modules/IO/SpatialObjects/test/itkPolygonGroupSpatialObjectXMLFileTest.cxx b/Modules/IO/SpatialObjects/test/itkPolygonGroupSpatialObjectXMLFileTest.cxx index babf4189101..3459fd36606 100644 --- a/Modules/IO/SpatialObjects/test/itkPolygonGroupSpatialObjectXMLFileTest.cxx +++ b/Modules/IO/SpatialObjects/test/itkPolygonGroupSpatialObjectXMLFileTest.cxx @@ -205,7 +205,7 @@ itkPolygonGroupSpatialObjectXMLFileTest(int argc, char * argv[]) std::cerr << "Error Reading file" << std::endl; return EXIT_FAILURE; } - itksys::SystemTools::RemoveFile(xmlfilename.c_str()); + itksys::SystemTools::RemoveFile(xmlfilename); return testPolygonGroupEquivalence(PolygonGroup, PGroupFromFile); } diff --git a/Modules/IO/Stimulate/src/itkStimulateImageIO.cxx b/Modules/IO/Stimulate/src/itkStimulateImageIO.cxx index f62c323dcc7..dd6cc8855bd 100644 --- a/Modules/IO/Stimulate/src/itkStimulateImageIO.cxx +++ b/Modules/IO/Stimulate/src/itkStimulateImageIO.cxx @@ -415,7 +415,7 @@ StimulateImageIO::InternalReadImageInformation(std::ifstream & file) const std::string datafilenamePath = ::itksys::SystemTools::GetFilenamePath(datafilename); if (datafilenamePath.empty()) { - const std::string fileNamePath = ::itksys::SystemTools::GetFilenamePath(m_FileName.c_str()); + const std::string fileNamePath = ::itksys::SystemTools::GetFilenamePath(m_FileName); m_DataFileName = fileNamePath + "/" + datafilename; } else @@ -566,7 +566,7 @@ StimulateImageIO::Write(const void * buffer) // determine datafile given the spr filename m_DataFileName = m_FileName; m_DataFileName.replace(m_DataFileName.length() - 3, 3, "sdt"); - file << "\nstimFileName: " << m_DataFileName.c_str(); + file << "\nstimFileName: " << m_DataFileName; // Last carrier return: file << '\n'; diff --git a/Modules/IO/TransformInsightLegacy/test/itkIOTransformTxtTest.cxx b/Modules/IO/TransformInsightLegacy/test/itkIOTransformTxtTest.cxx index 4c850786f42..bfdc232ddf1 100644 --- a/Modules/IO/TransformInsightLegacy/test/itkIOTransformTxtTest.cxx +++ b/Modules/IO/TransformInsightLegacy/test/itkIOTransformTxtTest.cxx @@ -201,7 +201,7 @@ int secondTest(const std::string & outputDirectory) { std::filebuf fb; - fb.open((outputDirectory + "IllegalTransform.txt").c_str(), std::ios::out); + fb.open((outputDirectory + "IllegalTransform.txt"), std::ios::out); std::ostream os(&fb); os << "#Insight Transform File V1.0" << std::endl << "#Transform 0" << std::endl diff --git a/Modules/IO/XML/include/itkFileTools.h b/Modules/IO/XML/include/itkFileTools.h index 84680c9c117..1d263529d89 100644 --- a/Modules/IO/XML/include/itkFileTools.h +++ b/Modules/IO/XML/include/itkFileTools.h @@ -62,7 +62,7 @@ FileTools::CreateDirectory(const std::string & dir) } // do nothing if it already exists - if (dir.empty() || "." == dir || itksys::SystemTools::FileIsDirectory(dir.c_str())) + if (dir.empty() || "." == dir || itksys::SystemTools::FileIsDirectory(dir)) { return; } @@ -71,7 +71,7 @@ FileTools::CreateDirectory(const std::string & dir) itksys::SystemTools::MakeDirectory(dir.c_str()); // check successful or not - if (!itksys::SystemTools::FileIsDirectory(dir.c_str())) + if (!itksys::SystemTools::FileIsDirectory(dir)) { ExceptionObject eo(__FILE__, __LINE__, "directory cannot be created"); throw eo; @@ -82,7 +82,7 @@ FileTools::CreateDirectory(const std::string & dir) inline void FileTools::CreateFile(const std::string & fn) { - if (fn.empty() || itksys::SystemTools::FileIsDirectory(fn.c_str())) + if (fn.empty() || itksys::SystemTools::FileIsDirectory(fn)) { ExceptionObject eo(__FILE__, __LINE__, "file cannot be created"); throw eo; @@ -95,11 +95,11 @@ FileTools::CreateFile(const std::string & fn) } // make sure the directory exists - const std::string dir = itksys::SystemTools::GetFilenamePath(fn.c_str()); + const std::string dir = itksys::SystemTools::GetFilenamePath(fn); FileTools::CreateDirectory(dir); // create the file - itksys::SystemTools::Touch(fn.c_str(), true); + itksys::SystemTools::Touch(fn, true); // check successful or not if (!itksys::SystemTools::FileExists(fn.c_str(), true)) diff --git a/Modules/IO/XML/src/itkXMLFile.cxx b/Modules/IO/XML/src/itkXMLFile.cxx index 02a1389c8d1..d4dabcfda02 100644 --- a/Modules/IO/XML/src/itkXMLFile.cxx +++ b/Modules/IO/XML/src/itkXMLFile.cxx @@ -85,7 +85,7 @@ XMLReaderBase::parse() } // Default stream parser just reads a block at a time. - const std::streamsize filesize = itksys::SystemTools::FileLength(m_Filename.c_str()); + const std::streamsize filesize = itksys::SystemTools::FileLength(m_Filename); const auto buffer = make_unique_for_overwrite(filesize); diff --git a/Modules/IO/XML/test/itkDOMTest8.cxx b/Modules/IO/XML/test/itkDOMTest8.cxx index 70876118413..f0476e886b5 100644 --- a/Modules/IO/XML/test/itkDOMTest8.cxx +++ b/Modules/IO/XML/test/itkDOMTest8.cxx @@ -44,7 +44,7 @@ itkDOMTest8(int argc, char * argv[]) // create the file in the directory std::string fn(argv[1]); fn.append(argv[2]); - itk::FileTools::CreateFile(fn.c_str()); + itk::FileTools::CreateFile(fn); // the testings are successful if reached here } diff --git a/Modules/Segmentation/LevelSetsv4/include/itkLevelSetEquationTermContainer.hxx b/Modules/Segmentation/LevelSetsv4/include/itkLevelSetEquationTermContainer.hxx index 02ef0ab6087..93d6ab68b5d 100644 --- a/Modules/Segmentation/LevelSetsv4/include/itkLevelSetEquationTermContainer.hxx +++ b/Modules/Segmentation/LevelSetsv4/include/itkLevelSetEquationTermContainer.hxx @@ -186,7 +186,7 @@ LevelSetEquationTermContainer::GetTerm(const st if (it == m_Container.end()) { - itkGenericExceptionMacro("the term " << iName.c_str() << " is not present in the container"); + itkGenericExceptionMacro("the term " << iName << " is not present in the container"); } return it->second;