mirror of
https://github.com/taglib/taglib.git
synced 2025-06-04 01:28:21 -04:00
clang-tidy: use C++ casting
Found with google-readability-casting Signed-off-by: Rosen Penev <rosenp@gmail.com>
This commit is contained in:
parent
38d1d4c21c
commit
68ac7c3106
@ -312,7 +312,7 @@ ByteVector ASF::Attribute::render(const String &name, int kind) const
|
||||
|
||||
if(kind == 0) {
|
||||
data = renderString(name, true) +
|
||||
ByteVector::fromShort((int)d->type, false) +
|
||||
ByteVector::fromShort(static_cast<int>(d->type), false) +
|
||||
ByteVector::fromShort(data.size(), false) +
|
||||
data;
|
||||
}
|
||||
@ -321,7 +321,7 @@ ByteVector ASF::Attribute::render(const String &name, int kind) const
|
||||
data = ByteVector::fromShort(kind == 2 ? d->language : 0, false) +
|
||||
ByteVector::fromShort(d->stream, false) +
|
||||
ByteVector::fromShort(nameData.size(), false) +
|
||||
ByteVector::fromShort((int)d->type, false) +
|
||||
ByteVector::fromShort(static_cast<int>(d->type), false) +
|
||||
ByteVector::fromUInt(data.size(), false) +
|
||||
nameData +
|
||||
data;
|
||||
|
@ -194,7 +194,7 @@ private:
|
||||
void ASF::File::FilePrivate::BaseObject::parse(ASF::File *file, unsigned int size)
|
||||
{
|
||||
data.clear();
|
||||
if(size > 24 && size <= (unsigned int)(file->length()))
|
||||
if(size > 24 && size <= static_cast<unsigned int>(file->length()))
|
||||
data = file->readBlock(size - 24);
|
||||
else
|
||||
data = ByteVector();
|
||||
@ -400,7 +400,7 @@ void ASF::File::FilePrivate::HeaderExtensionObject::parse(ASF::File *file, unsig
|
||||
else {
|
||||
obj = new UnknownObject(guid);
|
||||
}
|
||||
obj->parse(file, (unsigned int)size);
|
||||
obj->parse(file, static_cast<unsigned int>(size));
|
||||
objects.append(obj);
|
||||
dataPos += size;
|
||||
}
|
||||
@ -656,7 +656,7 @@ void ASF::File::read()
|
||||
setValid(false);
|
||||
break;
|
||||
}
|
||||
long size = (long)readQWORD(this, &ok);
|
||||
long size = static_cast<long>(readQWORD(this, &ok));
|
||||
if(!ok) {
|
||||
setValid(false);
|
||||
break;
|
||||
|
@ -137,7 +137,7 @@ ByteVector ASF::Picture::render() const
|
||||
return ByteVector();
|
||||
|
||||
return
|
||||
ByteVector((char)d->type) +
|
||||
ByteVector(static_cast<char>(d->type)) +
|
||||
ByteVector::fromUInt(d->picture.size(), false) +
|
||||
renderString(d->mimeType) +
|
||||
renderString(d->description) +
|
||||
@ -150,7 +150,7 @@ void ASF::Picture::parse(const ByteVector& bytes)
|
||||
if(bytes.size() < 9)
|
||||
return;
|
||||
int pos = 0;
|
||||
d->type = (Type)bytes[0]; ++pos;
|
||||
d->type = static_cast<Type>(bytes[0]); ++pos;
|
||||
const unsigned int dataLen = bytes.toUInt(pos, false); pos+=4;
|
||||
|
||||
const ByteVector nullStringTerminator(2, 0);
|
||||
|
@ -113,7 +113,7 @@ bool IT::File::save()
|
||||
// write comment as instrument and sample names:
|
||||
StringList lines = d->tag.comment().split("\n");
|
||||
for(unsigned short i = 0; i < instrumentCount; ++ i) {
|
||||
seek(192L + length + ((long)i << 2));
|
||||
seek(192L + length + (static_cast<long>(i) << 2));
|
||||
unsigned long instrumentOffset = 0;
|
||||
if(!readU32L(instrumentOffset))
|
||||
return false;
|
||||
@ -128,14 +128,14 @@ bool IT::File::save()
|
||||
}
|
||||
|
||||
for(unsigned short i = 0; i < sampleCount; ++ i) {
|
||||
seek(192L + length + ((long)instrumentCount << 2) + ((long)i << 2));
|
||||
seek(192L + length + (static_cast<long>(instrumentCount) << 2) + (static_cast<long>(i) << 2));
|
||||
unsigned long sampleOffset = 0;
|
||||
if(!readU32L(sampleOffset))
|
||||
return false;
|
||||
|
||||
seek(sampleOffset + 20);
|
||||
|
||||
if((unsigned int)(i + instrumentCount) < lines.size())
|
||||
if(static_cast<unsigned int>(i + instrumentCount) < lines.size())
|
||||
writeString(lines[i + instrumentCount], 25);
|
||||
else
|
||||
writeString(String(), 25);
|
||||
@ -152,7 +152,7 @@ bool IT::File::save()
|
||||
// terminating NUL but it does not hurt to add one:
|
||||
if(message.size() > 7999)
|
||||
message.resize(7999);
|
||||
message.append((char)0);
|
||||
message.append(static_cast<char>(0));
|
||||
|
||||
unsigned short special = 0;
|
||||
unsigned short messageLength = 0;
|
||||
@ -239,7 +239,7 @@ void IT::File::read(bool)
|
||||
seek(messageOffset);
|
||||
ByteVector messageBytes = readBlock(messageLength);
|
||||
READ_ASSERT(messageBytes.size() == messageLength);
|
||||
int index = messageBytes.find((char) 0);
|
||||
int index = messageBytes.find(static_cast<char>(0));
|
||||
if(index > -1)
|
||||
messageBytes.resize(index, 0);
|
||||
messageBytes.replace('\r', '\n');
|
||||
@ -258,7 +258,7 @@ void IT::File::read(bool)
|
||||
// But this always gives 64 channels for all my files anyway.
|
||||
// Strangely VLC does report other values. I wonder how VLC
|
||||
// gets it's values.
|
||||
if((unsigned char) pannings[i] < 128 && volumes[i] > 0)
|
||||
if(static_cast<unsigned char>(pannings[i]) < 128 && volumes[i] > 0)
|
||||
++channels;
|
||||
}
|
||||
d->properties.setChannels(channels);
|
||||
@ -280,7 +280,7 @@ void IT::File::read(bool)
|
||||
// e.g. VLC seems to interpret a nil as a space. I
|
||||
// don't know what is the proper behaviour.
|
||||
for(unsigned short i = 0; i < instrumentCount; ++ i) {
|
||||
seek(192L + length + ((long)i << 2));
|
||||
seek(192L + length + (static_cast<long>(i) << 2));
|
||||
READ_U32L_AS(instrumentOffset);
|
||||
seek(instrumentOffset);
|
||||
|
||||
@ -296,7 +296,7 @@ void IT::File::read(bool)
|
||||
}
|
||||
|
||||
for(unsigned short i = 0; i < sampleCount; ++ i) {
|
||||
seek(192L + length + ((long)instrumentCount << 2) + ((long)i << 2));
|
||||
seek(192L + length + (static_cast<long>(instrumentCount) << 2) + (static_cast<long>(i) << 2));
|
||||
READ_U32L_AS(sampleOffset);
|
||||
|
||||
seek(sampleOffset);
|
||||
|
@ -49,7 +49,7 @@ bool Mod::FileBase::readString(String &s, unsigned long size)
|
||||
{
|
||||
ByteVector data(readBlock(size));
|
||||
if(data.size() < size) return false;
|
||||
int index = data.find((char) 0);
|
||||
int index = data.find(static_cast<char>(0));
|
||||
if(index > -1)
|
||||
{
|
||||
data.resize(index);
|
||||
|
@ -84,7 +84,7 @@ MP4::Tag::Tag(TagLib::File *file, MP4::Atoms *atoms) :
|
||||
if (val.type == TypeUTF8) {
|
||||
addItem(atom->name, StringList(String(val.data, String::UTF8)));
|
||||
} else {
|
||||
addItem(atom->name, (int)(val.data.toShort()));
|
||||
addItem(atom->name, static_cast<int>(val.data.toShort()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -177,7 +177,7 @@ MP4::Tag::parseInt(const MP4::Atom *atom)
|
||||
{
|
||||
ByteVectorList data = parseData(atom);
|
||||
if(!data.isEmpty()) {
|
||||
addItem(atom->name, (int)data[0].toShort());
|
||||
addItem(atom->name, static_cast<int>(data[0].toShort()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -213,7 +213,7 @@ MP4::Tag::parseGnre(const MP4::Atom *atom)
|
||||
{
|
||||
ByteVectorList data = parseData(atom);
|
||||
if(!data.isEmpty()) {
|
||||
int idx = (int)data[0].toShort();
|
||||
int idx = static_cast<int>(data[0].toShort());
|
||||
if(idx > 0) {
|
||||
addItem("\251gen", StringList(ID3v1::genre(idx - 1)));
|
||||
}
|
||||
|
@ -320,22 +320,22 @@ void MPC::Properties::readSV7(const ByteVector &data, long streamLength)
|
||||
|
||||
// convert gain info
|
||||
if(d->trackGain != 0) {
|
||||
int tmp = (int)((64.82 - (short)d->trackGain / 100.) * 256. + .5);
|
||||
int tmp = static_cast<int>((64.82 - static_cast<short>(d->trackGain) / 100.) * 256. + .5);
|
||||
if(tmp >= (1 << 16) || tmp < 0) tmp = 0;
|
||||
d->trackGain = tmp;
|
||||
}
|
||||
|
||||
if(d->albumGain != 0) {
|
||||
int tmp = (int)((64.82 - d->albumGain / 100.) * 256. + .5);
|
||||
int tmp = static_cast<int>((64.82 - d->albumGain / 100.) * 256. + .5);
|
||||
if(tmp >= (1 << 16) || tmp < 0) tmp = 0;
|
||||
d->albumGain = tmp;
|
||||
}
|
||||
|
||||
if (d->trackPeak != 0)
|
||||
d->trackPeak = (int)(log10((double)d->trackPeak) * 20 * 256 + .5);
|
||||
d->trackPeak = static_cast<int>(log10(static_cast<double>(d->trackPeak)) * 20 * 256 + .5);
|
||||
|
||||
if (d->albumPeak != 0)
|
||||
d->albumPeak = (int)(log10((double)d->albumPeak) * 20 * 256 + .5);
|
||||
d->albumPeak = static_cast<int>(log10(static_cast<double>(d->albumPeak)) * 20 * 256 + .5);
|
||||
|
||||
bool trueGapless = (gapless >> 31) & 0x0001;
|
||||
if(trueGapless) {
|
||||
|
@ -144,7 +144,7 @@ void AttachedPictureFrame::parseFields(const ByteVector &data)
|
||||
return;
|
||||
}
|
||||
|
||||
d->type = (TagLib::ID3v2::AttachedPictureFrame::Type)data[pos++];
|
||||
d->type = static_cast<TagLib::ID3v2::AttachedPictureFrame::Type>(data[pos++]);
|
||||
d->description = readStringField(data, d->textEncoding, &pos);
|
||||
|
||||
d->data = data.mid(pos);
|
||||
@ -205,7 +205,7 @@ void AttachedPictureFrameV22::parseFields(const ByteVector &data)
|
||||
d->mimeType = "image/" + fixedString;
|
||||
}
|
||||
|
||||
d->type = (TagLib::ID3v2::AttachedPictureFrame::Type)data[pos++];
|
||||
d->type = static_cast<TagLib::ID3v2::AttachedPictureFrame::Type>(data[pos++]);
|
||||
d->description = readStringField(data, d->textEncoding, &pos);
|
||||
|
||||
d->data = data.mid(pos);
|
||||
|
@ -109,7 +109,7 @@ void PopularimeterFrame::parseFields(const ByteVector &data)
|
||||
d->rating = 0;
|
||||
d->counter = 0;
|
||||
if(pos < size) {
|
||||
d->rating = (unsigned char)(data[pos++]);
|
||||
d->rating = static_cast<unsigned char>(data[pos++]);
|
||||
if(pos < size) {
|
||||
d->counter = data.toUInt(static_cast<unsigned int>(pos));
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ void RelativeVolumeFrame::parseFields(const ByteVector &data)
|
||||
|
||||
// Each channel is at least 4 bytes.
|
||||
|
||||
while(pos <= (int)data.size() - 4) {
|
||||
while(pos <= static_cast<int>(data.size()) - 4) {
|
||||
|
||||
ChannelType type = ChannelType(data[pos]);
|
||||
pos += 1;
|
||||
|
@ -336,7 +336,7 @@ ByteVector TableOfContentsFrame::renderFields() const
|
||||
if(d->isOrdered)
|
||||
flags += 1;
|
||||
data.append(flags);
|
||||
data.append((char)(entryCount()));
|
||||
data.append(static_cast<char>(entryCount()));
|
||||
ByteVectorList::ConstIterator it = d->childElements.begin();
|
||||
while(it != d->childElements.end()) {
|
||||
data.append(*it);
|
||||
|
@ -129,12 +129,12 @@ bool S3M::File::save()
|
||||
StringList lines = d->tag.comment().split("\n");
|
||||
// write comment as sample names:
|
||||
for(unsigned short i = 0; i < sampleCount; ++ i) {
|
||||
seek(96L + length + ((long)i << 1));
|
||||
seek(96L + length + (static_cast<long>(i) << 1));
|
||||
|
||||
unsigned short instrumentOffset = 0;
|
||||
if(!readU16L(instrumentOffset))
|
||||
return false;
|
||||
seek(((long)instrumentOffset << 4) + 48);
|
||||
seek((static_cast<long>(instrumentOffset) << 4) + 48);
|
||||
|
||||
if(i < lines.size())
|
||||
writeString(lines[i], 27);
|
||||
@ -214,10 +214,10 @@ void S3M::File::read(bool)
|
||||
// instead samples (SCRS).
|
||||
StringList comment;
|
||||
for(unsigned short i = 0; i < sampleCount; ++ i) {
|
||||
seek(96L + length + ((long)i << 1));
|
||||
seek(96L + length + (static_cast<long>(i) << 1));
|
||||
|
||||
READ_U16L_AS(sampleHeaderOffset);
|
||||
seek((long)sampleHeaderOffset << 4);
|
||||
seek(static_cast<long>(sampleHeaderOffset) << 4);
|
||||
|
||||
READ_BYTE_AS(sampleType);
|
||||
READ_STRING_AS(dosFileName, 13);
|
||||
|
@ -925,8 +925,8 @@ ByteVector ByteVector::fromBase64(const ByteVector & input)
|
||||
|
||||
ByteVector output(len);
|
||||
|
||||
const unsigned char * src = (const unsigned char*) input.data();
|
||||
unsigned char * dst = (unsigned char*) output.data();
|
||||
const unsigned char * src = reinterpret_cast<const unsigned char*>(input.data());
|
||||
unsigned char * dst = reinterpret_cast<unsigned char*>(output.data());
|
||||
|
||||
while(4 <= len) {
|
||||
|
||||
@ -976,7 +976,7 @@ ByteVector ByteVector::fromBase64(const ByteVector & input)
|
||||
|
||||
// Only return output if we processed all bytes
|
||||
if(len == 0) {
|
||||
output.resize(static_cast<unsigned int>(dst - (unsigned char*) output.data()));
|
||||
output.resize(static_cast<unsigned int>(dst - reinterpret_cast<unsigned char*>(output.data())));
|
||||
return output;
|
||||
}
|
||||
return ByteVector();
|
||||
|
@ -130,7 +130,7 @@ public:
|
||||
{
|
||||
ByteVector data = file.readBlock(std::min(m_size, limit));
|
||||
unsigned int count = data.size();
|
||||
int index = data.find((char) 0);
|
||||
int index = data.find(static_cast<char>(0));
|
||||
if(index > -1) {
|
||||
data.resize(index);
|
||||
}
|
||||
@ -534,7 +534,7 @@ void XM::File::read(bool)
|
||||
.u16L(bpmSpeed);
|
||||
|
||||
unsigned int count = header.read(*this, headerSize - 4U);
|
||||
unsigned int size = std::min(headerSize - 4U, (unsigned long)header.size());
|
||||
unsigned int size = std::min(headerSize - 4U, static_cast<unsigned long>(header.size()));
|
||||
|
||||
READ_ASSERT(count == size);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user