Commit d4da6980 authored by Brad King's avatar Brad King Committed by Kitware Robot
Browse files

Merge topic 'clangtidy'

775296c8 Applied clang-tidy bugprone-suspicious-string-compare fixes
2c179921 Applied clang-tidy modernize-deprecated-headers
cb541c31

 Auto-fixed various clang-tidy warnings
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Merge-request: !185
parents 589bdb54 775296c8
......@@ -20,9 +20,9 @@
#include <sstream>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#ifdef _MSC_VER
# pragma warning(disable : 4786)
......
......@@ -17,8 +17,8 @@
# include "Encoding.hxx.in"
#endif
#include <stdlib.h>
#include <string.h>
#include <cstdlib>
#include <cstring>
#include <vector>
#ifdef _MSC_VER
......
......@@ -23,9 +23,9 @@
#include <string>
#include <vector>
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <cctype>
#include <cstdio>
#include <cstring>
namespace KWSYS_NAMESPACE {
#if defined(_WIN32) || defined(__APPLE__) || defined(__CYGWIN__)
// On Windows and Apple, no difference between lower and upper case
......
......@@ -28,8 +28,8 @@
# include "RegularExpression.hxx.in"
#endif
#include <stdio.h>
#include <string.h>
#include <cstdio>
#include <cstring>
namespace KWSYS_NAMESPACE {
......@@ -367,8 +367,7 @@ bool RegularExpression::compile(const char* exp)
// Allocate space.
//#ifndef _WIN32
if (this->program != nullptr)
delete[] this->program;
delete[] this->program;
//#endif
this->program = new char[comp.regsize];
this->progsize = static_cast<int>(comp.regsize);
......
......@@ -64,9 +64,9 @@ typedef int siginfo_t;
#else
# include <sys/types.h>
# include <errno.h> // extern int errno;
# include <cerrno> // extern int errno;
# include <csignal>
# include <fcntl.h>
# include <signal.h>
# include <sys/resource.h> // getrlimit
# include <sys/time.h>
# include <sys/utsname.h> // int uname(struct utsname *buf);
......@@ -163,11 +163,11 @@ typedef struct rlimit ResourceLimitType;
# undef KWSYS_SYSTEMINFORMATION_HAS_SYMBOL_LOOKUP
#endif
#include <ctype.h> // int isdigit(int c);
#include <cctype> // int isdigit(int c);
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <memory.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#if defined(KWSYS_USE_LONG_LONG)
# if defined(KWSYS_IOS_HAS_OSTREAM_LONG_LONG)
......@@ -1366,7 +1366,7 @@ std::string SymbolProperties::GetFileName(const std::string& path) const
{
std::string file(path);
if (!this->ReportPath) {
size_t at = file.rfind("/");
size_t at = file.rfind('/');
if (at != std::string::npos) {
file.erase(0, at + 1);
}
......@@ -3387,8 +3387,8 @@ std::string SystemInformationImplementation::ExtractValueFromCpuInfoFile(
size_t pos = buffer.find(word, init);
if (pos != std::string::npos) {
this->CurrentPositionInFile = pos;
pos = buffer.find(":", pos);
size_t pos2 = buffer.find("\n", pos);
pos = buffer.find(':', pos);
size_t pos2 = buffer.find('\n', pos);
if (pos != std::string::npos && pos2 != std::string::npos) {
// It may happen that the beginning matches, but this is still not the
// requested key.
......@@ -3937,7 +3937,7 @@ std::string SystemInformationImplementation::GetProgramStack(int firstFrame,
int wholePath)
{
std::ostringstream oss;
std::string programStack = "";
std::string programStack;
#ifdef KWSYS_SYSTEMINFORMATION_HAS_DBGHELP
(void)wholePath;
......@@ -4688,7 +4688,7 @@ std::string SystemInformationImplementation::ExtractValueFromSysCtl(
size_t pos = this->SysCtlBuffer.find(word);
if (pos != std::string::npos) {
pos = this->SysCtlBuffer.find(": ", pos);
size_t pos2 = this->SysCtlBuffer.find("\n", pos);
size_t pos2 = this->SysCtlBuffer.find('\n', pos);
if (pos != std::string::npos && pos2 != std::string::npos) {
return this->SysCtlBuffer.substr(pos + 2, pos2 - pos - 2);
}
......@@ -5500,13 +5500,13 @@ void SystemInformationImplementation::TrimNewline(std::string& output)
{
// remove \r
std::string::size_type pos = 0;
while ((pos = output.find("\r", pos)) != std::string::npos) {
while ((pos = output.find('\r', pos)) != std::string::npos) {
output.erase(pos);
}
// remove \n
pos = 0;
while ((pos = output.find("\n", pos)) != std::string::npos) {
while ((pos = output.find('\n', pos)) != std::string::npos) {
output.erase(pos);
}
}
......
......@@ -50,15 +50,15 @@
# pragma set woff 1375 /* base class destructor not virtual */
#endif
#include <ctype.h>
#include <errno.h>
#include <cctype>
#include <cerrno>
#ifdef __QNX__
# include <malloc.h> /* for malloc/free on QNX */
#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if defined(_WIN32) && !defined(_MSC_VER) && defined(__GNUC__)
# include <strings.h> /* for strcasecmp */
......@@ -70,7 +70,7 @@
// support for realpath call
#ifndef _WIN32
# include <limits.h>
# include <climits>
# include <pwd.h>
# include <sys/ioctl.h>
# include <sys/time.h>
......@@ -81,7 +81,7 @@
# include <sys/param.h>
# include <termios.h>
# endif
# include <signal.h> /* sigprocmask */
# include <csignal> /* sigprocmask */
#endif
#ifdef __linux
......@@ -2118,7 +2118,7 @@ std::string SystemTools::ConvertToUnixOutputPath(const std::string& path)
ret.erase(pos, 1);
}
// escape spaces and () in the path
if (ret.find_first_of(" ") != std::string::npos) {
if (ret.find_first_of(' ') != std::string::npos) {
std::string result;
char lastch = 1;
for (const char* ch = ret.c_str(); *ch != '\0'; ++ch) {
......@@ -2516,8 +2516,8 @@ bool SystemTools::CopyADirectory(const std::string& source,
return false;
}
for (fileNum = 0; fileNum < dir.GetNumberOfFiles(); ++fileNum) {
if (strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)), ".") &&
strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)), "..")) {
if (strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)), ".") != 0 &&
strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)), "..") != 0) {
std::string fullPath = source;
fullPath += "/";
fullPath += dir.GetFile(static_cast<unsigned long>(fileNum));
......@@ -2679,8 +2679,8 @@ bool SystemTools::RemoveADirectory(const std::string& source)
dir.Load(source);
size_t fileNum;
for (fileNum = 0; fileNum < dir.GetNumberOfFiles(); ++fileNum) {
if (strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)), ".") &&
strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)), "..")) {
if (strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)), ".") != 0 &&
strcmp(dir.GetFile(static_cast<unsigned long>(fileNum)), "..") != 0) {
std::string fullPath = source;
fullPath += "/";
fullPath += dir.GetFile(static_cast<unsigned long>(fileNum));
......@@ -3158,7 +3158,7 @@ bool SystemTools::SplitProgramPath(const std::string& in_name,
SystemTools::ConvertToUnixSlashes(dir);
if (!SystemTools::FileIsDirectory(dir)) {
std::string::size_type slashPos = dir.rfind("/");
std::string::size_type slashPos = dir.rfind('/');
if (slashPos != std::string::npos) {
file = dir.substr(slashPos + 1);
dir.resize(slashPos);
......@@ -3716,7 +3716,7 @@ std::string SystemTools::GetFilenamePath(const std::string& filename)
std::string fn = filename;
SystemTools::ConvertToUnixSlashes(fn);
std::string::size_type slash_pos = fn.rfind("/");
std::string::size_type slash_pos = fn.rfind('/');
if (slash_pos == 0) {
return "/";
}
......
......@@ -12,8 +12,8 @@
#include <iostream>
#include <vector>
#include <stddef.h> /* size_t */
#include <string.h> /* strcmp */
#include <cstddef> /* size_t */
#include <cstring> /* strcmp */
static void* random_ptr = reinterpret_cast<void*>(0x123);
......
......@@ -12,8 +12,8 @@
#include <iostream>
#include <vector>
#include <assert.h> /* assert */
#include <string.h> /* strcmp */
#include <cassert> /* assert */
#include <cstring> /* strcmp */
int testCommandLineArguments1(int argc, char* argv[])
{
......@@ -51,9 +51,7 @@ int testCommandLineArguments1(int argc, char* argv[])
std::cout << "Value of N: " << n << std::endl;
std::cout << "Value of M: " << m << std::endl;
std::cout << "Value of P: " << p << std::endl;
if (m) {
delete[] m;
}
delete[] m;
char** newArgv = nullptr;
int newArgc = 0;
......
......@@ -10,10 +10,10 @@
#include KWSYS_HEADER(Encoding.h)
#include <algorithm>
#include <clocale>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <locale.h>
#include <stdlib.h>
#include <string.h>
// Work-around CMake dependency scanning limitation. This must
// duplicate the above list of headers.
......@@ -59,7 +59,7 @@ static int testHelloWorldEncoding()
std::string str2 = kwsys::Encoding::ToNarrow(wstr);
wchar_t* c_wstr = kwsysEncoding_DupToWide(str.c_str());
char* c_str2 = kwsysEncoding_DupToNarrow(c_wstr);
if (!wstr.empty() && (str != str2 || strcmp(c_str2, str.c_str()))) {
if (!wstr.empty() && (str != str2 || strcmp(c_str2, str.c_str()) != 0)) {
std::cout << "converted string was different: " << str2 << std::endl;
std::cout << "converted string was different: " << c_str2 << std::endl;
ret++;
......
......@@ -7,7 +7,7 @@
#endif
#include KWSYS_HEADER(FStream.hxx)
#include <string.h>
#include <cstring>
#ifdef __BORLANDC__
# include <mem.h> /* memcmp */
#endif
......
......@@ -20,10 +20,10 @@
// left on disk.
#include <testSystemTools.h>
#include <cstdlib> /* free */
#include <cstring> /* strcmp */
#include <iostream>
#include <sstream>
#include <stdlib.h> /* free */
#include <string.h> /* strcmp */
#if defined(_WIN32) && !defined(__CYGWIN__)
# include <io.h> /* _umask (MSVC) / umask (Borland) */
# ifdef _MSC_VER
......@@ -507,7 +507,7 @@ static bool CheckStringOperations()
char* cres =
kwsys::SystemTools::AppendStrings("Mary Had A", " Little Lamb.");
if (strcmp(cres, "Mary Had A Little Lamb.")) {
if (strcmp(cres, "Mary Had A Little Lamb.") != 0) {
std::cerr << "Problem with AppendStrings "
<< "\"Mary Had A\" \" Little Lamb.\"" << std::endl;
res = false;
......@@ -515,7 +515,7 @@ static bool CheckStringOperations()
delete[] cres;
cres = kwsys::SystemTools::AppendStrings("Mary Had", " A ", "Little Lamb.");
if (strcmp(cres, "Mary Had A Little Lamb.")) {
if (strcmp(cres, "Mary Had A Little Lamb.") != 0) {
std::cerr << "Problem with AppendStrings "
<< "\"Mary Had\" \" A \" \"Little Lamb.\"" << std::endl;
res = false;
......@@ -529,7 +529,7 @@ static bool CheckStringOperations()
}
cres = kwsys::SystemTools::RemoveChars("Mary Had A Little Lamb.", "aeiou");
if (strcmp(cres, "Mry Hd A Lttl Lmb.")) {
if (strcmp(cres, "Mry Hd A Lttl Lmb.") != 0) {
std::cerr << "Problem with RemoveChars "
<< "\"Mary Had A Little Lamb.\"" << std::endl;
res = false;
......@@ -537,7 +537,7 @@ static bool CheckStringOperations()
delete[] cres;
cres = kwsys::SystemTools::RemoveCharsButUpperHex("Mary Had A Little Lamb.");
if (strcmp(cres, "A")) {
if (strcmp(cres, "A") != 0) {
std::cerr << "Problem with RemoveCharsButUpperHex "
<< "\"Mary Had A Little Lamb.\"" << std::endl;
res = false;
......@@ -546,7 +546,7 @@ static bool CheckStringOperations()
char* cres2 = strdup("Mary Had A Little Lamb.");
kwsys::SystemTools::ReplaceChars(cres2, "aeiou", 'X');
if (strcmp(cres2, "MXry HXd A LXttlX LXmb.")) {
if (strcmp(cres2, "MXry HXd A LXttlX LXmb.") != 0) {
std::cerr << "Problem with ReplaceChars "
<< "\"Mary Had A Little Lamb.\"" << std::endl;
res = false;
......@@ -568,7 +568,7 @@ static bool CheckStringOperations()
}
cres = kwsys::SystemTools::DuplicateString("Mary Had A Little Lamb.");
if (strcmp(cres, "Mary Had A Little Lamb.")) {
if (strcmp(cres, "Mary Had A Little Lamb.") != 0) {
std::cerr << "Problem with DuplicateString "
<< "\"Mary Had A Little Lamb.\"" << std::endl;
res = false;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment