summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2017-12-13 23:54:38 +0100
committerDavid Kalnischkies <david@kalnischkies.de>2017-12-13 23:54:38 +0100
commit99813a2eaa7c0cce1d7d8c811827733ed66458de (patch)
tree61fe422eeca8c5bd5cb2de6060f11e71343d4602 /apt-pkg
parentd30b30ad1e1ce434df84e15e2573c43ac152f9e3 (diff)
parent0b5e329a8ba2461ccb7017d3adfc972f9dccd830 (diff)
Merge branch 'feature/happy-gcc'
Fixing various real and imagined bugs reported by gcc warnings
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/acquire-item.cc4
-rw-r--r--apt-pkg/acquire.cc13
-rw-r--r--apt-pkg/cacheiterators.h4
-rw-r--r--apt-pkg/cdrom.cc2
-rw-r--r--apt-pkg/contrib/cdromutl.cc33
-rw-r--r--apt-pkg/contrib/configuration.h2
-rw-r--r--apt-pkg/contrib/fileutl.cc2
-rw-r--r--apt-pkg/contrib/hashes.h14
-rw-r--r--apt-pkg/contrib/hashsum_template.h8
-rw-r--r--apt-pkg/contrib/macros.h1
-rw-r--r--apt-pkg/contrib/mmap.cc3
-rw-r--r--apt-pkg/contrib/mmap.h7
-rw-r--r--apt-pkg/contrib/netrc.cc14
-rw-r--r--apt-pkg/contrib/progress.cc5
-rw-r--r--apt-pkg/deb/deblistparser.cc6
-rw-r--r--apt-pkg/deb/debmetaindex.cc6
-rw-r--r--apt-pkg/deb/debsrcrecords.cc6
-rw-r--r--apt-pkg/deb/dpkgpm.cc2
-rw-r--r--apt-pkg/indexcopy.cc15
-rw-r--r--apt-pkg/install-progress.cc8
-rw-r--r--apt-pkg/pkgcachegen.cc12
21 files changed, 94 insertions, 73 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index b13bd203b..b3eb75d16 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -971,7 +971,9 @@ bool pkgAcquire::Item::RenameOnError(pkgAcquire::Item::RenameOnErrorState const
void pkgAcquire::Item::SetActiveSubprocess(const std::string &subprocess)/*{{{*/
{
ActiveSubprocess = subprocess;
- APT_IGNORE_DEPRECATED(Mode = ActiveSubprocess.c_str();)
+ APT_IGNORE_DEPRECATED_PUSH
+ Mode = ActiveSubprocess.c_str();
+ APT_IGNORE_DEPRECATED_POP
}
/*}}}*/
// Acquire::Item::ReportMirrorFailure /*{{{*/
diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc
index 408cf6df5..f6e323d30 100644
--- a/apt-pkg/acquire.cc
+++ b/apt-pkg/acquire.cc
@@ -31,6 +31,7 @@
#include <sstream>
#include <string>
#include <vector>
+#include <cmath>
#include <dirent.h>
#include <errno.h>
@@ -437,7 +438,7 @@ string pkgAcquire::QueueName(string Uri,MethodConfig const *&Config)
clog << "Found " << Instances << " instances of " << U.Access << endl;
}
- if (Instances >= (unsigned int)_config->FindI("Acquire::QueueHost::Limit",10))
+ if (Instances >= static_cast<decltype(Instances)>(_config->FindI("Acquire::QueueHost::Limit",10)))
return U.Access;
return FullQueueName;
@@ -1074,7 +1075,7 @@ bool pkgAcquire::Queue::Cycle()
// Look for a queable item
QItem *I = Items;
int ActivePriority = 0;
- while (PipeDepth < (signed)MaxPipeDepth)
+ while (PipeDepth < static_cast<decltype(PipeDepth)>(MaxPipeDepth))
{
for (; I != 0; I = I->Next) {
if (I->Owner->Status == pkgAcquire::Item::StatFetching)
@@ -1285,7 +1286,7 @@ bool pkgAcquireStatus::Pulse(pkgAcquire *Owner)
else
CurrentCPS = ((CurrentBytes - ResumeSize) - LastBytes)/Delta;
LastBytes = CurrentBytes - ResumeSize;
- ElapsedTime = (unsigned long long)Delta;
+ ElapsedTime = std::llround(Delta);
Time = NewTime;
}
@@ -1295,8 +1296,8 @@ bool pkgAcquireStatus::Pulse(pkgAcquire *Owner)
Percent = 0;
else
// use both files and bytes because bytes can be unreliable
- Percent = (0.8 * (CurrentBytes/float(TotalBytes)*100.0) +
- 0.2 * (CurrentItems/float(TotalItems)*100.0));
+ Percent = (0.8 * (CurrentBytes/double(TotalBytes)*100.0) +
+ 0.2 * (CurrentItems/double(TotalItems)*100.0));
// debug
if (_config->FindB("Debug::acquire::progress", false) == true)
@@ -1380,7 +1381,7 @@ void pkgAcquireStatus::Stop()
else
CurrentCPS = FetchedBytes/Delta;
LastBytes = CurrentBytes;
- ElapsedTime = (unsigned long long)Delta;
+ ElapsedTime = std::llround(Delta);
}
/*}}}*/
// AcquireStatus::Fetched - Called when a byte set has been fetched /*{{{*/
diff --git a/apt-pkg/cacheiterators.h b/apt-pkg/cacheiterators.h
index 0cb684382..52915aae4 100644
--- a/apt-pkg/cacheiterators.h
+++ b/apt-pkg/cacheiterators.h
@@ -86,7 +86,7 @@ template<typename Str, typename Itr> class pkgCache::Iterator :
void ReMap(void const * const oldMap, void const * const newMap) {
if (Owner == 0 || S == 0)
return;
- S += (Str const * const)(newMap) - (Str const * const)(oldMap);
+ S += static_cast<Str const *>(newMap) - static_cast<Str const *>(oldMap);
}
// Constructors - look out for the variable assigning
@@ -341,7 +341,7 @@ class pkgCache::DepIterator : public Iterator<Dependency, DepIterator> {
Iterator<Dependency, DepIterator>::ReMap(oldMap, newMap);
if (Owner == 0 || S == 0 || S2 == 0)
return;
- S2 += (DependencyData const * const)(newMap) - (DependencyData const * const)(oldMap);
+ S2 += static_cast<DependencyData const *>(newMap) - static_cast<DependencyData const *>(oldMap);
}
//Nice printable representation
diff --git a/apt-pkg/cdrom.cc b/apt-pkg/cdrom.cc
index 4f57153f9..e4b0bef06 100644
--- a/apt-pkg/cdrom.cc
+++ b/apt-pkg/cdrom.cc
@@ -315,7 +315,7 @@ bool pkgCdrom::DropRepeats(vector<string> &List,const char *Name)
for (std::vector<APT::Configuration::Compressor>::const_iterator c = compressor.begin();
c != compressor.end(); ++c)
{
- std::string filename = std::string(List[I]).append(Name).append(c->Extension);
+ std::string const filename = List[I] + Name + c->Extension;
if (stat(filename.c_str(), &Buf) != 0)
continue;
Inodes[I] = Buf.st_ino;
diff --git a/apt-pkg/contrib/cdromutl.cc b/apt-pkg/contrib/cdromutl.cc
index 93bfb9f42..7ae54060a 100644
--- a/apt-pkg/contrib/cdromutl.cc
+++ b/apt-pkg/contrib/cdromutl.cc
@@ -105,13 +105,14 @@ bool UnmountCdrom(string Path)
}
else
{
- const char *Args[10];
- Args[0] = "umount";
- Args[1] = Path.c_str();
- Args[2] = 0;
- execvp(Args[0],(char **)Args);
+ const char * const Args[] = {
+ "umount",
+ Path.c_str(),
+ nullptr
+ };
+ execvp(Args[0], const_cast<char **>(Args));
_exit(100);
- }
+ }
}
// if it can not be umounted, give it a bit more time
@@ -222,15 +223,13 @@ bool IdentCdrom(string CD,string &Res,unsigned int Version)
std::string S;
if (Version <= 1)
- {
- strprintf(S, "%lu", (unsigned long)Dir->d_ino);
- }
+ S = std::to_string(Dir->d_ino);
else
{
struct stat Buf;
if (fstatat(dirfd, Dir->d_name, &Buf, 0) != 0)
continue;
- strprintf(S, "%lu", (unsigned long)Buf.st_mtime);
+ S = std::to_string(Buf.st_mtime);
}
Hash.Add(S.c_str());
@@ -246,21 +245,17 @@ bool IdentCdrom(string CD,string &Res,unsigned int Version)
return _error->Errno("statfs",_("Failed to stat the cdrom"));
// We use a kilobyte block size to avoid overflow
- if (writable_media)
- {
- strprintf(S, "%lu", (unsigned long)(Buf.f_blocks*(Buf.f_bsize/1024)));
- } else {
- strprintf(S, "%lu %lu", (unsigned long)(Buf.f_blocks*(Buf.f_bsize/1024)),
- (unsigned long)(Buf.f_bfree*(Buf.f_bsize/1024)));
- }
- Hash.Add(S.c_str());
+ S = std::to_string(Buf.f_blocks * (Buf.f_bsize / 1024));
+ if (writable_media == false)
+ S.append(" ").append(std::to_string(Buf.f_bfree * (Buf.f_bsize / 1024)));
+ Hash.Add(S.c_str(), S.length());
strprintf(S, "-%u", Version);
}
else
strprintf(S, "-%u.debug", Version);
closedir(D);
- Res = Hash.Result().Value() + S;
+ Res = Hash.Result().Value().append(std::move(S));
return true;
}
/*}}}*/
diff --git a/apt-pkg/contrib/configuration.h b/apt-pkg/contrib/configuration.h
index 8d0835cf5..73f7acb81 100644
--- a/apt-pkg/contrib/configuration.h
+++ b/apt-pkg/contrib/configuration.h
@@ -66,7 +66,7 @@ class Configuration
Item *Lookup(const char *Name,const bool &Create);
inline const Item *Lookup(const char *Name) const
{
- return ((Configuration *)this)->Lookup(Name,false);
+ return const_cast<Configuration *>(this)->Lookup(Name,false);
}
public:
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index 6cc7414b0..d3764d003 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -1107,7 +1107,7 @@ public:
}
unsigned long long const OutputSize = std::min(Size, buffer.size());
- char const * const newline = static_cast<char const * const>(memchr(buffer.get(), '\n', OutputSize));
+ char const * const newline = static_cast<char const *>(memchr(buffer.get(), '\n', OutputSize));
// Read until end of line or up to Size bytes from the buffer.
unsigned long long actualread = buffer.read(To,
(newline != nullptr)
diff --git a/apt-pkg/contrib/hashes.h b/apt-pkg/contrib/hashes.h
index 11521008a..dc91c1dd3 100644
--- a/apt-pkg/contrib/hashes.h
+++ b/apt-pkg/contrib/hashes.h
@@ -197,7 +197,7 @@ class Hashes
bool Add(const unsigned char * const Data, unsigned long long const Size) APT_NONNULL(2);
APT_DEPRECATED_MSG("Construct accordingly instead of choosing hashes while adding") bool Add(const unsigned char * const Data, unsigned long long const Size, unsigned int const Hashes) APT_NONNULL(2);
inline bool Add(const char * const Data) APT_NONNULL(2)
- {return Add((unsigned char const * const)Data,strlen(Data));};
+ {return Add(reinterpret_cast<unsigned char const *>(Data),strlen(Data));};
inline bool Add(const unsigned char * const Beg,const unsigned char * const End) APT_NONNULL(2,3)
{return Add(Beg,End-Beg);};
@@ -227,12 +227,12 @@ APT_IGNORE_DEPRECATED_POP
private:
APT_HIDDEN APT_PURE inline unsigned int boolsToFlag(bool const addMD5, bool const addSHA1, bool const addSHA256, bool const addSHA512)
{
- unsigned int Hashes = ~0;
- if (addMD5 == false) Hashes &= ~MD5SUM;
- if (addSHA1 == false) Hashes &= ~SHA1SUM;
- if (addSHA256 == false) Hashes &= ~SHA256SUM;
- if (addSHA512 == false) Hashes &= ~SHA512SUM;
- return Hashes;
+ unsigned int hashes = ~0;
+ if (addMD5 == false) hashes &= ~MD5SUM;
+ if (addSHA1 == false) hashes &= ~SHA1SUM;
+ if (addSHA256 == false) hashes &= ~SHA256SUM;
+ if (addSHA512 == false) hashes &= ~SHA512SUM;
+ return hashes;
}
public:
diff --git a/apt-pkg/contrib/hashsum_template.h b/apt-pkg/contrib/hashsum_template.h
index 2594f6aeb..33e096b79 100644
--- a/apt-pkg/contrib/hashsum_template.h
+++ b/apt-pkg/contrib/hashsum_template.h
@@ -123,17 +123,17 @@ class SummationImplementation
public:
virtual bool Add(const unsigned char *inbuf, unsigned long long inlen) APT_NONNULL(2) = 0;
inline bool Add(const char *inbuf, unsigned long long const inlen) APT_NONNULL(2)
- { return Add((const unsigned char *)inbuf, inlen); }
+ { return Add(reinterpret_cast<const unsigned char *>(inbuf), inlen); }
inline bool Add(const unsigned char *Data) APT_NONNULL(2)
- { return Add(Data, strlen((const char *)Data)); }
+ { return Add(Data, strlen(reinterpret_cast<const char *>(Data))); }
inline bool Add(const char *Data) APT_NONNULL(2)
- { return Add((const unsigned char *)Data, strlen(Data)); }
+ { return Add(reinterpret_cast<const unsigned char *>(Data), strlen(Data)); }
inline bool Add(const unsigned char *Beg, const unsigned char *End) APT_NONNULL(2,3)
{ return Add(Beg, End - Beg); }
inline bool Add(const char *Beg, const char *End) APT_NONNULL(2,3)
- { return Add((const unsigned char *)Beg, End - Beg); }
+ { return Add(reinterpret_cast<const unsigned char *>(Beg), End - Beg); }
bool AddFD(int Fd, unsigned long long Size = 0);
bool AddFD(FileFd &Fd, unsigned long long Size = 0);
diff --git a/apt-pkg/contrib/macros.h b/apt-pkg/contrib/macros.h
index abf99f7a2..57d3f6c22 100644
--- a/apt-pkg/contrib/macros.h
+++ b/apt-pkg/contrib/macros.h
@@ -143,6 +143,7 @@
_Pragma("GCC diagnostic ignored \"-Wdeprecated-declarations\"")
#define APT_IGNORE_DEPRECATED_POP \
_Pragma("GCC diagnostic pop")
+ /* gcc has various problems with this shortcut, so prefer the long form */
#define APT_IGNORE_DEPRECATED(XXX) \
APT_IGNORE_DEPRECATED_PUSH \
XXX \
diff --git a/apt-pkg/contrib/mmap.cc b/apt-pkg/contrib/mmap.cc
index 100796cdf..bfded21e2 100644
--- a/apt-pkg/contrib/mmap.cc
+++ b/apt-pkg/contrib/mmap.cc
@@ -28,7 +28,6 @@
#include <string>
#include <errno.h>
#include <stdlib.h>
-#include <sys/mman.h>
#include <unistd.h>
#include <apti18n.h>
@@ -415,7 +414,7 @@ unsigned long DynamicMMap::Allocate(unsigned long ItemSize)
unsigned long DynamicMMap::WriteString(const char *String,
unsigned long Len)
{
- if (Len == (unsigned long)-1)
+ if (Len == std::numeric_limits<unsigned long>::max())
Len = strlen(String);
_error->PushToStack();
diff --git a/apt-pkg/contrib/mmap.h b/apt-pkg/contrib/mmap.h
index df02b1b85..c194de534 100644
--- a/apt-pkg/contrib/mmap.h
+++ b/apt-pkg/contrib/mmap.h
@@ -26,6 +26,9 @@
#define PKGLIB_MMAP_H
#include <string>
+#include <limits>
+
+#include <sys/mman.h>
#ifndef APT_8_CLEANER_HEADERS
#include <apt-pkg/fileutl.h>
@@ -65,7 +68,7 @@ class MMap
inline void *Data() {return Base;};
inline unsigned long long Size() {return iSize;};
inline void AddSize(unsigned long long const size) {iSize += size;};
- inline bool validData() const { return Base != (void *)-1 && Base != 0; };
+ inline bool validData() const { return Base != MAP_FAILED && Base != 0; };
// File manipulators
bool Sync();
@@ -104,7 +107,7 @@ class DynamicMMap : public MMap
// Allocation
unsigned long RawAllocate(unsigned long long Size,unsigned long Aln = 0);
unsigned long Allocate(unsigned long ItemSize);
- unsigned long WriteString(const char *String,unsigned long Len = (unsigned long)-1);
+ unsigned long WriteString(const char *String,unsigned long Len = std::numeric_limits<unsigned long>::max());
inline unsigned long WriteString(const std::string &S) {return WriteString(S.c_str(),S.length());};
void UsePools(Pool &P,unsigned int Count) {Pools = &P; PoolCount = Count;};
diff --git a/apt-pkg/contrib/netrc.cc b/apt-pkg/contrib/netrc.cc
index 27511d413..ed8b2aa88 100644
--- a/apt-pkg/contrib/netrc.cc
+++ b/apt-pkg/contrib/netrc.cc
@@ -127,8 +127,18 @@ bool MaybeAddAuth(FileFd &NetRCFile, URI &Uri)
return true;
}
else if (Debug)
- std::clog << "MaybeAddAuth: Found no matching host (syntax error: " << active_token << ") for "
- << (std::string)Uri << " from " << NetRCFile.Name() << std::endl;
+ {
+ std::clog << "MaybeAddAuth: Found no matching host (syntax error: token:";
+ switch (active_token)
+ {
+ case NO: std::clog << "NO"; break;
+ case MACHINE: std::clog << "MACHINE"; break;
+ case GOOD_MACHINE: std::clog << "GOOD_MACHINE"; break;
+ case LOGIN: std::clog << "LOGIN"; break;
+ case PASSWORD: std::clog << "PASSWORD"; break;
+ }
+ std::clog << ") for " << (std::string)Uri << " from " << NetRCFile.Name() << std::endl;
+ }
return false;
}
diff --git a/apt-pkg/contrib/progress.cc b/apt-pkg/contrib/progress.cc
index 7c5b15e6b..5499f0946 100644
--- a/apt-pkg/contrib/progress.cc
+++ b/apt-pkg/contrib/progress.cc
@@ -14,6 +14,7 @@
#include <apt-pkg/error.h>
#include <apt-pkg/progress.h>
+#include <cmath>
#include <cstring>
#include <iostream>
#include <string>
@@ -44,7 +45,7 @@ void OpProgress::Progress(unsigned long long Cur)
if (Total == 0 || Size == 0 || SubTotal == 0)
Percent = 0;
else
- Percent = (Current + Cur/((float)SubTotal)*Size)*100.0/Total;
+ Percent = (Current + Cur/((double)SubTotal)*Size)*100.0/Total;
Update();
}
/*}}}*/
@@ -106,7 +107,7 @@ bool OpProgress::CheckChange(float Interval)
return true;
}
- if ((int)LastPercent == (int)Percent)
+ if (std::lround(LastPercent) == std::lround(Percent))
return false;
LastPercent = Percent;
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index 378988a1c..241313ff2 100644
--- a/apt-pkg/deb/deblistparser.cc
+++ b/apt-pkg/deb/deblistparser.cc
@@ -170,15 +170,15 @@ bool debListParser::NewVersion(pkgCache::VerIterator &Ver)
Ver->SourceVerStr = Ver->VerStr;
if (Section.Find(pkgTagSection::Key::Source,Start,Stop) == true)
{
- const char * const Space = (const char * const) memchr(Start, ' ', Stop - Start);
+ const char * const Space = static_cast<const char *>(memchr(Start, ' ', Stop - Start));
pkgCache::VerIterator V;
if (Space != NULL)
{
- const char * const Open = (const char * const) memchr(Space, '(', Stop - Space);
+ const char * const Open = static_cast<const char *>(memchr(Space, '(', Stop - Space));
if (likely(Open != NULL))
{
- const char * const Close = (const char * const) memchr(Open, ')', Stop - Open);
+ const char * const Close = static_cast<const char *>(memchr(Open, ')', Stop - Open));
if (likely(Close != NULL))
{
APT::StringView const version(Open + 1, (Close - Open) - 1);
diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc
index c2579e12d..ad27e2dcd 100644
--- a/apt-pkg/deb/debmetaindex.cc
+++ b/apt-pkg/deb/debmetaindex.cc
@@ -459,8 +459,10 @@ bool debReleaseIndex::Load(std::string const &Filename, std::string * const Erro
Sum->MetaKeyFilename = Name;
Sum->Size = Size;
Sum->Hashes.FileSize(Size);
- APT_IGNORE_DEPRECATED(Sum->Hash = hs;)
- Entries[Name] = Sum;
+ APT_IGNORE_DEPRECATED_PUSH
+ Sum->Hash = hs;
+ APT_IGNORE_DEPRECATED_POP
+ Entries[Name] = Sum;
}
Entries[Name]->Hashes.push_back(hs);
FoundHashSum = true;
diff --git a/apt-pkg/deb/debsrcrecords.cc b/apt-pkg/deb/debsrcrecords.cc
index 1cabfe281..7fd206ed6 100644
--- a/apt-pkg/deb/debsrcrecords.cc
+++ b/apt-pkg/deb/debsrcrecords.cc
@@ -241,7 +241,11 @@ bool debSrcRecordParser::Files2(std::vector<pkgSrcRecords::File2> &List)
if (file != List.end())
{
if (checksumField == "Files")
- APT_IGNORE_DEPRECATED(file->MD5Hash = hash;)
+ {
+ APT_IGNORE_DEPRECATED_PUSH
+ file->MD5Hash = hash;
+ APT_IGNORE_DEPRECATED_POP
+ }
// an error here indicates that we have two different hashes for the same file
if (file->Hashes.push_back(hashString) == false)
return _error->Error("Error parsing checksum in %s of source package %s", checksumField.c_str(), Package().c_str());
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index 4724f6e1c..c6d0a50f1 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -1758,7 +1758,9 @@ bool pkgDPkgPM::Go(APT::Progress::PackageManager *progress)
case Item::Purge:
ADDARGC("--force-depends");
if (std::any_of(I, J, ItemIsEssential))
+ {
ADDARGC("--force-remove-essential");
+ }
ADDARGC("--remove");
break;
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();
diff --git a/apt-pkg/install-progress.cc b/apt-pkg/install-progress.cc
index 2c2205d2b..09bf465bf 100644
--- a/apt-pkg/install-progress.cc
+++ b/apt-pkg/install-progress.cc
@@ -55,8 +55,8 @@ bool PackageManager::StatusChanged(std::string /*PackageName*/,
std::string /*HumanReadableAction*/)
{
int reporting_steps = _config->FindI("DpkgPM::Reporting-Steps", 1);
- percentage = StepsDone/(float)TotalSteps * 100.0;
- strprintf(progress_str, _("Progress: [%3i%%]"), (int)percentage);
+ percentage = StepsDone/(double)TotalSteps * 100.0;
+ strprintf(progress_str, _("Progress: [%3li%%]"), std::lround(percentage));
if(percentage < (last_reported_progress + reporting_steps))
return false;
@@ -382,8 +382,8 @@ bool PackageManagerFancy::DrawStatusLine()
if (_config->FindB("Dpkg::Progress-Fancy::Progress-Bar", true))
{
int padding = 4;
- float progressbar_size = size.columns - padding - progress_str.size();
- float current_percent = percentage / 100.0;
+ auto const progressbar_size = size.columns - padding - progress_str.size();
+ auto const current_percent = percentage / 100.0;
std::cout << " "
<< GetTextProgressStr(current_percent, progressbar_size)
<< " ";
diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc
index bde0ea122..1748e8bc1 100644
--- a/apt-pkg/pkgcachegen.cc
+++ b/apt-pkg/pkgcachegen.cc
@@ -159,8 +159,8 @@ void pkgCacheGenerator::ReMap(void const * const oldMap, void const * const newM
Cache.ReMap(false);
- CurrentFile += (pkgCache::PackageFile const * const) newMap - (pkgCache::PackageFile const * const) oldMap;
- CurrentRlsFile += (pkgCache::ReleaseFile const * const) newMap - (pkgCache::ReleaseFile const * const) oldMap;
+ CurrentFile += static_cast<pkgCache::PackageFile const *>(newMap) - static_cast<pkgCache::PackageFile const *>(oldMap);
+ CurrentRlsFile += static_cast<pkgCache::ReleaseFile const *>(newMap) - static_cast<pkgCache::ReleaseFile const *>(oldMap);
for (std::vector<pkgCache::GrpIterator*>::const_iterator i = Dynamic<pkgCache::GrpIterator>::toReMap.begin();
i != Dynamic<pkgCache::GrpIterator>::toReMap.end(); ++i)
@@ -439,7 +439,7 @@ bool pkgCacheGenerator::MergeListVersion(ListParser &List, pkgCache::PkgIterator
Pkg.Name(), "NewVersion", 1);
if (oldMap != Map.Data())
- LastVer += (map_pointer_t const * const) Map.Data() - (map_pointer_t const * const) oldMap;
+ LastVer += static_cast<map_pointer_t const *>(Map.Data()) - static_cast<map_pointer_t const *>(oldMap);
*LastVer = verindex;
if (unlikely(List.NewVersion(Ver) == false))
@@ -599,7 +599,9 @@ bool pkgCacheGenerator::NewPackage(pkgCache::PkgIterator &Pkg, StringView Name,
Pkg = pkgCache::PkgIterator(Cache,Cache.PkgP + Package);
// Set the name, arch and the ID
- APT_IGNORE_DEPRECATED(Pkg->Name = Grp->Name;)
+ APT_IGNORE_DEPRECATED_PUSH
+ Pkg->Name = Grp->Name;
+ APT_IGNORE_DEPRECATED_POP
Pkg->Group = Grp.Index();
// all is mapped to the native architecture
map_stringitem_t const idxArch = (Arch == "all") ? Cache.HeaderP->Architecture : StoreString(MIXED, Arch);
@@ -1054,7 +1056,7 @@ bool pkgCacheGenerator::NewDepends(pkgCache::PkgIterator &Pkg,
for (pkgCache::DepIterator D = Ver.DependsList(); D.end() == false; ++D)
OldDepLast = &D->NextDepends;
} else if (oldMap != Map.Data())
- OldDepLast += (map_pointer_t const * const) Map.Data() - (map_pointer_t const * const) oldMap;
+ OldDepLast += static_cast<map_pointer_t const *>(Map.Data()) - static_cast<map_pointer_t const *>(oldMap);
Dep->NextDepends = *OldDepLast;
*OldDepLast = Dependency;