Silence MSVC warnings concerning narrowing conversions.

This commit is contained in:
Tsuda Kageyu 2015-12-21 15:17:59 +09:00
parent ed0305bd3f
commit 75159614fc
10 changed files with 21 additions and 19 deletions

View File

@ -71,8 +71,8 @@ namespace TagLib
inline String readString(File *file, int length)
{
ByteVector data = file->readBlock(length);
unsigned int size = data.size();
while (size >= 2) {
size_t size = data.size();
while(size >= 2) {
if(data[size - 1] != '\0' || data[size - 2] != '\0') {
break;
}

View File

@ -125,8 +125,8 @@ namespace
#endif
String ext;
const int pos = s.rfind(".");
if(pos != -1)
const size_t pos = s.rfind(".");
if(pos != String::npos())
ext = s.substr(pos + 1).upper();
// If this list is updated, the method defaultFileExtensions() should also be

View File

@ -82,13 +82,13 @@ bool Mod::File::save()
seek(0);
writeString(d->tag.title(), 20);
StringList lines = d->tag.comment().split("\n");
unsigned int n = std::min<unsigned int>(lines.size(), d->properties.instrumentCount());
for(unsigned int i = 0; i < n; ++ i) {
size_t n = std::min<size_t>(lines.size(), d->properties.instrumentCount());
for(size_t i = 0; i < n; ++ i) {
writeString(lines[i], 22);
seek(8, Current);
}
for(unsigned int i = n; i < d->properties.instrumentCount(); ++ i) {
for(size_t i = n; i < d->properties.instrumentCount(); ++ i) {
writeString(String(), 22);
seek(8, Current);
}

View File

@ -628,8 +628,8 @@ MP4::Tag::saveNew(ByteVector data)
long long offset = path.back()->offset + 8;
d->file->insert(data, offset, 0);
updateParents(path, data.size());
updateOffsets(data.size(), offset);
updateParents(path, static_cast<long>(data.size()));
updateOffsets(static_cast<long>(data.size()), offset);
// Insert the newly created atoms into the tree to keep it up-to-date.

View File

@ -123,7 +123,7 @@ bool TableOfContentsFrame::isOrdered() const
unsigned int TableOfContentsFrame::entryCount() const
{
return d->childElements.size();
return static_cast<unsigned int>(d->childElements.size());
}
ByteVectorList TableOfContentsFrame::childElements() const
@ -261,7 +261,7 @@ TableOfContentsFrame *TableOfContentsFrame::findTopLevel(const ID3v2::Tag *tag)
void TableOfContentsFrame::parseFields(const ByteVector &data)
{
unsigned int size = data.size();
size_t size = data.size();
if(size < 6) {
debug("A CTOC frame must contain at least 6 bytes (1 byte element ID terminated by "
"null, 1 byte flags, 1 byte entry count and 1 byte child element ID terminated "

View File

@ -63,7 +63,7 @@ namespace
for(StringList::ConstIterator it = fields.begin(); it != fields.end(); ++it) {
String s = *it;
int end = s.find(")");
size_t end = s.find(")");
if(s.startsWith("(") && end > 0) {
// "(12)Genre"

View File

@ -211,14 +211,14 @@ bool Ogg::XiphComment::isEmpty() const
unsigned int Ogg::XiphComment::fieldCount() const
{
unsigned int count = 0;
size_t count = 0;
for(FieldConstIterator it = d->fieldListMap.begin(); it != d->fieldListMap.end(); ++it)
count += (*it).second.size();
count += d->pictureList.size();
return count;
return static_cast<unsigned int>(count);
}
const Ogg::FieldListMap &Ogg::XiphComment::fieldListMap() const

View File

@ -224,7 +224,7 @@ void RIFF::File::removeChunk(unsigned int i)
std::vector<Chunk>::iterator it = d->chunks.begin();
std::advance(it, i);
const unsigned int removeSize = it->size + it->padding + 8;
const size_t removeSize = it->size + it->padding + 8;
removeBlock(it->offset - 8, removeSize);
it = d->chunks.erase(it);
@ -234,7 +234,7 @@ void RIFF::File::removeChunk(unsigned int i)
void RIFF::File::removeChunk(const ByteVector &name)
{
for(int i = d->chunks.size() - 1; i >= 0; --i) {
for(int i = static_cast<int>(d->chunks.size()) - 1; i >= 0; --i) {
if(d->chunks[i].name == name)
removeChunk(i);
}

View File

@ -58,7 +58,8 @@ namespace
#ifdef _WIN32
len = ::WideCharToMultiByte(CP_UTF8, 0, src, srcLength, dst, dstLength, NULL, NULL);
len = ::WideCharToMultiByte(
CP_UTF8, 0, src, static_cast<int>(srcLength), dst, static_cast<int>(dstLength), NULL, NULL);
#else
@ -91,7 +92,8 @@ namespace
#ifdef _WIN32
len = ::MultiByteToWideChar(CP_UTF8, 0, src, srcLength, dst, dstLength);
len = ::MultiByteToWideChar(
CP_UTF8, 0, src, static_cast<int>(srcLength), dst, static_cast<int>(dstLength));
#else

View File

@ -14,7 +14,7 @@ class PublicRIFF : public RIFF::File
public:
PublicRIFF(FileName file) : RIFF::File(file, BigEndian) {};
unsigned int riffSize() { return RIFF::File::riffSize(); };
unsigned int chunkCount() { return RIFF::File::chunkCount(); };
size_t chunkCount() { return RIFF::File::chunkCount(); };
long long chunkOffset(unsigned int i) { return RIFF::File::chunkOffset(i); };
unsigned int chunkPadding(unsigned int i) { return RIFF::File::chunkPadding(i); };
unsigned int chunkDataSize(unsigned int i) { return RIFF::File::chunkDataSize(i); };