From dce8e016b9620685d87d52f0f00dc7dd48a019a5 Mon Sep 17 00:00:00 2001 From: Urs Fleisch Date: Sat, 14 Oct 2023 08:37:52 +0200 Subject: [PATCH] DSDIFF: Fix MSVC warnings --- taglib/dsdiff/dsdifffile.cpp | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/taglib/dsdiff/dsdifffile.cpp b/taglib/dsdiff/dsdifffile.cpp index 8b38be05..cb6f0649 100644 --- a/taglib/dsdiff/dsdifffile.cpp +++ b/taglib/dsdiff/dsdifffile.cpp @@ -54,7 +54,7 @@ namespace { for(size_t i = 0; i < chunks.size(); i++) { if(chunks[i].name == id) - return i; + return static_cast(i); } return -1; @@ -361,7 +361,7 @@ void DSDIFF::File::setRootChunkData(unsigned int i, const ByteVector &data) writeChunk(d->chunks[i].name, data, d->chunks[i].offset - 12, - d->chunks[i].size + d->chunks[i].padding + 12); + static_cast(d->chunks[i].size + d->chunks[i].padding + 12)); d->chunks[i].size = data.size(); d->chunks[i].padding = (data.size() & 0x01) ? 1 : 0; @@ -386,8 +386,8 @@ void DSDIFF::File::setRootChunkData(const ByteVector &name, const ByteVector &da } // Couldn't find an existing chunk, so let's create a new one. - i = d->chunks.size() - 1; - unsigned long offset = d->chunks[i].offset + d->chunks[i].size + d->chunks[i].padding; + i = static_cast(d->chunks.size()) - 1; + unsigned long long offset = d->chunks[i].offset + d->chunks[i].size + d->chunks[i].padding; // First we update the global size d->size += (offset & 1) + ((data.size() + 1) & ~1) + 12; @@ -398,7 +398,7 @@ void DSDIFF::File::setRootChunkData(const ByteVector &name, const ByteVector &da writeChunk(name, data, offset, - fileLength > offset ? fileLength - offset : 0, + static_cast(fileLength > offset ? fileLength - offset : 0), (offset & 1) ? 1 : 0); Chunk64 chunk; @@ -485,7 +485,7 @@ void DSDIFF::File::setChildChunkData(unsigned int i, writeChunk(childChunks[i].name, data, childChunks[i].offset - 12, - childChunks[i].size + childChunks[i].padding + 12); + static_cast(childChunks[i].size + childChunks[i].padding + 12)); childChunks[i].size = data.size(); childChunks[i].padding = (data.size() & 0x01) ? 1 : 0; @@ -520,14 +520,14 @@ void DSDIFF::File::setChildChunkData(const ByteVector &name, unsigned long long offset = 0; if(childChunks.size() > 0) { - unsigned int i = childChunks.size() - 1; + size_t i = childChunks.size() - 1; offset = childChunks[i].offset + childChunks[i].size + childChunks[i].padding; } else if(childChunkNum == DIINChunk) { int i = d->childChunkIndex[DIINChunk]; if(i < 0) { setRootChunkData("DIIN", ByteVector()); - const int lastChunkIndex = d->chunks.size() - 1; + const int lastChunkIndex = static_cast(d->chunks.size()) - 1; if(lastChunkIndex >= 0 && d->chunks[lastChunkIndex].name == "DIIN") { i = lastChunkIndex; d->childChunkIndex[DIINChunk] = lastChunkIndex; @@ -563,7 +563,8 @@ void DSDIFF::File::setChildChunkData(const ByteVector &name, nextRootChunkIdx = d->chunks[d->childChunkIndex[childChunkNum] + 1].offset - 12; writeChunk(name, data, offset, - nextRootChunkIdx > offset ? nextRootChunkIdx - offset : 0, + static_cast( + nextRootChunkIdx > offset ? nextRootChunkIdx - offset : 0), (offset & 1) ? 1 : 0); // For root chunks @@ -646,7 +647,7 @@ void DSDIFF::File::read(bool readProperties, Properties::ReadStyle propertiesSty // Check padding chunk.padding = 0; - long uPosNotPadded = tell(); + offset_t uPosNotPadded = tell(); if((uPosNotPadded & 0x01) != 0) { ByteVector iByte = readBlock(1); if((iByte.size() != 1) || (iByte[0] != 0)) @@ -707,7 +708,7 @@ void DSDIFF::File::read(bool readProperties, Properties::ReadStyle propertiesSty seek(dstChunkSize, Current); // Check padding - long uPosNotPadded = tell(); + offset_t uPosNotPadded = tell(); if((uPosNotPadded & 0x01) != 0) { ByteVector iByte = readBlock(1); if((iByte.size() != 1) || (iByte[0] != 0)) @@ -748,7 +749,7 @@ void DSDIFF::File::read(bool readProperties, Properties::ReadStyle propertiesSty // Check padding chunk.padding = 0; - long uPosNotPadded = tell(); + offset_t uPosNotPadded = tell(); if((uPosNotPadded & 0x01) != 0) { ByteVector iByte = readBlock(1); if((iByte.size() != 1) || (iByte[0] != 0)) @@ -796,7 +797,7 @@ void DSDIFF::File::read(bool readProperties, Properties::ReadStyle propertiesSty // Check padding chunk.padding = 0; - long uPosNotPadded = tell(); + offset_t uPosNotPadded = tell(); if((uPosNotPadded & 0x01) != 0) { ByteVector iByte = readBlock(1); @@ -898,7 +899,8 @@ void DSDIFF::File::read(bool readProperties, Properties::ReadStyle propertiesSty } int bitrate = 0; if(lengthDSDSamplesTimeChannels > 0) - bitrate = (audioDataSizeinBytes * 8 * sampleRate) / lengthDSDSamplesTimeChannels / 1000; + bitrate = static_cast( + (audioDataSizeinBytes * 8 * sampleRate) / lengthDSDSamplesTimeChannels / 1000); d->properties = std::make_unique(sampleRate, channels, lengthDSDSamplesTimeChannels, bitrate, propertiesStyle);