diff options
author | David Kalnischkies <kalnischkies@gmail.com> | 2013-03-10 12:24:13 +0100 |
---|---|---|
committer | David Kalnischkies <kalnischkies@gmail.com> | 2013-03-10 12:24:13 +0100 |
commit | 69c2ecbdc937e3c73fe67d3c9bce12a80d3ec7ec (patch) | |
tree | b3b8f0753ebe2760ab8d97b0e9404ddbeef25a1b /apt-pkg/contrib | |
parent | fd6a8d0ddc14406bb6c0996b5bbaa95d6ccc1186 (diff) |
various simple changes to fix cppcheck warnings
Diffstat (limited to 'apt-pkg/contrib')
-rw-r--r-- | apt-pkg/contrib/configuration.cc | 2 | ||||
-rw-r--r-- | apt-pkg/contrib/fileutl.cc | 10 | ||||
-rw-r--r-- | apt-pkg/contrib/netrc.cc | 8 | ||||
-rw-r--r-- | apt-pkg/contrib/strutl.cc | 8 |
4 files changed, 13 insertions, 15 deletions
diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc index 4de17e3e1..808a708a1 100644 --- a/apt-pkg/contrib/configuration.cc +++ b/apt-pkg/contrib/configuration.cc @@ -958,7 +958,7 @@ Configuration::MatchAgainstConfig::MatchAgainstConfig(char const * Config) continue; } } - if (strings.size() == 0) + if (strings.empty() == true) patterns.push_back(NULL); } /*}}}*/ diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index 90e49cbfa..f18e17005 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -387,7 +387,7 @@ std::vector<string> GetListOfFilesInDir(string const &Dir, std::vector<string> c std::vector<string> List; - if (DirectoryExists(Dir.c_str()) == false) + if (DirectoryExists(Dir) == false) { _error->Error(_("List of files can't be created as '%s' is not a directory"), Dir.c_str()); return List; @@ -413,14 +413,14 @@ std::vector<string> GetListOfFilesInDir(string const &Dir, std::vector<string> c if (Ent->d_type != DT_REG) #endif { - if (RealFileExists(File.c_str()) == false) + if (RealFileExists(File) == false) { // do not show ignoration warnings for directories if ( #ifdef _DIRENT_HAVE_D_TYPE Ent->d_type == DT_DIR || #endif - DirectoryExists(File.c_str()) == true) + DirectoryExists(File) == true) continue; if (SilentIgnore.Match(Ent->d_name) == false) _error->Notice(_("Ignoring '%s' in directory '%s' as it is not a regular file"), Ent->d_name, Dir.c_str()); @@ -501,7 +501,7 @@ std::vector<string> GetListOfFilesInDir(string const &Dir, bool SortList) std::vector<string> List; - if (DirectoryExists(Dir.c_str()) == false) + if (DirectoryExists(Dir) == false) { _error->Error(_("List of files can't be created as '%s' is not a directory"), Dir.c_str()); return List; @@ -526,7 +526,7 @@ std::vector<string> GetListOfFilesInDir(string const &Dir, bool SortList) if (Ent->d_type != DT_REG) #endif { - if (RealFileExists(File.c_str()) == false) + if (RealFileExists(File) == false) { if (Debug == true) std::clog << "Bad file: " << Ent->d_name << " → it is not a real file" << std::endl; diff --git a/apt-pkg/contrib/netrc.cc b/apt-pkg/contrib/netrc.cc index 0a902f126..de95aa4ab 100644 --- a/apt-pkg/contrib/netrc.cc +++ b/apt-pkg/contrib/netrc.cc @@ -50,14 +50,10 @@ static int parsenetrc_string (char *host, std::string &login, std::string &passw FILE *file; int retcode = 1; int specific_login = (login.empty() == false); - char *home = NULL; bool netrc_alloc = false; - int state_our_login = false; /* With specific_login, - found *our* login name */ - if (!netrcfile) { - home = getenv ("HOME"); /* portable environment reader */ + char const * home = getenv ("HOME"); /* portable environment reader */ if (!home) { struct passwd *pw; @@ -86,6 +82,8 @@ static int parsenetrc_string (char *host, std::string &login, std::string &passw int state = NOTHING; char state_login = 0; /* Found a login keyword */ char state_password = 0; /* Found a password keyword */ + int state_our_login = false; /* With specific_login, + found *our* login name */ while (!done && getline(&netrcbuffer, &netrcbuffer_size, file) != -1) { tok = strtok_r (netrcbuffer, " \t\n", &tok_buf); diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc index ca096d736..f643db451 100644 --- a/apt-pkg/contrib/strutl.cc +++ b/apt-pkg/contrib/strutl.cc @@ -1246,7 +1246,7 @@ string StripEpoch(const string &VerStr) return VerStr; return VerStr.substr(i+1); } - + /*}}}*/ // tolower_ascii - tolower() function that ignores the locale /*{{{*/ // --------------------------------------------------------------------- /* This little function is the most called method we have and tries @@ -1284,14 +1284,14 @@ bool CheckDomainList(const string &Host,const string &List) return false; } /*}}}*/ -// DeEscapeString - unescape (\0XX and \xXX) from a string /*{{{*/ +// DeEscapeString - unescape (\0XX and \xXX) from a string /*{{{*/ // --------------------------------------------------------------------- /* */ string DeEscapeString(const string &input) { char tmp[3]; - string::const_iterator it, escape_start; - string output, octal, hex; + string::const_iterator it; + string output; for (it = input.begin(); it != input.end(); ++it) { // just copy non-escape chars |