Skip to content

Commit 148cc9a

Browse files
committed
Fix conversion compiler warnings
Using a release build with GCC 14.2.0 and -Wextra -Wconversion -Wall. The generated binaries are not changed by this commit.
1 parent 88d6b18 commit 148cc9a

25 files changed

Lines changed: 51 additions & 49 deletions

taglib/ape/apeproperties.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ void APE::Properties::read(File *file, offset_t streamLength)
139139
if(d->sampleFrames > 0 && d->sampleRate > 0) {
140140
const auto length = static_cast<double>(d->sampleFrames) * 1000.0 / d->sampleRate;
141141
d->length = static_cast<int>(length + 0.5);
142-
d->bitrate = static_cast<int>(streamLength * 8.0 / length + 0.5);
142+
d->bitrate = static_cast<int>(static_cast<double>(streamLength) * 8.0 / length + 0.5);
143143
}
144144
}
145145

taglib/asf/asfattribute.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -302,16 +302,16 @@ ByteVector ASF::Attribute::render(const String &name, int kind) const
302302

303303
if(kind == 0) {
304304
data = renderString(name, true) +
305-
ByteVector::fromShort(static_cast<int>(d->type), false) +
306-
ByteVector::fromShort(data.size(), false) +
305+
ByteVector::fromShort(static_cast<short>(d->type), false) +
306+
ByteVector::fromShort(static_cast<short>(data.size()), false) +
307307
data;
308308
}
309309
else {
310310
ByteVector nameData = renderString(name);
311-
data = ByteVector::fromShort(kind == 2 ? d->language : 0, false) +
312-
ByteVector::fromShort(d->stream, false) +
313-
ByteVector::fromShort(nameData.size(), false) +
314-
ByteVector::fromShort(static_cast<int>(d->type), false) +
311+
data = ByteVector::fromShort(static_cast<short>(kind == 2 ? d->language : 0), false) +
312+
ByteVector::fromShort(static_cast<short>(d->stream), false) +
313+
ByteVector::fromShort(static_cast<short>(nameData.size()), false) +
314+
ByteVector::fromShort(static_cast<short>(d->type), false) +
315315
ByteVector::fromUInt(data.size(), false) +
316316
nameData +
317317
data;

taglib/asf/asffile.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,8 @@ void ASF::File::FilePrivate::FilePropertiesObject::parse(ASF::File *file, long l
221221

222222
const long long duration = data.toLongLong(40, false);
223223
const long long preroll = data.toLongLong(56, false);
224-
file->d->properties->setLengthInMilliseconds(static_cast<int>(duration / 10000.0 - preroll + 0.5));
224+
file->d->properties->setLengthInMilliseconds(
225+
static_cast<int>(static_cast<double>(duration) / 10000.0 - static_cast<double>(preroll) + 0.5));
225226
}
226227

227228
ByteVector ASF::File::FilePrivate::StreamPropertiesObject::guid() const
@@ -271,11 +272,11 @@ ByteVector ASF::File::FilePrivate::ContentDescriptionObject::render(ASF::File *f
271272
const ByteVector v4 = renderString(file->d->tag->comment());
272273
const ByteVector v5 = renderString(file->d->tag->rating());
273274
data.clear();
274-
data.append(ByteVector::fromShort(v1.size(), false));
275-
data.append(ByteVector::fromShort(v2.size(), false));
276-
data.append(ByteVector::fromShort(v3.size(), false));
277-
data.append(ByteVector::fromShort(v4.size(), false));
278-
data.append(ByteVector::fromShort(v5.size(), false));
275+
data.append(ByteVector::fromShort(static_cast<short>(v1.size()), false));
276+
data.append(ByteVector::fromShort(static_cast<short>(v2.size()), false));
277+
data.append(ByteVector::fromShort(static_cast<short>(v3.size()), false));
278+
data.append(ByteVector::fromShort(static_cast<short>(v4.size()), false));
279+
data.append(ByteVector::fromShort(static_cast<short>(v5.size()), false));
279280
data.append(v1);
280281
data.append(v2);
281282
data.append(v3);
@@ -302,7 +303,7 @@ void ASF::File::FilePrivate::ExtendedContentDescriptionObject::parse(ASF::File *
302303
ByteVector ASF::File::FilePrivate::ExtendedContentDescriptionObject::render(ASF::File *file)
303304
{
304305
data.clear();
305-
data.append(ByteVector::fromShort(attributeData.size(), false));
306+
data.append(ByteVector::fromShort(static_cast<short>(attributeData.size()), false));
306307
data.append(attributeData.toByteVector(""));
307308
return BaseObject::render(file);
308309
}
@@ -325,7 +326,7 @@ void ASF::File::FilePrivate::MetadataObject::parse(ASF::File *file, long long /*
325326
ByteVector ASF::File::FilePrivate::MetadataObject::render(ASF::File *file)
326327
{
327328
data.clear();
328-
data.append(ByteVector::fromShort(attributeData.size(), false));
329+
data.append(ByteVector::fromShort(static_cast<short>(attributeData.size()), false));
329330
data.append(attributeData.toByteVector(""));
330331
return BaseObject::render(file);
331332
}
@@ -348,7 +349,7 @@ void ASF::File::FilePrivate::MetadataLibraryObject::parse(ASF::File *file, long
348349
ByteVector ASF::File::FilePrivate::MetadataLibraryObject::render(ASF::File *file)
349350
{
350351
data.clear();
351-
data.append(ByteVector::fromShort(attributeData.size(), false));
352+
data.append(ByteVector::fromShort(static_cast<short>(attributeData.size()), false));
352353
data.append(attributeData.toByteVector(""));
353354
return BaseObject::render(file);
354355
}

taglib/asf/asfutils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ namespace TagLib
9090
{
9191
ByteVector data = str.data(String::UTF16LE) + ByteVector::fromShort(0, false);
9292
if(includeLength) {
93-
data = ByteVector::fromShort(data.size(), false) + data;
93+
data = ByteVector::fromShort(static_cast<short>(data.size()), false) + data;
9494
}
9595
return data;
9696
}

taglib/dsdiff/dsdiffproperties.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ DSDIFF::Properties::Properties(unsigned int sampleRate,
5858
d->sampleRate = sampleRate;
5959
d->bitrate = bitrate;
6060
d->length = d->sampleRate > 0
61-
? static_cast<int>(d->sampleCount * 1000.0 / d->sampleRate + 0.5)
61+
? static_cast<int>(static_cast<double>(d->sampleCount) * 1000.0 / d->sampleRate + 0.5)
6262
: 0;
6363
}
6464

taglib/dsf/dsffile.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ bool DSF::File::isSupported(IOStream *stream)
5959
return id.startsWith("DSD ");
6060
}
6161

62-
DSF::File::File(FileName file, bool readProperties,
62+
DSF::File::File(FileName file, bool,
6363
AudioProperties::ReadStyle propertiesStyle,
6464
ID3v2::FrameFactory *frameFactory) :
6565
TagLib::File(file),
@@ -69,7 +69,7 @@ DSF::File::File(FileName file, bool readProperties,
6969
read(propertiesStyle);
7070
}
7171

72-
DSF::File::File(IOStream *stream, bool readProperties,
72+
DSF::File::File(IOStream *stream, bool,
7373
AudioProperties::ReadStyle propertiesStyle,
7474
ID3v2::FrameFactory *frameFactory) :
7575
TagLib::File(stream),

taglib/dsf/dsfproperties.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,6 @@ void DSF::Properties::read(const ByteVector &data)
129129
d->bitrate = static_cast<unsigned int>(
130130
d->samplingFrequency * d->bitsPerSample * d->channelNum / 1000.0 + 0.5);
131131
d->length = d->samplingFrequency > 0
132-
? static_cast<unsigned int>(d->sampleCount * 1000.0 / d->samplingFrequency + 0.5)
132+
? static_cast<unsigned int>(static_cast<double>(d->sampleCount) * 1000.0 / d->samplingFrequency + 0.5)
133133
: 0;
134134
}

taglib/fileref.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ class FileRef::FileRefPrivate
321321
return !file || !file->isValid();
322322
}
323323

324-
bool isNullWithDebugMessage(const String &methodName) const
324+
bool isNullWithDebugMessage([[maybe_unused]] const String &methodName) const
325325
{
326326
if(isNull()) {
327327
debug("FileRef::" + methodName + "() - Called without a valid file.");

taglib/flac/flacfile.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ bool FLAC::File::save()
274274
it = d->blocks.erase(it);
275275
continue;
276276
}
277-
blockHeader[0] = (*it)->code();
277+
blockHeader[0] = static_cast<char>((*it)->code());
278278
data.append(blockHeader);
279279
data.append(blockData);
280280
++it;

taglib/flac/flacproperties.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ void FLAC::Properties::read(const ByteVector &data, offset_t streamLength)
134134
if(d->sampleFrames > 0 && d->sampleRate > 0) {
135135
const auto length = static_cast<double>(d->sampleFrames) * 1000.0 / d->sampleRate;
136136
d->length = static_cast<int>(length + 0.5);
137-
d->bitrate = static_cast<int>(streamLength * 8.0 / length + 0.5);
137+
d->bitrate = static_cast<int>(static_cast<double>(streamLength) * 8.0 / length + 0.5);
138138
}
139139

140140
if(data.size() >= pos + 16)

0 commit comments

Comments
 (0)