diff options
author | David Kalnischkies <david@kalnischkies.de> | 2017-12-13 13:26:38 +0100 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2017-12-13 23:53:34 +0100 |
commit | 957381a0d26ec11a172ebfc64f892d1b31f0c193 (patch) | |
tree | 503ae7e87a16a01a4d642f668ec284a258369de0 /apt-pkg/contrib | |
parent | 5d5ca1aac76448cdfd16972090d246c44671dce6 (diff) |
convert various c-style casts to C++-style
gcc was warning about ignored type qualifiers for all of them due to the
last 'const', so dropping that and converting to static_cast in the
process removes the here harmless warning to avoid hidden real issues in
them later on.
Reported-By: gcc
Gbp-Dch: Ignore
Diffstat (limited to 'apt-pkg/contrib')
-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 |
6 files changed, 19 insertions, 17 deletions
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;}; |