diff --git a/taglib/ape/apeproperties.cpp b/taglib/ape/apeproperties.cpp index d9d2fe87..84d07628 100644 --- a/taglib/ape/apeproperties.cpp +++ b/taglib/ape/apeproperties.cpp @@ -139,7 +139,7 @@ void APE::Properties::read(File *file, offset_t streamLength) if(d->sampleFrames > 0 && d->sampleRate > 0) { const auto length = static_cast(d->sampleFrames) * 1000.0 / d->sampleRate; d->length = static_cast(length + 0.5); - d->bitrate = static_cast(streamLength * 8.0 / length + 0.5); + d->bitrate = static_cast(static_cast(streamLength) * 8.0 / length + 0.5); } } diff --git a/taglib/asf/asfattribute.cpp b/taglib/asf/asfattribute.cpp index c5c93d24..82bd319a 100644 --- a/taglib/asf/asfattribute.cpp +++ b/taglib/asf/asfattribute.cpp @@ -302,16 +302,16 @@ ByteVector ASF::Attribute::render(const String &name, int kind) const if(kind == 0) { data = renderString(name, true) + - ByteVector::fromShort(static_cast(d->type), false) + - ByteVector::fromShort(data.size(), false) + + ByteVector::fromShort(static_cast(d->type), false) + + ByteVector::fromShort(static_cast(data.size()), false) + data; } else { ByteVector nameData = renderString(name); - data = ByteVector::fromShort(kind == 2 ? d->language : 0, false) + - ByteVector::fromShort(d->stream, false) + - ByteVector::fromShort(nameData.size(), false) + - ByteVector::fromShort(static_cast(d->type), false) + + data = ByteVector::fromShort(static_cast(kind == 2 ? d->language : 0), false) + + ByteVector::fromShort(static_cast(d->stream), false) + + ByteVector::fromShort(static_cast(nameData.size()), false) + + ByteVector::fromShort(static_cast(d->type), false) + ByteVector::fromUInt(data.size(), false) + nameData + data; diff --git a/taglib/asf/asffile.cpp b/taglib/asf/asffile.cpp index 23931c67..40bc6209 100644 --- a/taglib/asf/asffile.cpp +++ b/taglib/asf/asffile.cpp @@ -221,7 +221,8 @@ void ASF::File::FilePrivate::FilePropertiesObject::parse(ASF::File *file, long l const long long duration = data.toLongLong(40, false); const long long preroll = data.toLongLong(56, false); - file->d->properties->setLengthInMilliseconds(static_cast(duration / 10000.0 - preroll + 0.5)); + file->d->properties->setLengthInMilliseconds( + static_cast(static_cast(duration) / 10000.0 - static_cast(preroll) + 0.5)); } ByteVector ASF::File::FilePrivate::StreamPropertiesObject::guid() const @@ -271,11 +272,11 @@ ByteVector ASF::File::FilePrivate::ContentDescriptionObject::render(ASF::File *f const ByteVector v4 = renderString(file->d->tag->comment()); const ByteVector v5 = renderString(file->d->tag->rating()); data.clear(); - data.append(ByteVector::fromShort(v1.size(), false)); - data.append(ByteVector::fromShort(v2.size(), false)); - data.append(ByteVector::fromShort(v3.size(), false)); - data.append(ByteVector::fromShort(v4.size(), false)); - data.append(ByteVector::fromShort(v5.size(), false)); + data.append(ByteVector::fromShort(static_cast(v1.size()), false)); + data.append(ByteVector::fromShort(static_cast(v2.size()), false)); + data.append(ByteVector::fromShort(static_cast(v3.size()), false)); + data.append(ByteVector::fromShort(static_cast(v4.size()), false)); + data.append(ByteVector::fromShort(static_cast(v5.size()), false)); data.append(v1); data.append(v2); data.append(v3); @@ -302,7 +303,7 @@ void ASF::File::FilePrivate::ExtendedContentDescriptionObject::parse(ASF::File * ByteVector ASF::File::FilePrivate::ExtendedContentDescriptionObject::render(ASF::File *file) { data.clear(); - data.append(ByteVector::fromShort(attributeData.size(), false)); + data.append(ByteVector::fromShort(static_cast(attributeData.size()), false)); data.append(attributeData.toByteVector("")); return BaseObject::render(file); } @@ -325,7 +326,7 @@ void ASF::File::FilePrivate::MetadataObject::parse(ASF::File *file, long long /* ByteVector ASF::File::FilePrivate::MetadataObject::render(ASF::File *file) { data.clear(); - data.append(ByteVector::fromShort(attributeData.size(), false)); + data.append(ByteVector::fromShort(static_cast(attributeData.size()), false)); data.append(attributeData.toByteVector("")); return BaseObject::render(file); } @@ -348,7 +349,7 @@ void ASF::File::FilePrivate::MetadataLibraryObject::parse(ASF::File *file, long ByteVector ASF::File::FilePrivate::MetadataLibraryObject::render(ASF::File *file) { data.clear(); - data.append(ByteVector::fromShort(attributeData.size(), false)); + data.append(ByteVector::fromShort(static_cast(attributeData.size()), false)); data.append(attributeData.toByteVector("")); return BaseObject::render(file); } diff --git a/taglib/asf/asfutils.h b/taglib/asf/asfutils.h index 501c39e3..8eb24729 100644 --- a/taglib/asf/asfutils.h +++ b/taglib/asf/asfutils.h @@ -90,7 +90,7 @@ namespace TagLib { ByteVector data = str.data(String::UTF16LE) + ByteVector::fromShort(0, false); if(includeLength) { - data = ByteVector::fromShort(data.size(), false) + data; + data = ByteVector::fromShort(static_cast(data.size()), false) + data; } return data; } diff --git a/taglib/dsdiff/dsdiffproperties.cpp b/taglib/dsdiff/dsdiffproperties.cpp index 0585fe48..e0785c60 100644 --- a/taglib/dsdiff/dsdiffproperties.cpp +++ b/taglib/dsdiff/dsdiffproperties.cpp @@ -58,7 +58,7 @@ DSDIFF::Properties::Properties(unsigned int sampleRate, d->sampleRate = sampleRate; d->bitrate = bitrate; d->length = d->sampleRate > 0 - ? static_cast(d->sampleCount * 1000.0 / d->sampleRate + 0.5) + ? static_cast(static_cast(d->sampleCount) * 1000.0 / d->sampleRate + 0.5) : 0; } diff --git a/taglib/dsf/dsffile.cpp b/taglib/dsf/dsffile.cpp index 2912e35a..35951594 100644 --- a/taglib/dsf/dsffile.cpp +++ b/taglib/dsf/dsffile.cpp @@ -59,7 +59,7 @@ bool DSF::File::isSupported(IOStream *stream) return id.startsWith("DSD "); } -DSF::File::File(FileName file, bool readProperties, +DSF::File::File(FileName file, bool, AudioProperties::ReadStyle propertiesStyle, ID3v2::FrameFactory *frameFactory) : TagLib::File(file), @@ -69,7 +69,7 @@ DSF::File::File(FileName file, bool readProperties, read(propertiesStyle); } -DSF::File::File(IOStream *stream, bool readProperties, +DSF::File::File(IOStream *stream, bool, AudioProperties::ReadStyle propertiesStyle, ID3v2::FrameFactory *frameFactory) : TagLib::File(stream), diff --git a/taglib/dsf/dsfproperties.cpp b/taglib/dsf/dsfproperties.cpp index 0556d823..0d3ae57f 100644 --- a/taglib/dsf/dsfproperties.cpp +++ b/taglib/dsf/dsfproperties.cpp @@ -129,6 +129,6 @@ void DSF::Properties::read(const ByteVector &data) d->bitrate = static_cast( d->samplingFrequency * d->bitsPerSample * d->channelNum / 1000.0 + 0.5); d->length = d->samplingFrequency > 0 - ? static_cast(d->sampleCount * 1000.0 / d->samplingFrequency + 0.5) + ? static_cast(static_cast(d->sampleCount) * 1000.0 / d->samplingFrequency + 0.5) : 0; } diff --git a/taglib/fileref.cpp b/taglib/fileref.cpp index 3ff45c33..2b5e5873 100644 --- a/taglib/fileref.cpp +++ b/taglib/fileref.cpp @@ -321,7 +321,7 @@ public: return !file || !file->isValid(); } - bool isNullWithDebugMessage(const String &methodName) const + bool isNullWithDebugMessage([[maybe_unused]] const String &methodName) const { if(isNull()) { debug("FileRef::" + methodName + "() - Called without a valid file."); diff --git a/taglib/flac/flacfile.cpp b/taglib/flac/flacfile.cpp index f0d93bd4..a282c95a 100644 --- a/taglib/flac/flacfile.cpp +++ b/taglib/flac/flacfile.cpp @@ -274,7 +274,7 @@ bool FLAC::File::save() it = d->blocks.erase(it); continue; } - blockHeader[0] = (*it)->code(); + blockHeader[0] = static_cast((*it)->code()); data.append(blockHeader); data.append(blockData); ++it; diff --git a/taglib/flac/flacproperties.cpp b/taglib/flac/flacproperties.cpp index 03a741eb..0e829147 100644 --- a/taglib/flac/flacproperties.cpp +++ b/taglib/flac/flacproperties.cpp @@ -134,7 +134,7 @@ void FLAC::Properties::read(const ByteVector &data, offset_t streamLength) if(d->sampleFrames > 0 && d->sampleRate > 0) { const auto length = static_cast(d->sampleFrames) * 1000.0 / d->sampleRate; d->length = static_cast(length + 0.5); - d->bitrate = static_cast(streamLength * 8.0 / length + 0.5); + d->bitrate = static_cast(static_cast(streamLength) * 8.0 / length + 0.5); } if(data.size() >= pos + 16) diff --git a/taglib/it/itfile.cpp b/taglib/it/itfile.cpp index 6c8ec652..a1ca419b 100644 --- a/taglib/it/itfile.cpp +++ b/taglib/it/itfile.cpp @@ -167,7 +167,7 @@ bool IT::File::save() if(messageOffset + messageLength >= fileSize) { // append new message seek(54); - writeU16L(message.size()); + writeU16L(static_cast(message.size())); writeU32L(messageOffset); seek(messageOffset); writeBlock(message); diff --git a/taglib/mp4/mp4itemfactory.cpp b/taglib/mp4/mp4itemfactory.cpp index dbf3d6f9..c402bf98 100644 --- a/taglib/mp4/mp4itemfactory.cpp +++ b/taglib/mp4/mp4itemfactory.cpp @@ -400,7 +400,7 @@ Map ItemFactory::namePropertyMap() const } MP4::AtomDataList ItemFactory::parseData2( - const MP4::Atom *atom, const ByteVector &data, int expectedFlags, + const MP4::Atom *, const ByteVector &data, int expectedFlags, bool freeForm) { AtomDataList result; @@ -663,7 +663,7 @@ ByteVector ItemFactory::renderInt( const ByteVector &name, const MP4::Item &item) { ByteVectorList data; - data.append(ByteVector::fromShort(item.toInt())); + data.append(ByteVector::fromShort(static_cast(item.toInt()))); return renderData(name, TypeInteger, data); } @@ -703,8 +703,8 @@ ByteVector ItemFactory::renderIntPair( { ByteVectorList data; data.append(ByteVector(2, '\0') + - ByteVector::fromShort(item.toIntPair().first) + - ByteVector::fromShort(item.toIntPair().second) + + ByteVector::fromShort(static_cast(item.toIntPair().first)) + + ByteVector::fromShort(static_cast(item.toIntPair().second)) + ByteVector(2, '\0')); return renderData(name, TypeImplicit, data); } @@ -714,8 +714,8 @@ ByteVector ItemFactory::renderIntPairNoTrailing( { ByteVectorList data; data.append(ByteVector(2, '\0') + - ByteVector::fromShort(item.toIntPair().first) + - ByteVector::fromShort(item.toIntPair().second)); + ByteVector::fromShort(static_cast(item.toIntPair().first)) + + ByteVector::fromShort(static_cast(item.toIntPair().second))); return renderData(name, TypeImplicit, data); } diff --git a/taglib/mp4/mp4properties.cpp b/taglib/mp4/mp4properties.cpp index d3d0c207..df83d641 100644 --- a/taglib/mp4/mp4properties.cpp +++ b/taglib/mp4/mp4properties.cpp @@ -196,7 +196,7 @@ MP4::Properties::read(File *file, const Atoms *atoms) } } if(unit > 0 && length > 0) - d->length = static_cast(length * 1000.0 / unit + 0.5); + d->length = static_cast(static_cast(length) * 1000.0 / static_cast(unit) + 0.5); MP4::Atom *atom = trak->find("mdia", "minf", "stbl", "stsd"); if(!atom) { diff --git a/taglib/mpc/mpcproperties.cpp b/taglib/mpc/mpcproperties.cpp index 46fef24d..6da886c1 100644 --- a/taglib/mpc/mpcproperties.cpp +++ b/taglib/mpc/mpcproperties.cpp @@ -229,7 +229,7 @@ void MPC::Properties::readSV8(File *file, offset_t streamLength) frameCount > 0 && d->sampleRate > 0) { const auto length = static_cast(frameCount) * 1000.0 / d->sampleRate; d->length = static_cast(length + 0.5); - d->bitrate = static_cast(streamLength * 8.0 / length + 0.5); + d->bitrate = static_cast(static_cast(streamLength) * 8.0 / length + 0.5); } } else if (packetType == "RG") { @@ -331,6 +331,6 @@ void MPC::Properties::readSV7(const ByteVector &data, offset_t streamLength) d->length = static_cast(length + 0.5); if(d->bitrate == 0) - d->bitrate = static_cast(streamLength * 8.0 / length + 0.5); + d->bitrate = static_cast(static_cast(streamLength) * 8.0 / length + 0.5); } } diff --git a/taglib/mpeg/id3v1/id3v1tag.cpp b/taglib/mpeg/id3v1/id3v1tag.cpp index 8f55a16e..cd8cceb9 100644 --- a/taglib/mpeg/id3v1/id3v1tag.cpp +++ b/taglib/mpeg/id3v1/id3v1tag.cpp @@ -176,7 +176,7 @@ void ID3v1::Tag::setComment(const String &s) void ID3v1::Tag::setGenre(const String &s) { - d->genre = ID3v1::genreIndex(s); + d->genre = static_cast(ID3v1::genreIndex(s)); } void ID3v1::Tag::setYear(unsigned int i) @@ -186,7 +186,7 @@ void ID3v1::Tag::setYear(unsigned int i) void ID3v1::Tag::setTrack(unsigned int i) { - d->track = i < 256 ? i : 0; + d->track = static_cast(i < 256 ? i : 0); } unsigned int ID3v1::Tag::genreNumber() const @@ -196,7 +196,7 @@ unsigned int ID3v1::Tag::genreNumber() const void ID3v1::Tag::setGenreNumber(unsigned int i) { - d->genre = i < 256 ? i : 255; + d->genre = static_cast(i < 256 ? i : 255); } void ID3v1::Tag::setStringHandler(const StringHandler *handler) diff --git a/taglib/mpeg/mpegproperties.cpp b/taglib/mpeg/mpegproperties.cpp index 1790b282..8a64ff26 100644 --- a/taglib/mpeg/mpegproperties.cpp +++ b/taglib/mpeg/mpegproperties.cpp @@ -240,7 +240,7 @@ void MPEG::Properties::read(File *file, ReadStyle readStyle) const Header lastHeader(file, lastFrameOffset, false); if(const offset_t streamLength = lastFrameOffset - firstFrameOffset + lastHeader.frameLength(); streamLength > 0) - d->length = static_cast(streamLength * 8.0 / d->bitrate + 0.5); + d->length = static_cast(static_cast(streamLength) * 8.0 / d->bitrate + 0.5); } } } diff --git a/taglib/ogg/opus/opusproperties.cpp b/taglib/ogg/opus/opusproperties.cpp index 296d795f..a936ce77 100644 --- a/taglib/ogg/opus/opusproperties.cpp +++ b/taglib/ogg/opus/opusproperties.cpp @@ -147,7 +147,7 @@ void Opus::Properties::read(File *file) fileLengthWithoutOverhead -= file->packet(i).size(); } d->length = static_cast(length + 0.5); - d->bitrate = static_cast(fileLengthWithoutOverhead * 8.0 / length + 0.5); + d->bitrate = static_cast(static_cast(fileLengthWithoutOverhead) * 8.0 / length + 0.5); } } else { diff --git a/taglib/ogg/speex/speexproperties.cpp b/taglib/ogg/speex/speexproperties.cpp index 7b54758b..3f9bf5bb 100644 --- a/taglib/ogg/speex/speexproperties.cpp +++ b/taglib/ogg/speex/speexproperties.cpp @@ -163,7 +163,7 @@ void Speex::Properties::read(File *file) fileLengthWithoutOverhead -= file->packet(i).size(); } d->length = static_cast(length + 0.5); - d->bitrate = static_cast(fileLengthWithoutOverhead * 8.0 / length + 0.5); + d->bitrate = static_cast(static_cast(fileLengthWithoutOverhead) * 8.0 / length + 0.5); } } else { diff --git a/taglib/ogg/vorbis/vorbisproperties.cpp b/taglib/ogg/vorbis/vorbisproperties.cpp index 4afe3151..42ee3d3b 100644 --- a/taglib/ogg/vorbis/vorbisproperties.cpp +++ b/taglib/ogg/vorbis/vorbisproperties.cpp @@ -166,7 +166,7 @@ void Vorbis::Properties::read(File *file) fileLengthWithoutOverhead -= file->packet(i).size(); } d->length = static_cast(length + 0.5); - d->bitrate = static_cast(fileLengthWithoutOverhead * 8.0 / length + 0.5); + d->bitrate = static_cast(static_cast(fileLengthWithoutOverhead) * 8.0 / length + 0.5); } } else { diff --git a/taglib/shorten/shortenfile.cpp b/taglib/shorten/shortenfile.cpp index 850708e4..c1e44c10 100644 --- a/taglib/shorten/shortenfile.cpp +++ b/taglib/shorten/shortenfile.cpp @@ -196,7 +196,7 @@ bool Shorten::File::isSupported(IOStream *stream) return id.startsWith("ajkg"); } -Shorten::File::File(FileName file, bool readProperties, +Shorten::File::File(FileName file, bool, AudioProperties::ReadStyle propertiesStyle) : TagLib::File(file), d(std::make_unique()) @@ -205,7 +205,7 @@ Shorten::File::File(FileName file, bool readProperties, read(propertiesStyle); } -Shorten::File::File(IOStream *stream, bool readProperties, +Shorten::File::File(IOStream *stream, bool, AudioProperties::ReadStyle propertiesStyle) : TagLib::File(stream), d(std::make_unique()) diff --git a/taglib/shorten/shortenproperties.cpp b/taglib/shorten/shortenproperties.cpp index 65aca412..96e61a3f 100644 --- a/taglib/shorten/shortenproperties.cpp +++ b/taglib/shorten/shortenproperties.cpp @@ -65,7 +65,7 @@ Shorten::Properties::Properties(const PropertyValues *values, ReadStyle style) : d->bitrate = static_cast(d->sampleRate * d->bitsPerSample * d->channelCount / 1000.0 + 0.5); if(d->sampleRate > 0) - d->length = static_cast(d->sampleFrames * 1000.0 / d->sampleRate + 0.5); + d->length = static_cast(static_cast(d->sampleFrames) * 1000.0 / d->sampleRate + 0.5); } } diff --git a/taglib/toolkit/tbytevector.cpp b/taglib/toolkit/tbytevector.cpp index e7b18918..5a32585b 100644 --- a/taglib/toolkit/tbytevector.cpp +++ b/taglib/toolkit/tbytevector.cpp @@ -120,7 +120,8 @@ T toNumber(const ByteVector &v, size_t offset, size_t length, bool mostSignifica T sum = 0; for(size_t i = 0; i < length; i++) { const size_t shift = (mostSignificantByteFirst ? length - 1 - i : i) * 8; - sum |= static_cast(static_cast(v[static_cast(offset + i)])) << shift; + sum |= static_cast( + static_cast(static_cast(v[static_cast(offset + i)])) << shift); } return sum; diff --git a/taglib/trueaudio/trueaudioproperties.cpp b/taglib/trueaudio/trueaudioproperties.cpp index 3f885472..88c714b6 100644 --- a/taglib/trueaudio/trueaudioproperties.cpp +++ b/taglib/trueaudio/trueaudioproperties.cpp @@ -145,7 +145,7 @@ void TrueAudio::Properties::read(const ByteVector &data, offset_t streamLength) if(d->sampleFrames > 0 && d->sampleRate > 0) { const auto length = static_cast(d->sampleFrames) * 1000.0 / d->sampleRate; d->length = static_cast(length + 0.5); - d->bitrate = static_cast(streamLength * 8.0 / length + 0.5); + d->bitrate = static_cast(static_cast(streamLength) * 8.0 / length + 0.5); } } } diff --git a/taglib/wavpack/wavpackproperties.cpp b/taglib/wavpack/wavpackproperties.cpp index ad84f1e1..34119402 100644 --- a/taglib/wavpack/wavpackproperties.cpp +++ b/taglib/wavpack/wavpackproperties.cpp @@ -288,7 +288,7 @@ void WavPack::Properties::read(File *file, offset_t streamLength) if(d->version < MIN_STREAM_VERS || d->version > MAX_STREAM_VERS) break; - d->bitsPerSample = ((flags & BYTES_STORED) + 1) * 8 - ((flags & SHIFT_MASK) >> SHIFT_LSB); + d->bitsPerSample = static_cast(((flags & BYTES_STORED) + 1) * 8 - ((flags & SHIFT_MASK) >> SHIFT_LSB)); d->sampleRate = static_cast(smplRate); d->lossless = !(flags & HYBRID_FLAG); d->sampleFrames = smplFrames; @@ -308,7 +308,7 @@ void WavPack::Properties::read(File *file, offset_t streamLength) if(d->sampleFrames > 0 && d->sampleRate > 0) { const auto length = static_cast(d->sampleFrames) * 1000.0 / d->sampleRate; d->length = static_cast(length + 0.5); - d->bitrate = static_cast(streamLength * 8.0 / length + 0.5); + d->bitrate = static_cast(static_cast(streamLength) * 8.0 / length + 0.5); } } diff --git a/tests/test_bytevector.cpp b/tests/test_bytevector.cpp index 066f01e9..f149d619 100644 --- a/tests/test_bytevector.cpp +++ b/tests/test_bytevector.cpp @@ -560,7 +560,7 @@ public: // reverse { for(int i = 0; i < 256; i++){ - all[i]=static_cast(255)-i; + all[i]=static_cast(255 - i); } ByteVector b64 = all.toBase64(); ByteVector original = ByteVector::fromBase64(b64);