summaryrefslogtreecommitdiff
path: root/apt-pkg/indexcopy.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2017-12-13 21:39:16 +0100
committerDavid Kalnischkies <david@kalnischkies.de>2017-12-13 23:53:41 +0100
commit1adcf56bec7d2127d83aa423916639740fe8e586 (patch)
tree39802989990796e903d8e670b07408380b117c21 /apt-pkg/indexcopy.cc
parent957381a0d26ec11a172ebfc64f892d1b31f0c193 (diff)
avoid some useless casts reported by -Wuseless-cast
The casts are useless, but the reports show some where we can actually improve the code by replacing them with better alternatives like converting whatever int type into a string instead of casting to a specific one which might in the future be too small. Reported-By: gcc -Wuseless-cast
Diffstat (limited to 'apt-pkg/indexcopy.cc')
-rw-r--r--apt-pkg/indexcopy.cc15
1 files changed, 7 insertions, 8 deletions
diff --git a/apt-pkg/indexcopy.cc b/apt-pkg/indexcopy.cc
index d4cab1a04..cb23a860f 100644
--- a/apt-pkg/indexcopy.cc
+++ b/apt-pkg/indexcopy.cc
@@ -58,15 +58,14 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector<string> &List,
// Prepare the progress indicator
off_t TotalSize = 0;
std::vector<APT::Configuration::Compressor> const compressor = APT::Configuration::getCompressors();
- for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
+ for (auto const &F : List)
{
struct stat Buf;
bool found = false;
- std::string file = std::string(*I).append(GetFileName());
- for (std::vector<APT::Configuration::Compressor>::const_iterator c = compressor.begin();
- c != compressor.end(); ++c)
+ auto const file = F + GetFileName();
+ for (auto const &ext: APT::Configuration::getCompressorExtensions())
{
- if (stat((file + c->Extension).c_str(), &Buf) != 0)
+ if (stat((file + ext).c_str(), &Buf) != 0)
continue;
found = true;
break;
@@ -82,9 +81,9 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector<string> &List,
unsigned int WrongSize = 0;
unsigned int Packages = 0;
for (vector<string>::iterator I = List.begin(); I != List.end(); ++I)
- {
- string OrigPath = string(*I,CDROM.length());
-
+ {
+ std::string OrigPath(*I,CDROM.length());
+
// Open the package file
FileFd Pkg(*I + GetFileName(), FileFd::ReadOnly, FileFd::Auto);
off_t const FileSize = Pkg.Size();