diff options
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/cacheiterators.h | 4 | ||||
-rw-r--r-- | apt-pkg/contrib/configuration.h | 2 | ||||
-rw-r--r-- | apt-pkg/contrib/fileutl.cc | 2 | ||||
-rw-r--r-- | apt-pkg/contrib/hashes.h | 14 | ||||
-rw-r--r-- | apt-pkg/contrib/hashsum_template.h | 8 | ||||
-rw-r--r-- | apt-pkg/contrib/mmap.cc | 3 | ||||
-rw-r--r-- | apt-pkg/contrib/mmap.h | 7 | ||||
-rw-r--r-- | apt-pkg/deb/deblistparser.cc | 6 | ||||
-rw-r--r-- | apt-pkg/pkgcachegen.cc | 8 |
9 files changed, 28 insertions, 26 deletions
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/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/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/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/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc index 50c7961e7..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)) @@ -1056,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; |