diff --git a/ebml/EbmlDate.h b/ebml/EbmlDate.h index 8153fd50..6c3b5775 100644 --- a/ebml/EbmlDate.h +++ b/ebml/EbmlDate.h @@ -22,7 +22,7 @@ class EBML_DLL_API EbmlDate : public EbmlElementDefaultSameStorage { if (classInfo.HasDefault()) { - auto def = static_cast &>(classInfo); + const auto& def = static_cast &>(classInfo); SetValue(def.DefaultValue()); } } diff --git a/ebml/EbmlElement.h b/ebml/EbmlElement.h index 9282463a..263a7b13 100644 --- a/ebml/EbmlElement.h +++ b/ebml/EbmlElement.h @@ -430,7 +430,7 @@ static inline EbmlElement & tEBML_SEM_CREATE(const EbmlSemantic & s) return s.Create(); } -using _GetSemanticContext = const class EbmlSemanticContext &(*)(); +using _GetSemanticContext = const EbmlSemanticContext &(*)(); /*! Context of the element @@ -650,7 +650,7 @@ class EBML_DLL_API EbmlElement { private: std::size_t HeadSize() const { - return EBML_ID_LENGTH((const EbmlId&)*this) + CodedSizeLength(Size, SizeLength, bSizeIsFinite); + return EBML_ID_LENGTH(static_cast(*this)) + CodedSizeLength(Size, SizeLength, bSizeIsFinite); } /// return the size of the head, on reading/writing std::uint64_t Size; ///< the size of the data to write diff --git a/src/EbmlElement.cpp b/src/EbmlElement.cpp index 5526ac81..b05ea67b 100644 --- a/src/EbmlElement.cpp +++ b/src/EbmlElement.cpp @@ -195,23 +195,22 @@ EbmlElement * EbmlElement::FindNextID(IOCallback & DataStream, const EbmlCallbac } while (_SizeLength == 0); } - const auto PossibleID = EbmlId(EbmlId::FromBuffer(PossibleId.data(), PossibleID_Length)); - auto Result = [=] { - if (PossibleID != EBML_INFO_ID(ClassInfos)) - { + auto Result = [&]() -> EbmlElement * { + auto pID = EbmlId(EbmlId::FromBuffer(PossibleId.data(), PossibleID_Length)); + if (pID != EBML_INFO_ID(ClassInfos)) { if (SizeFound == SizeUnknown) - return static_cast(nullptr); - return static_cast(new EbmlDummy(PossibleID)); + return nullptr; + return new EbmlDummy(pID); } if (SizeFound != SizeUnknown && MaxDataSize < SizeFound) - return static_cast(nullptr); + return nullptr; // check if the size is not all 1s if (SizeFound == SizeUnknown && !ClassInfos.CanHaveInfiniteSize()) - return static_cast(nullptr); + return nullptr; return &EBML_INFO_CREATE(ClassInfos); }(); - if (Result == nullptr) + if (!Result) return nullptr; if (!Result->SizeIsValid(SizeFound)) { @@ -454,7 +453,7 @@ EbmlElement *EbmlElement::CreateElementUsingContext(const EbmlId & aID, const Eb // parent elements if (EBML_CTX_MASTER(Context) != nullptr && aID == EBML_INFO_ID(*EBML_CTX_MASTER(Context))) { - auto Callbacks = *EBML_CTX_MASTER(Context); + const auto& Callbacks = *EBML_CTX_MASTER(Context); if (AsInfiniteSize && !Callbacks.CanHaveInfiniteSize()) return nullptr; LowLevel++; // already one level up (same as context) @@ -518,7 +517,7 @@ filepos_t EbmlElement::MakeRenderHead(IOCallback & output, bool bKeepPosition) std::array FinalHead; // Class D + 64 bits coded size std::size_t FinalHeadSize; - FinalHeadSize = EBML_ID_LENGTH((const EbmlId&)*this); + FinalHeadSize = EBML_ID_LENGTH(static_cast(*this)); EbmlId(*this).Fill(FinalHead.data()); const unsigned int CodedSize = CodedSizeLength(Size, SizeLength, bSizeIsFinite); diff --git a/src/EbmlFloat.cpp b/src/EbmlFloat.cpp index 3160454b..0d9ae786 100644 --- a/src/EbmlFloat.cpp +++ b/src/EbmlFloat.cpp @@ -19,7 +19,7 @@ EbmlFloat::EbmlFloat(const EbmlCallbacksDefault & classInfo, const EbmlF SetPrecision(prec); if (classInfo.HasDefault()) { - auto def = static_cast &>(classInfo); + const auto& def = static_cast &>(classInfo); SetValue(def.DefaultValue()); } } diff --git a/src/EbmlMaster.cpp b/src/EbmlMaster.cpp index 31132842..7a27919b 100644 --- a/src/EbmlMaster.cpp +++ b/src/EbmlMaster.cpp @@ -104,7 +104,7 @@ std::uint64_t EbmlMaster::UpdateSize(const ShouldWrite & writeFilter, bool bForc SetSize_(0); if (!IsFiniteSize()) - return (0-1); + return std::numeric_limits::max(); if (!bForceRender) { assert(CheckMandatory()); @@ -117,7 +117,7 @@ std::uint64_t EbmlMaster::UpdateSize(const ShouldWrite & writeFilter, bool bForc const std::uint64_t SizeToAdd = Element->ElementSize(writeFilter); #if !defined(NDEBUG) if (static_cast(SizeToAdd) == (0-1)) - return (0-1); + return std::numeric_limits::max(); #endif // !NDEBUG SetSize_(GetSize() + SizeToAdd); } diff --git a/src/EbmlSInteger.cpp b/src/EbmlSInteger.cpp index edd4a854..ab6d19e6 100644 --- a/src/EbmlSInteger.cpp +++ b/src/EbmlSInteger.cpp @@ -34,7 +34,7 @@ EbmlSInteger::EbmlSInteger(const EbmlCallbacksDefault & classInfo) { if (classInfo.HasDefault()) { - auto def = static_cast &>(classInfo); + const auto& def = static_cast &>(classInfo); SetValue(def.DefaultValue()); } } diff --git a/src/EbmlString.cpp b/src/EbmlString.cpp index fec753f0..ac2fdab6 100644 --- a/src/EbmlString.cpp +++ b/src/EbmlString.cpp @@ -15,7 +15,7 @@ EbmlString::EbmlString(const EbmlCallbacksDefault & classInfo) { if (classInfo.HasDefault()) { - auto def = static_cast &>(classInfo); + const auto& def = static_cast &>(classInfo); SetValue(def.DefaultValue()); } } diff --git a/src/EbmlUInteger.cpp b/src/EbmlUInteger.cpp index 137d4af6..4ec8b5ca 100644 --- a/src/EbmlUInteger.cpp +++ b/src/EbmlUInteger.cpp @@ -17,7 +17,7 @@ EbmlUInteger::EbmlUInteger(const EbmlCallbacksDefault & classInfo { if (classInfo.HasDefault()) { - auto def = static_cast &>(classInfo); + const auto& def = static_cast &>(classInfo); SetValue(def.DefaultValue()); } } diff --git a/src/EbmlUnicodeString.cpp b/src/EbmlUnicodeString.cpp index b45fa30c..22ccfae2 100644 --- a/src/EbmlUnicodeString.cpp +++ b/src/EbmlUnicodeString.cpp @@ -104,7 +104,7 @@ EbmlUnicodeString::EbmlUnicodeString(const EbmlCallbacksDefault { if (classInfo.HasDefault()) { - auto def = static_cast &>(classInfo); + const auto& def = static_cast &>(classInfo); SetValue(UTFstring{def.DefaultValue()}); } } diff --git a/src/MemIOCallback.cpp b/src/MemIOCallback.cpp index 25c202df..eaacf7c2 100644 --- a/src/MemIOCallback.cpp +++ b/src/MemIOCallback.cpp @@ -91,7 +91,7 @@ std::size_t MemIOCallback::write(IOCallback & IOToRead, std::size_t Size) } IOToRead.readFully(&dataBuffer[dataBufferPos], Size); dataBufferTotalSize = Size; - return Size; + return static_cast(Size); } } // namespace libebml diff --git a/src/StdIOCallback.cpp b/src/StdIOCallback.cpp index 083a8e07..d05c38c7 100644 --- a/src/StdIOCallback.cpp +++ b/src/StdIOCallback.cpp @@ -98,7 +98,7 @@ void StdIOCallback::setFilePointer(std::int64_t Offset,seek_mode Mode) std::size_t StdIOCallback::write(const void*Buffer,std::size_t Size) { assert(File!=nullptr); - const std::uint32_t Result = fwrite(Buffer,1,Size,File); + const size_t Result = fwrite(Buffer,1,Size,File); mCurrentPosition += Result; return Result; } diff --git a/test/test_id.cxx b/test/test_id.cxx index 17ce1c02..d95ce92f 100644 --- a/test/test_id.cxx +++ b/test/test_id.cxx @@ -9,13 +9,13 @@ static constexpr EbmlId MyId = EbmlId{0x654321}; class KaxTracks { public: - static const EbmlId & ClassId() { return MyId; }; + static const EbmlId & ClassId() { return MyId; } }; int main(void) { constexpr binary buf[4] = { 0x12, 0x34, 0x56, 0x78 }; - EbmlId frombuf(EbmlId::FromBuffer(buf, 4)); + auto frombuf = EbmlId(EbmlId::FromBuffer(buf, 4)); EbmlId fromint(0x12345678); diff --git a/test/test_macros.cxx b/test/test_macros.cxx index 8aeb96d3..c31cad81 100644 --- a/test/test_macros.cxx +++ b/test/test_macros.cxx @@ -56,7 +56,7 @@ int main(void) return 1; UIntWithDefault test0; - auto ClassSpecWithDefault = test0.ElementSpec(); + const auto& ClassSpecWithDefault = test0.ElementSpec(); if (!ClassSpecWithDefault.HasDefault()) return 1; @@ -90,7 +90,7 @@ int main(void) return 1; UIntWithoutDefault testNoDefault0; - auto ClassSpecWithoutDefault = testNoDefault0.ElementSpec(); + const auto& ClassSpecWithoutDefault = testNoDefault0.ElementSpec(); if (ClassSpecWithoutDefault.HasDefault()) return 1; #ifdef TEST_COMPILATION_ERRORS diff --git a/test/test_utfstring.cxx b/test/test_utfstring.cxx index 8a7b4f23..33c78b11 100644 --- a/test/test_utfstring.cxx +++ b/test/test_utfstring.cxx @@ -36,7 +36,7 @@ int main(void) UTFstring invalid; invalid.SetUTF8( "\x1\xF6\x00" ); - UTFstring empty{0}; + UTFstring empty{nullptr}; if (empty.length() != 0) return 1;