From 7bcfb960989eea46e7e8636fa4cd7b67118f7674 Mon Sep 17 00:00:00 2001 From: Urs Fleisch Date: Sat, 20 Jan 2024 23:30:40 +0100 Subject: [PATCH] Inspection: Code redundancies --- taglib/ape/apefile.cpp | 10 +++---- taglib/ape/apeitem.cpp | 2 +- taglib/ape/apeproperties.cpp | 2 +- taglib/asf/asfattribute.cpp | 6 ++--- taglib/asf/asffile.cpp | 7 +++-- taglib/dsdiff/dsdifffile.cpp | 20 +++++++------- taglib/dsdiff/dsdiffproperties.cpp | 10 +++---- taglib/dsdiff/dsdiffproperties.h | 4 +-- taglib/dsf/dsfproperties.cpp | 2 +- taglib/fileref.cpp | 4 +-- taglib/flac/flacfile.cpp | 16 +++++------ taglib/mod/modtag.cpp | 2 +- taglib/mp4/mp4atom.cpp | 27 +++++++++---------- taglib/mp4/mp4file.cpp | 2 +- taglib/mp4/mp4itemfactory.cpp | 20 ++++++-------- taglib/mp4/mp4properties.cpp | 4 +-- taglib/mpc/mpcfile.cpp | 10 +++---- taglib/mpc/mpcproperties.cpp | 2 +- .../id3v2/frames/textidentificationframe.cpp | 2 +- taglib/mpeg/id3v2/id3v2framefactory.cpp | 2 +- taglib/mpeg/id3v2/id3v2tag.cpp | 2 +- taglib/mpeg/mpegfile.cpp | 12 ++++----- taglib/mpeg/mpegheader.cpp | 12 ++++----- taglib/mpeg/mpegproperties.cpp | 2 +- taglib/mpeg/xingheader.cpp | 2 +- taglib/ogg/flac/oggflacfile.cpp | 2 +- taglib/ogg/oggpage.cpp | 6 ++--- taglib/ogg/oggpageheader.cpp | 2 +- taglib/ogg/opus/opusfile.cpp | 2 +- taglib/ogg/opus/opusproperties.cpp | 2 +- taglib/ogg/speex/speexfile.cpp | 2 +- taglib/ogg/vorbis/vorbisfile.cpp | 2 +- taglib/riff/aiff/aifffile.cpp | 2 +- taglib/riff/aiff/aiffproperties.cpp | 2 +- taglib/riff/rifffile.cpp | 2 +- taglib/riff/wav/wavfile.cpp | 2 +- taglib/tag.cpp | 24 ++++++++--------- taglib/tagutils.cpp | 2 +- taglib/toolkit/tbytevector.cpp | 24 ++++++++--------- taglib/toolkit/tbytevectorstream.h | 2 -- taglib/toolkit/tfile.cpp | 4 +-- taglib/toolkit/tfilestream.cpp | 2 +- taglib/toolkit/tpropertymap.cpp | 4 +-- taglib/toolkit/tstring.cpp | 12 ++++----- taglib/toolkit/tvariant.cpp | 2 +- taglib/toolkit/tzlib.cpp | 2 +- taglib/trueaudio/trueaudiofile.cpp | 10 +++---- taglib/wavpack/wavpackfile.cpp | 8 +++--- tests/main.cpp | 2 +- tests/test_map.cpp | 2 +- tests/test_xiphcomment.cpp | 8 +++--- 51 files changed, 154 insertions(+), 164 deletions(-) diff --git a/taglib/ape/apefile.cpp b/taglib/ape/apefile.cpp index 5552c957..2784c0e7 100644 --- a/taglib/ape/apefile.cpp +++ b/taglib/ape/apefile.cpp @@ -75,7 +75,7 @@ bool APE::File::isSupported(IOStream *stream) // An APE file has an ID "MAC " somewhere. An ID3v2 tag may precede. const ByteVector buffer = Utils::readHeader(stream, bufferSize(), true); - return (buffer.find("MAC ") >= 0); + return buffer.find("MAC ") >= 0; } //////////////////////////////////////////////////////////////////////////////// @@ -178,7 +178,7 @@ bool APE::File::save() insert(data, d->APELocation, d->APESize); if(d->ID3v1Location >= 0) - d->ID3v1Location += (static_cast(data.size()) - d->APESize); + d->ID3v1Location += static_cast(data.size()) - d->APESize; d->APESize = data.size(); } @@ -224,12 +224,12 @@ void APE::File::strip(int tags) bool APE::File::hasAPETag() const { - return (d->APELocation >= 0); + return d->APELocation >= 0; } bool APE::File::hasID3v1Tag() const { - return (d->ID3v1Location >= 0); + return d->ID3v1Location >= 0; } //////////////////////////////////////////////////////////////////////////////// @@ -283,7 +283,7 @@ void APE::File::read(bool readProperties) if(d->ID3v2Location >= 0) { seek(d->ID3v2Location + d->ID3v2Size); - streamLength -= (d->ID3v2Location + d->ID3v2Size); + streamLength -= d->ID3v2Location + d->ID3v2Size; } else { seek(0); diff --git a/taglib/ape/apeitem.cpp b/taglib/ape/apeitem.cpp index 4e9adac7..a5c8099e 100644 --- a/taglib/ape/apeitem.cpp +++ b/taglib/ape/apeitem.cpp @@ -241,7 +241,7 @@ void APE::Item::parse(const ByteVector &data) ByteVector APE::Item::render() const { ByteVector data; - unsigned int flags = ((d->readOnly) ? 1 : 0) | (d->type << 1); + unsigned int flags = (d->readOnly ? 1 : 0) | (d->type << 1); ByteVector val; if(isEmpty()) diff --git a/taglib/ape/apeproperties.cpp b/taglib/ape/apeproperties.cpp index 61dda605..79046337 100644 --- a/taglib/ape/apeproperties.cpp +++ b/taglib/ape/apeproperties.cpp @@ -154,7 +154,7 @@ void APE::Properties::analyzeCurrent(File *file) } if(const unsigned int descriptorBytes = descriptor.toUInt(0, false); - (descriptorBytes - 52) > 0) + descriptorBytes - 52 > 0) file->seek(descriptorBytes - 52, File::Current); // Read the header diff --git a/taglib/asf/asfattribute.cpp b/taglib/asf/asfattribute.cpp index 867770ef..c5c93d24 100644 --- a/taglib/asf/asfattribute.cpp +++ b/taglib/asf/asfattribute.cpp @@ -154,7 +154,7 @@ unsigned int ASF::Attribute::toUInt() const unsigned long long ASF::Attribute::toULongLong() const { - return static_cast(d->numericValue); + return d->numericValue; } ASF::Picture ASF::Attribute::toPicture() const @@ -199,10 +199,10 @@ String ASF::Attribute::parse(ASF::File &file, int kind) case BoolType: if(kind == 0) { - d->numericValue = (readDWORD(&file) != 0); + d->numericValue = readDWORD(&file) != 0; } else { - d->numericValue = (readWORD(&file) != 0); + d->numericValue = readWORD(&file) != 0; } break; diff --git a/taglib/asf/asffile.cpp b/taglib/asf/asffile.cpp index 8f2f74e8..23931c67 100644 --- a/taglib/asf/asffile.cpp +++ b/taglib/asf/asffile.cpp @@ -472,7 +472,7 @@ bool ASF::File::isSupported(IOStream *stream) // An ASF file has to start with the designated GUID. const ByteVector id = Utils::readHeader(stream, 16, false); - return (id == headerGuid); + return id == headerGuid; } //////////////////////////////////////////////////////////////////////////////// @@ -564,8 +564,8 @@ bool ASF::File::save() bool inMetadataObject = false; for(const auto &attribute : attributes) { - const bool largeValue = (attribute.dataSize() > 65535); - const bool guid = (attribute.type() == Attribute::GuidType); + const bool largeValue = attribute.dataSize() > 65535; + const bool guid = attribute.type() == Attribute::GuidType; if(!inExtendedContentDescriptionObject && !guid && !largeValue && attribute.language() == 0 && attribute.stream() == 0) { d->extendedContentDescriptionObject->attributeData.append(attribute.render(name)); @@ -681,6 +681,5 @@ void ASF::File::read() if(!filePropertiesObject || !streamPropertiesObject) { debug("ASF::File::read(): Missing mandatory header objects."); setValid(false); - return; } } diff --git a/taglib/dsdiff/dsdifffile.cpp b/taglib/dsdiff/dsdifffile.cpp index 7353fbe1..d49e22e0 100644 --- a/taglib/dsdiff/dsdifffile.cpp +++ b/taglib/dsdiff/dsdifffile.cpp @@ -130,7 +130,7 @@ bool DSDIFF::File::isSupported(IOStream *stream) { // A DSDIFF file has to start with "FRM8????????DSD ". const ByteVector id = Utils::readHeader(stream, 16, false); - return (id.startsWith("FRM8") && id.containsAt("DSD ", 12)); + return id.startsWith("FRM8") && id.containsAt("DSD ", 12); } //////////////////////////////////////////////////////////////////////////////// @@ -429,7 +429,7 @@ void DSDIFF::File::removeChildChunk(unsigned int i, unsigned int childChunkNum) // Update the internal offsets // For child chunks - if((i + 1) < childChunks.size()) { + if(i + 1 < childChunks.size()) { childChunks[i + 1].offset = childChunks[i].offset; for(unsigned int c = i + 2; c < childChunks.size(); ++c) childChunks[c].offset = childChunks[c - 1].offset + 12 @@ -555,13 +555,13 @@ void DSDIFF::File::setChildChunkData(const ByteVector &name, // Now add the chunk to the file unsigned long long nextRootChunkIdx = length(); - if((d->childChunkIndex[childChunkNum] + 1) < static_cast(d->chunks.size())) + if(d->childChunkIndex[childChunkNum] + 1 < static_cast(d->chunks.size())) nextRootChunkIdx = d->chunks[d->childChunkIndex[childChunkNum] + 1].offset - 12; writeChunk(name, data, offset, static_cast( nextRootChunkIdx > offset ? nextRootChunkIdx - offset : 0), - (offset & 1) ? 1 : 0); + offset & 1 ? 1 : 0); // For root chunks @@ -571,7 +571,7 @@ void DSDIFF::File::setChildChunkData(const ByteVector &name, chunk.name = name; chunk.size = data.size(); chunk.offset = offset + 12; - chunk.padding = (data.size() & 0x01) ? 1 : 0; + chunk.padding = data.size() & 0x01 ? 1 : 0; childChunks.push_back(chunk); } @@ -645,7 +645,7 @@ void DSDIFF::File::read(bool readProperties, Properties::ReadStyle propertiesSty chunk.padding = 0; if(offset_t uPosNotPadded = tell(); (uPosNotPadded & 0x01) != 0) { if(ByteVector iByte = readBlock(1); - (iByte.size() != 1) || (iByte[0] != 0)) + iByte.size() != 1 || iByte[0] != 0) // Not well formed, re-seek seek(uPosNotPadded, Beginning); else @@ -705,7 +705,7 @@ void DSDIFF::File::read(bool readProperties, Properties::ReadStyle propertiesSty // Check padding if(offset_t uPosNotPadded = tell(); (uPosNotPadded & 0x01) != 0) { if(ByteVector iByte = readBlock(1); - (iByte.size() != 1) || (iByte[0] != 0)) + iByte.size() != 1 || iByte[0] != 0) // Not well formed, re-seek seek(uPosNotPadded, Beginning); } @@ -745,7 +745,7 @@ void DSDIFF::File::read(bool readProperties, Properties::ReadStyle propertiesSty chunk.padding = 0; if(offset_t uPosNotPadded = tell(); (uPosNotPadded & 0x01) != 0) { if(ByteVector iByte = readBlock(1); - (iByte.size() != 1) || (iByte[0] != 0)) + iByte.size() != 1 || iByte[0] != 0) // Not well formed, re-seek seek(uPosNotPadded, Beginning); else @@ -793,7 +793,7 @@ void DSDIFF::File::read(bool readProperties, Properties::ReadStyle propertiesSty if(offset_t uPosNotPadded = tell(); (uPosNotPadded & 0x01) != 0) { if(ByteVector iByte = readBlock(1); - (iByte.size() != 1) || (iByte[0] != 0)) + iByte.size() != 1 || iByte[0] != 0) // Not well formed, re-seek seek(uPosNotPadded, Beginning); else @@ -894,7 +894,7 @@ void DSDIFF::File::read(bool readProperties, Properties::ReadStyle propertiesSty int bitrate = 0; if(lengthDSDSamplesTimeChannels > 0) bitrate = static_cast( - (audioDataSizeinBytes * 8 * sampleRate) / lengthDSDSamplesTimeChannels / 1000); + audioDataSizeinBytes * 8 * sampleRate / lengthDSDSamplesTimeChannels / 1000); d->properties = std::make_unique(sampleRate, channels, lengthDSDSamplesTimeChannels, bitrate, propertiesStyle); diff --git a/taglib/dsdiff/dsdiffproperties.cpp b/taglib/dsdiff/dsdiffproperties.cpp index ef1ede0d..0585fe48 100644 --- a/taglib/dsdiff/dsdiffproperties.cpp +++ b/taglib/dsdiff/dsdiffproperties.cpp @@ -44,10 +44,10 @@ public: // public members //////////////////////////////////////////////////////////////////////////////// -DSDIFF::Properties::Properties(const unsigned int sampleRate, - const unsigned short channels, - const unsigned long long samplesCount, - const int bitrate, +DSDIFF::Properties::Properties(unsigned int sampleRate, + unsigned short channels, + unsigned long long samplesCount, + int bitrate, ReadStyle style) : AudioProperties(style), d(std::make_unique()) @@ -58,7 +58,7 @@ DSDIFF::Properties::Properties(const 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(d->sampleCount * 1000.0 / d->sampleRate + 0.5) : 0; } diff --git a/taglib/dsdiff/dsdiffproperties.h b/taglib/dsdiff/dsdiffproperties.h index 98b21914..f2d6afc9 100644 --- a/taglib/dsdiff/dsdiffproperties.h +++ b/taglib/dsdiff/dsdiffproperties.h @@ -48,8 +48,8 @@ namespace TagLib { * Create an instance of DSDIFF::Properties with the data read from the * ByteVector \a data. */ - Properties(const unsigned int sampleRate, const unsigned short channels, - const unsigned long long samplesCount, const int bitrate, + Properties(unsigned int sampleRate, unsigned short channels, + unsigned long long samplesCount, int bitrate, ReadStyle style); /*! diff --git a/taglib/dsf/dsfproperties.cpp b/taglib/dsf/dsfproperties.cpp index 678fce2b..0556d823 100644 --- a/taglib/dsf/dsfproperties.cpp +++ b/taglib/dsf/dsfproperties.cpp @@ -127,7 +127,7 @@ void DSF::Properties::read(const ByteVector &data) d->blockSizePerChannel = data.toUInt(32U,false); d->bitrate = static_cast( - (d->samplingFrequency * d->bitsPerSample * d->channelNum) / 1000.0 + 0.5); + 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) : 0; diff --git a/taglib/fileref.cpp b/taglib/fileref.cpp index 1b8b197c..c59b65f3 100644 --- a/taglib/fileref.cpp +++ b/taglib/fileref.cpp @@ -456,12 +456,12 @@ void FileRef::swap(FileRef &ref) noexcept bool FileRef::operator==(const FileRef &ref) const { - return (ref.d->file == d->file); + return ref.d->file == d->file; } bool FileRef::operator!=(const FileRef &ref) const { - return (ref.d->file != d->file); + return ref.d->file != d->file; } //////////////////////////////////////////////////////////////////////////////// diff --git a/taglib/flac/flacfile.cpp b/taglib/flac/flacfile.cpp index c94713e4..c890a9a5 100644 --- a/taglib/flac/flacfile.cpp +++ b/taglib/flac/flacfile.cpp @@ -86,7 +86,7 @@ bool FLAC::File::isSupported(IOStream *stream) // A FLAC file has an ID "fLaC" somewhere. An ID3v2 tag may precede. const ByteVector buffer = Utils::readHeader(stream, bufferSize(), true); - return (buffer.find("fLaC") >= 0); + return buffer.find("fLaC") >= 0; } //////////////////////////////////////////////////////////////////////////////// @@ -301,10 +301,10 @@ bool FLAC::File::save() insert(data, d->flacStart, originalLength); - d->streamStart += (static_cast(data.size()) - originalLength); + d->streamStart += static_cast(data.size()) - originalLength; if(d->ID3v1Location >= 0) - d->ID3v1Location += (static_cast(data.size()) - originalLength); + d->ID3v1Location += static_cast(data.size()) - originalLength; // Update ID3 tags @@ -318,11 +318,11 @@ bool FLAC::File::save() data = ID3v2Tag()->render(); insert(data, d->ID3v2Location, d->ID3v2OriginalSize); - d->flacStart += (static_cast(data.size()) - d->ID3v2OriginalSize); - d->streamStart += (static_cast(data.size()) - d->ID3v2OriginalSize); + d->flacStart += static_cast(data.size()) - d->ID3v2OriginalSize; + d->streamStart += static_cast(data.size()) - d->ID3v2OriginalSize; if(d->ID3v1Location >= 0) - d->ID3v1Location += (static_cast(data.size()) - d->ID3v2OriginalSize); + d->ID3v1Location += static_cast(data.size()) - d->ID3v2OriginalSize; d->ID3v2OriginalSize = data.size(); } @@ -447,12 +447,12 @@ bool FLAC::File::hasXiphComment() const bool FLAC::File::hasID3v1Tag() const { - return (d->ID3v1Location >= 0); + return d->ID3v1Location >= 0; } bool FLAC::File::hasID3v2Tag() const { - return (d->ID3v2Location >= 0); + return d->ID3v2Location >= 0; } //////////////////////////////////////////////////////////////////////////////// diff --git a/taglib/mod/modtag.cpp b/taglib/mod/modtag.cpp index 0779842d..15f9a68e 100644 --- a/taglib/mod/modtag.cpp +++ b/taglib/mod/modtag.cpp @@ -128,7 +128,7 @@ PropertyMap Mod::Tag::properties() const PropertyMap properties; properties["TITLE"] = d->title; properties["COMMENT"] = d->comment; - if(!(d->trackerName.isEmpty())) + if(!d->trackerName.isEmpty()) properties["TRACKERNAME"] = d->trackerName; return properties; } diff --git a/taglib/mp4/mp4atom.cpp b/taglib/mp4/mp4atom.cpp index c23b3248..c8ca88c1 100644 --- a/taglib/mp4/mp4atom.cpp +++ b/taglib/mp4/mp4atom.cpp @@ -271,28 +271,25 @@ namespace } } // namespace -bool MP4::Atoms::checkRootLevelAtoms() -{ +bool MP4::Atoms::checkRootLevelAtoms() { bool moovValid = false; for(auto it = d->atoms.begin(); it != d->atoms.end(); ++it) { - bool invalid = (*it)->length() == 0 || !checkValid((*it)->children()); - if(!moovValid && !invalid && (*it)->name() == "moov") { + bool invalid = (*it)->length() == 0 || !checkValid((*it)->children()); + if(!moovValid && !invalid && (*it)->name() == "moov") { moovValid = true; - } - if(invalid) { + } + if(invalid) { if(moovValid && (*it)->name() != "moof") { - // Only the root level atoms "moov" and (if present) "moof" are - // modified. If they are valid, ignore following invalid root level - // atoms as trailing garbage. - while(it != d->atoms.end()) { + // Only the root level atoms "moov" and (if present) "moof" are + // modified. If they are valid, ignore following invalid root level + // atoms as trailing garbage. + while(it != d->atoms.end()) { delete *it; it = d->atoms.erase(it); - } - return true; - } - else { - return false; + } + return true; } + return false; } } diff --git a/taglib/mp4/mp4file.cpp b/taglib/mp4/mp4file.cpp index 1c0ae8c6..cf760be2 100644 --- a/taglib/mp4/mp4file.cpp +++ b/taglib/mp4/mp4file.cpp @@ -174,5 +174,5 @@ MP4::File::strip(int tags) bool MP4::File::hasMP4Tag() const { - return (d->atoms->find("moov", "udta", "meta", "ilst") != nullptr); + return d->atoms->find("moov", "udta", "meta", "ilst") != nullptr; } diff --git a/taglib/mp4/mp4itemfactory.cpp b/taglib/mp4/mp4itemfactory.cpp index 8a097d1e..667fd558 100644 --- a/taglib/mp4/mp4itemfactory.cpp +++ b/taglib/mp4/mp4itemfactory.cpp @@ -95,9 +95,8 @@ ByteVector ItemFactory::renderItem( if(itemName.startsWith("----")) { return renderFreeForm(itemName, item); } - else { - const ByteVector name = itemName.data(String::Latin1); - switch(handlerTypeForName(name)) { + const ByteVector name = itemName.data(String::Latin1); + switch(handlerTypeForName(name)) { case ItemHandlerType::Unknown: debug("MP4: Unknown item name \"" + name + "\""); break; @@ -127,7 +126,6 @@ ByteVector ItemFactory::renderItem( return renderText(name, item, TypeImplicit); case ItemHandlerType::Text: return renderText(name, item); - } } return ByteVector(); } @@ -573,15 +571,13 @@ std::pair ItemFactory::parseFreeForm( item.setAtomDataType(type); return {name, item}; } - else { - ByteVectorList value; - for(auto it = itBegin; it != data.end(); ++it) { - value.append(it->data); - } - Item item(value); - item.setAtomDataType(type); - return {name, item}; + ByteVectorList value; + for(auto it = itBegin; it != data.end(); ++it) { + value.append(it->data); } + Item item(value); + item.setAtomDataType(type); + return {name, item}; } return {atom->name(), Item()}; } diff --git a/taglib/mp4/mp4properties.cpp b/taglib/mp4/mp4properties.cpp index 850797e7..d3d0c207 100644 --- a/taglib/mp4/mp4properties.cpp +++ b/taglib/mp4/mp4properties.cpp @@ -228,7 +228,7 @@ MP4::Properties::read(File *file, const Atoms *atoms) } else { d->bitrate = static_cast( - (calculateMdatLength(atoms->atoms()) * 8) / d->length); + calculateMdatLength(atoms->atoms()) * 8 / d->length); } } } @@ -245,7 +245,7 @@ MP4::Properties::read(File *file, const Atoms *atoms) // There are files which do not contain a nominal bitrate, e.g. those // generated by refalac64.exe. Calculate the bitrate from the audio // data size (mdat atoms) and the duration. - d->bitrate = static_cast((calculateMdatLength(atoms->atoms()) * 8) / d->length); + d->bitrate = static_cast(calculateMdatLength(atoms->atoms()) * 8 / d->length); } } } diff --git a/taglib/mpc/mpcfile.cpp b/taglib/mpc/mpcfile.cpp index c12b7d7e..6dc63603 100644 --- a/taglib/mpc/mpcfile.cpp +++ b/taglib/mpc/mpcfile.cpp @@ -68,7 +68,7 @@ bool MPC::File::isSupported(IOStream *stream) // have keys to do a quick check. An ID3v2 tag may precede. const ByteVector id = Utils::readHeader(stream, 4, true); - return (id == "MPCK" || id.startsWith("MP+")); + return id == "MPCK" || id.startsWith("MP+"); } //////////////////////////////////////////////////////////////////////////////// @@ -186,7 +186,7 @@ bool MPC::File::save() insert(data, d->APELocation, d->APESize); if(d->ID3v1Location >= 0) - d->ID3v1Location += (static_cast(data.size()) - d->APESize); + d->ID3v1Location += static_cast(data.size()) - d->APESize; d->APESize = data.size(); } @@ -236,12 +236,12 @@ void MPC::File::strip(int tags) bool MPC::File::hasID3v1Tag() const { - return (d->ID3v1Location >= 0); + return d->ID3v1Location >= 0; } bool MPC::File::hasAPETag() const { - return (d->APELocation >= 0); + return d->APELocation >= 0; } //////////////////////////////////////////////////////////////////////////////// @@ -295,7 +295,7 @@ void MPC::File::read(bool readProperties) if(d->ID3v2Location >= 0) { seek(d->ID3v2Location + d->ID3v2Size); - streamLength -= (d->ID3v2Location + d->ID3v2Size); + streamLength -= d->ID3v2Location + d->ID3v2Size; } else { seek(0); diff --git a/taglib/mpc/mpcproperties.cpp b/taglib/mpc/mpcproperties.cpp index daf5f9c8..d2a535d1 100644 --- a/taglib/mpc/mpcproperties.cpp +++ b/taglib/mpc/mpcproperties.cpp @@ -162,7 +162,7 @@ namespace do { tmp = data[pos++]; size = (size << 7) | (tmp & 0x7F); - } while((tmp & 0x80) && (pos < data.size())); + } while((tmp & 0x80) && pos < data.size()); return size; } diff --git a/taglib/mpeg/id3v2/frames/textidentificationframe.cpp b/taglib/mpeg/id3v2/frames/textidentificationframe.cpp index 739b2b6f..aa78d563 100644 --- a/taglib/mpeg/id3v2/frames/textidentificationframe.cpp +++ b/taglib/mpeg/id3v2/frames/textidentificationframe.cpp @@ -287,7 +287,7 @@ ByteVector TextIdentificationFrame::renderFields() const if(it != d->fieldList.cbegin()) v.append(textDelimiter(encoding)); - v.append((*it).data(encoding)); + v.append(it->data(encoding)); } return v; diff --git a/taglib/mpeg/id3v2/id3v2framefactory.cpp b/taglib/mpeg/id3v2/id3v2framefactory.cpp index 073704be..f194aca3 100644 --- a/taglib/mpeg/id3v2/id3v2framefactory.cpp +++ b/taglib/mpeg/id3v2/id3v2framefactory.cpp @@ -553,7 +553,7 @@ Frame *FrameFactory::createFrameForProperty(const String &key, const StringList auto frame = new TextIdentificationFrame(frameID, String::UTF8); frame->setText(values); return frame; - } if((frameID[0] == 'W') && (values.size() == 1)){ // URL frame (not WXXX); support only one value + } if(frameID[0] == 'W' && values.size() == 1){ // URL frame (not WXXX); support only one value auto frame = new UrlLinkFrame(frameID); frame->setUrl(values.front()); return frame; diff --git a/taglib/mpeg/id3v2/id3v2tag.cpp b/taglib/mpeg/id3v2/id3v2tag.cpp index cb6ec1c2..4f8390ee 100644 --- a/taglib/mpeg/id3v2/id3v2tag.cpp +++ b/taglib/mpeg/id3v2/id3v2tag.cpp @@ -300,7 +300,7 @@ bool ID3v2::Tag::isEmpty() const Header *ID3v2::Tag::header() const { - return &(d->header); + return &d->header; } ExtendedHeader *ID3v2::Tag::extendedHeader() const diff --git a/taglib/mpeg/mpegfile.cpp b/taglib/mpeg/mpegfile.cpp index e0b957e9..d0a816af 100644 --- a/taglib/mpeg/mpegfile.cpp +++ b/taglib/mpeg/mpegfile.cpp @@ -238,10 +238,10 @@ bool MPEG::File::save(int tags, StripTags strip, ID3v2::Version version, Duplica insert(data, d->ID3v2Location, d->ID3v2OriginalSize); if(d->APELocation >= 0) - d->APELocation += (static_cast(data.size()) - d->ID3v2OriginalSize); + d->APELocation += static_cast(data.size()) - d->ID3v2OriginalSize; if(d->ID3v1Location >= 0) - d->ID3v1Location += (static_cast(data.size()) - d->ID3v2OriginalSize); + d->ID3v1Location += static_cast(data.size()) - d->ID3v2OriginalSize; d->ID3v2OriginalSize = data.size(); } @@ -294,7 +294,7 @@ bool MPEG::File::save(int tags, StripTags strip, ID3v2::Version version, Duplica insert(data, d->APELocation, d->APEOriginalSize); if(d->ID3v1Location >= 0) - d->ID3v1Location += (static_cast(data.size()) - d->APEOriginalSize); + d->ID3v1Location += static_cast(data.size()) - d->APEOriginalSize; d->APEOriginalSize = data.size(); } @@ -445,17 +445,17 @@ offset_t MPEG::File::lastFrameOffset() bool MPEG::File::hasID3v1Tag() const { - return (d->ID3v1Location >= 0); + return d->ID3v1Location >= 0; } bool MPEG::File::hasID3v2Tag() const { - return (d->ID3v2Location >= 0); + return d->ID3v2Location >= 0; } bool MPEG::File::hasAPETag() const { - return (d->APELocation >= 0); + return d->APELocation >= 0; } //////////////////////////////////////////////////////////////////////////////// diff --git a/taglib/mpeg/mpegheader.cpp b/taglib/mpeg/mpegheader.cpp index 2439e690..c20b89d3 100644 --- a/taglib/mpeg/mpegheader.cpp +++ b/taglib/mpeg/mpegheader.cpp @@ -210,7 +210,7 @@ void MPEG::Header::parse(File *file, offset_t offset, bool checkLength) } } - d->protectionEnabled = (static_cast(data[1] & 0x01) == 0); + d->protectionEnabled = static_cast(data[1] & 0x01) == 0; if(isADTS()) { static constexpr std::array sampleRates { @@ -262,8 +262,8 @@ void MPEG::Header::parse(File *file, offset_t offset, bool checkLength) }, }; - const int versionIndex = (d->version == Version1) ? 0 : 1; - const int layerIndex = (d->layer > 0) ? d->layer - 1 : 0; + const int versionIndex = d->version == Version1 ? 0 : 1; + const int layerIndex = d->layer > 0 ? d->layer - 1 : 0; // The bitrate index is encoded as the first 4 bits of the 3rd byte, // i.e. 1111xxxx @@ -300,9 +300,9 @@ void MPEG::Header::parse(File *file, offset_t offset, bool checkLength) // TODO: Add mode extension for completeness - d->isOriginal = ((static_cast(data[3]) & 0x04) != 0); - d->isCopyrighted = ((static_cast(data[3]) & 0x08) != 0); - d->isPadded = ((static_cast(data[2]) & 0x02) != 0); + d->isOriginal = (static_cast(data[3]) & 0x04) != 0; + d->isCopyrighted = (static_cast(data[3]) & 0x08) != 0; + d->isPadded = (static_cast(data[2]) & 0x02) != 0; // Samples per frame diff --git a/taglib/mpeg/mpegproperties.cpp b/taglib/mpeg/mpegproperties.cpp index 36095373..dfbddc26 100644 --- a/taglib/mpeg/mpegproperties.cpp +++ b/taglib/mpeg/mpegproperties.cpp @@ -210,7 +210,7 @@ void MPEG::Properties::read(File *file, ReadStyle readStyle) } } bitRate = firstHeader.samplesPerFrame() != 0 - ? static_cast((bytesPerFrame * 8 * firstHeader.sampleRate()) + ? static_cast(bytesPerFrame * 8 * firstHeader.sampleRate() / 1000 / firstHeader.samplesPerFrame()) : 0; } diff --git a/taglib/mpeg/xingheader.cpp b/taglib/mpeg/xingheader.cpp index 99d6b8c8..e2bb7bed 100644 --- a/taglib/mpeg/xingheader.cpp +++ b/taglib/mpeg/xingheader.cpp @@ -54,7 +54,7 @@ MPEG::XingHeader::~XingHeader() = default; bool MPEG::XingHeader::isValid() const { - return (d->type != Invalid && d->frames > 0 && d->size > 0); + return d->type != Invalid && d->frames > 0 && d->size > 0; } unsigned int MPEG::XingHeader::totalFrames() const diff --git a/taglib/ogg/flac/oggflacfile.cpp b/taglib/ogg/flac/oggflacfile.cpp index 14473c5f..58a96956 100644 --- a/taglib/ogg/flac/oggflacfile.cpp +++ b/taglib/ogg/flac/oggflacfile.cpp @@ -57,7 +57,7 @@ bool Ogg::FLAC::File::isSupported(IOStream *stream) // An Ogg FLAC file has IDs "OggS" and "fLaC" somewhere. const ByteVector buffer = Utils::readHeader(stream, bufferSize(), false); - return (buffer.find("OggS") >= 0 && buffer.find("fLaC") >= 0); + return buffer.find("OggS") >= 0 && buffer.find("fLaC") >= 0; } //////////////////////////////////////////////////////////////////////////////// diff --git a/taglib/ogg/oggpage.cpp b/taglib/ogg/oggpage.cpp index 9e2819d4..a4fa7aea 100644 --- a/taglib/ogg/oggpage.cpp +++ b/taglib/ogg/oggpage.cpp @@ -293,16 +293,16 @@ List Ogg::Page::paginate(const ByteVectorList &packets, for(auto it = packets.begin(); it != packets.end(); ++it) { - const bool lastPacketInList = (it == --packets.end()); + const bool lastPacketInList = it == --packets.end(); // mark very first packet? - bool continued = (firstPacketContinued && it == packets.begin()); + bool continued = firstPacketContinued && it == packets.begin(); unsigned int pos = 0; while(pos < it->size()) { - const bool lastSplit = (pos + SplitSize >= it->size()); + const bool lastSplit = pos + SplitSize >= it->size(); ByteVectorList packetList; packetList.append(it->mid(pos, SplitSize)); diff --git a/taglib/ogg/oggpageheader.cpp b/taglib/ogg/oggpageheader.cpp index 32564e61..6ed844ad 100644 --- a/taglib/ogg/oggpageheader.cpp +++ b/taglib/ogg/oggpageheader.cpp @@ -286,7 +286,7 @@ ByteVector Ogg::PageHeader::lacingValues() const // these values is a byte. A value of less than 255 (0xff) indicates the end // of the packet. - data.resize(data.size() + (*it / 255), '\xff'); + data.resize(data.size() + *it / 255, '\xff'); if(it != std::prev(d->packetSizes.cend()) || d->lastPacketCompleted) data.append(static_cast(*it % 255)); diff --git a/taglib/ogg/opus/opusfile.cpp b/taglib/ogg/opus/opusfile.cpp index e29763a8..8c907153 100644 --- a/taglib/ogg/opus/opusfile.cpp +++ b/taglib/ogg/opus/opusfile.cpp @@ -52,7 +52,7 @@ bool Ogg::Opus::File::isSupported(IOStream *stream) // An Opus file has IDs "OggS" and "OpusHead" somewhere. const ByteVector buffer = Utils::readHeader(stream, bufferSize(), false); - return (buffer.find("OggS") >= 0 && buffer.find("OpusHead") >= 0); + return buffer.find("OggS") >= 0 && buffer.find("OpusHead") >= 0; } //////////////////////////////////////////////////////////////////////////////// diff --git a/taglib/ogg/opus/opusproperties.cpp b/taglib/ogg/opus/opusproperties.cpp index e695b488..f5f06a0d 100644 --- a/taglib/ogg/opus/opusproperties.cpp +++ b/taglib/ogg/opus/opusproperties.cpp @@ -138,7 +138,7 @@ void Opus::Properties::read(File *file) const long long end = last->absoluteGranularPosition(); if(start >= 0 && end >= 0) { - if(const long long frameCount = (end - start - preSkip); frameCount > 0) { + if(const long long frameCount = end - start - preSkip; frameCount > 0) { const double length = frameCount * 1000.0 / 48000.0; offset_t fileLengthWithoutOverhead = file->length(); // Ignore the two mandatory header packets, see "3. Packet Organization" diff --git a/taglib/ogg/speex/speexfile.cpp b/taglib/ogg/speex/speexfile.cpp index 298ea311..c664c03e 100644 --- a/taglib/ogg/speex/speexfile.cpp +++ b/taglib/ogg/speex/speexfile.cpp @@ -52,7 +52,7 @@ bool Ogg::Speex::File::isSupported(IOStream *stream) // A Speex file has IDs "OggS" and "Speex " somewhere. const ByteVector buffer = Utils::readHeader(stream, bufferSize(), false); - return (buffer.find("OggS") >= 0 && buffer.find("Speex ") >= 0); + return buffer.find("OggS") >= 0 && buffer.find("Speex ") >= 0; } //////////////////////////////////////////////////////////////////////////////// diff --git a/taglib/ogg/vorbis/vorbisfile.cpp b/taglib/ogg/vorbis/vorbisfile.cpp index 69cd6f4f..7b5823b4 100644 --- a/taglib/ogg/vorbis/vorbisfile.cpp +++ b/taglib/ogg/vorbis/vorbisfile.cpp @@ -55,7 +55,7 @@ bool Vorbis::File::isSupported(IOStream *stream) // An Ogg Vorbis file has IDs "OggS" and "\x01vorbis" somewhere. const ByteVector buffer = Utils::readHeader(stream, bufferSize(), false); - return (buffer.find("OggS") >= 0 && buffer.find("\x01vorbis") >= 0); + return buffer.find("OggS") >= 0 && buffer.find("\x01vorbis") >= 0; } //////////////////////////////////////////////////////////////////////////////// diff --git a/taglib/riff/aiff/aifffile.cpp b/taglib/riff/aiff/aifffile.cpp index e3a42230..25e8f856 100644 --- a/taglib/riff/aiff/aifffile.cpp +++ b/taglib/riff/aiff/aifffile.cpp @@ -58,7 +58,7 @@ bool RIFF::AIFF::File::isSupported(IOStream *stream) // An AIFF file has to start with "FORM????AIFF" or "FORM????AIFC". const ByteVector id = Utils::readHeader(stream, 12, false); - return (id.startsWith("FORM") && (id.containsAt("AIFF", 8) || id.containsAt("AIFC", 8))); + return id.startsWith("FORM") && (id.containsAt("AIFF", 8) || id.containsAt("AIFC", 8)); } //////////////////////////////////////////////////////////////////////////////// diff --git a/taglib/riff/aiff/aiffproperties.cpp b/taglib/riff/aiff/aiffproperties.cpp index dbc4875d..f5ff37f3 100644 --- a/taglib/riff/aiff/aiffproperties.cpp +++ b/taglib/riff/aiff/aiffproperties.cpp @@ -90,7 +90,7 @@ unsigned int RIFF::AIFF::Properties::sampleFrames() const bool RIFF::AIFF::Properties::isAiffC() const { - return (!d->compressionType.isEmpty()); + return !d->compressionType.isEmpty(); } ByteVector RIFF::AIFF::Properties::compressionType() const diff --git a/taglib/riff/rifffile.cpp b/taglib/riff/rifffile.cpp index 67d307ee..66aa05e9 100644 --- a/taglib/riff/rifffile.cpp +++ b/taglib/riff/rifffile.cpp @@ -281,7 +281,7 @@ void RIFF::File::removeChunk(const ByteVector &name) void RIFF::File::read() { - const bool bigEndian = (d->endianness == BigEndian); + const bool bigEndian = d->endianness == BigEndian; offset_t offset = tell(); diff --git a/taglib/riff/wav/wavfile.cpp b/taglib/riff/wav/wavfile.cpp index d4c93947..8c7cdb85 100644 --- a/taglib/riff/wav/wavfile.cpp +++ b/taglib/riff/wav/wavfile.cpp @@ -66,7 +66,7 @@ bool RIFF::WAV::File::isSupported(IOStream *stream) // A WAV file has to start with "RIFF????WAVE". const ByteVector id = Utils::readHeader(stream, 12, false); - return (id.startsWith("RIFF") && id.containsAt("WAVE", 8)); + return id.startsWith("RIFF") && id.containsAt("WAVE", 8); } //////////////////////////////////////////////////////////////////////////////// diff --git a/taglib/tag.cpp b/taglib/tag.cpp index a1e7e5ae..f2e82300 100644 --- a/taglib/tag.cpp +++ b/taglib/tag.cpp @@ -42,27 +42,27 @@ Tag::~Tag() = default; bool Tag::isEmpty() const { - return (title().isEmpty() && - artist().isEmpty() && - album().isEmpty() && - comment().isEmpty() && - genre().isEmpty() && - year() == 0 && - track() == 0); + return title().isEmpty() && + artist().isEmpty() && + album().isEmpty() && + comment().isEmpty() && + genre().isEmpty() && + year() == 0 && + track() == 0; } PropertyMap Tag::properties() const { PropertyMap map; - if(!(title().isEmpty())) + if(!title().isEmpty()) map["TITLE"].append(title()); - if(!(artist().isEmpty())) + if(!artist().isEmpty()) map["ARTIST"].append(artist()); - if(!(album().isEmpty())) + if(!album().isEmpty()) map["ALBUM"].append(album()); - if(!(comment().isEmpty())) + if(!comment().isEmpty()) map["COMMENT"].append(comment()); - if(!(genre().isEmpty())) + if(!genre().isEmpty()) map["GENRE"].append(genre()); if(year() != 0) map["DATE"].append(String::number(year())); diff --git a/taglib/tagutils.cpp b/taglib/tagutils.cpp index 93efed4d..c11c8b69 100644 --- a/taglib/tagutils.cpp +++ b/taglib/tagutils.cpp @@ -45,7 +45,7 @@ offset_t Utils::findID3v1(File *file) const offset_t p = file->tell() + 3; if(const TagLib::ByteVector data = file->readBlock(8); - data.containsAt(ID3v1::Tag::fileIdentifier(), 3) && (data != APE::Tag::fileIdentifier())) + data.containsAt(ID3v1::Tag::fileIdentifier(), 3) && data != APE::Tag::fileIdentifier()) return p; } else { file->seek(-128, File::End); diff --git a/taglib/toolkit/tbytevector.cpp b/taglib/toolkit/tbytevector.cpp index d025c226..350e8498 100644 --- a/taglib/toolkit/tbytevector.cpp +++ b/taglib/toolkit/tbytevector.cpp @@ -129,8 +129,8 @@ T toNumber(const ByteVector &v, size_t offset, size_t length, bool mostSignifica template T toNumber(const ByteVector &v, size_t offset, bool mostSignificantByteFirst) { - const bool isBigEndian = (Utils::systemByteOrder() == Utils::BigEndian); - const bool swap = (mostSignificantByteFirst != isBigEndian); + const bool isBigEndian = Utils::systemByteOrder() == Utils::BigEndian; + const bool swap = mostSignificantByteFirst != isBigEndian; if(offset + sizeof(T) > v.size()) return toNumber(v, offset, v.size() - offset, mostSignificantByteFirst); @@ -147,7 +147,7 @@ T toNumber(const ByteVector &v, size_t offset, bool mostSignificantByteFirst) template ByteVector fromNumber(T value, bool mostSignificantByteFirst) { - const bool isBigEndian = (Utils::systemByteOrder() == Utils::BigEndian); + const bool isBigEndian = Utils::systemByteOrder() == Utils::BigEndian; if(mostSignificantByteFirst != isBigEndian) value = Utils::byteSwap(value); @@ -381,12 +381,12 @@ ByteVector &ByteVector::setData(const char *data) char *ByteVector::data() { detach(); - return !isEmpty() ? (&(*d->data)[d->offset]) : nullptr; + return !isEmpty() ? &(*d->data)[d->offset] : nullptr; } const char *ByteVector::data() const { - return !isEmpty() ? (&(*d->data)[d->offset]) : nullptr; + return !isEmpty() ? &(*d->data)[d->offset] : nullptr; } ByteVector ByteVector::mid(unsigned int index, unsigned int length) const @@ -399,7 +399,7 @@ ByteVector ByteVector::mid(unsigned int index, unsigned int length) const char ByteVector::at(unsigned int index) const { - return (index < size()) ? (*d->data)[d->offset + index] : 0; + return index < size() ? (*d->data)[d->offset + index] : 0; } int ByteVector::find(const ByteVector &pattern, unsigned int offset, int byteAlign) const @@ -439,7 +439,7 @@ bool ByteVector::containsAt(const ByteVector &pattern, unsigned int offset, unsi if(offset + compareLength > size() || patternOffset >= pattern.size() || patternLength == 0) return false; - return (::memcmp(data() + offset, pattern.data() + patternOffset, compareLength) == 0); + return ::memcmp(data() + offset, pattern.data() + patternOffset, compareLength) == 0; } bool ByteVector::startsWith(const ByteVector &pattern) const @@ -653,7 +653,7 @@ ByteVector::ConstReverseIterator ByteVector::rend() const bool ByteVector::isEmpty() const { - return (d->length == 0); + return d->length == 0; } unsigned int ByteVector::toUInt(bool mostSignificantByteFirst) const @@ -757,7 +757,7 @@ bool ByteVector::operator==(const ByteVector &v) const if(size() != v.size()) return false; - return (::memcmp(data(), v.data(), size()) == 0); + return ::memcmp(data(), v.data(), size()) == 0; } bool ByteVector::operator!=(const ByteVector &v) const @@ -770,7 +770,7 @@ bool ByteVector::operator==(const char *s) const if(size() != ::strlen(s)) return false; - return (::memcmp(data(), s, size()) == 0); + return ::memcmp(data(), s, size()) == 0; } bool ByteVector::operator!=(const char *s) const @@ -788,7 +788,7 @@ bool ByteVector::operator<(const ByteVector &v) const bool ByteVector::operator>(const ByteVector &v) const { - return (v < *this); + return v < *this; } ByteVector ByteVector::operator+(const ByteVector &v) const @@ -833,7 +833,7 @@ ByteVector ByteVector::toHex() const for(unsigned int i = 0; i < size(); i++) { unsigned char c = data()[i]; *p++ = hexTable[(c >> 4) & 0x0F]; - *p++ = hexTable[(c ) & 0x0F]; + *p++ = hexTable[ c & 0x0F]; } return encoded; diff --git a/taglib/toolkit/tbytevectorstream.h b/taglib/toolkit/tbytevectorstream.h index ce33a39d..21c699f4 100644 --- a/taglib/toolkit/tbytevectorstream.h +++ b/taglib/toolkit/tbytevectorstream.h @@ -132,8 +132,6 @@ namespace TagLib { ByteVector *data(); - protected: - private: class ByteVectorStreamPrivate; TAGLIB_MSVC_SUPPRESS_WARNING_NEEDS_TO_HAVE_DLL_INTERFACE diff --git a/taglib/toolkit/tfile.cpp b/taglib/toolkit/tfile.cpp index 200e649d..81ba29e7 100644 --- a/taglib/toolkit/tfile.cpp +++ b/taglib/toolkit/tfile.cpp @@ -176,7 +176,7 @@ offset_t File::find(const ByteVector &pattern, offset_t fromOffset, const ByteVe // (1) previous partial match if(previousPartialMatch >= 0 && static_cast(bufferSize()) > previousPartialMatch) { - if(const int patternOffset = (bufferSize() - previousPartialMatch); + if(const int patternOffset = bufferSize() - previousPartialMatch; buffer.containsAt(pattern, 0, patternOffset)) { seek(originalPosition); return bufferOffset - bufferSize() + previousPartialMatch; @@ -184,7 +184,7 @@ offset_t File::find(const ByteVector &pattern, offset_t fromOffset, const ByteVe } if(!before.isEmpty() && beforePreviousPartialMatch >= 0 && static_cast(bufferSize()) > beforePreviousPartialMatch) { - if(const int beforeOffset = (bufferSize() - beforePreviousPartialMatch); + if(const int beforeOffset = bufferSize() - beforePreviousPartialMatch; buffer.containsAt(before, 0, beforeOffset)) { seek(originalPosition); return -1; diff --git a/taglib/toolkit/tfilestream.cpp b/taglib/toolkit/tfilestream.cpp index 4563d3a9..f1233436 100644 --- a/taglib/toolkit/tfilestream.cpp +++ b/taglib/toolkit/tfilestream.cpp @@ -357,7 +357,7 @@ bool FileStream::readOnly() const bool FileStream::isOpen() const { - return (d->file != InvalidFileHandle); + return d->file != InvalidFileHandle; } void FileStream::seek(offset_t offset, Position p) diff --git a/taglib/toolkit/tpropertymap.cpp b/taglib/toolkit/tpropertymap.cpp index 777b5704..93836ca1 100644 --- a/taglib/toolkit/tpropertymap.cpp +++ b/taglib/toolkit/tpropertymap.cpp @@ -142,12 +142,12 @@ bool PropertyMap::operator==(const PropertyMap &other) const { for(const auto &[property, val] : other) { if(auto thisFind = find(property); - thisFind == end() || (thisFind->second != val)) + thisFind == end() || thisFind->second != val) return false; } for(const auto &[property, val] : *this) { if(auto otherFind = other.find(property); - otherFind == other.end() || (otherFind->second != val)) + otherFind == other.end() || otherFind->second != val) return false; } return d->unsupported == other.d->unsupported; diff --git a/taglib/toolkit/tstring.cpp b/taglib/toolkit/tstring.cpp index 50470c7b..3158bd79 100644 --- a/taglib/toolkit/tstring.cpp +++ b/taglib/toolkit/tstring.cpp @@ -117,7 +117,7 @@ namespace length--; } else { - swap = (t != wcharByteOrder()); + swap = t != wcharByteOrder(); } data.resize(length); @@ -483,8 +483,8 @@ int String::toInt(bool *ok) const // Has wcstol() consumed the entire string and not overflowed? if(ok) { - *ok = (errno == 0 && endPtr > beginPtr && *endPtr == L'\0'); - *ok = (*ok && value > INT_MIN && value < INT_MAX); + *ok = errno == 0 && endPtr > beginPtr && *endPtr == L'\0'; + *ok = *ok && value > INT_MIN && value < INT_MAX; } return static_cast(value); @@ -535,7 +535,7 @@ const wchar_t &String::operator[](int i) const bool String::operator==(const String &s) const { - return (d == s.d || d->data == s.d->data); + return d == s.d || d->data == s.d->data; } bool String::operator!=(const String &s) const @@ -561,7 +561,7 @@ bool String::operator!=(const char *s) const bool String::operator==(const wchar_t *s) const { - return (d->data == s); + return d->data == s; } bool String::operator!=(const wchar_t *s) const @@ -663,7 +663,7 @@ void String::swap(String &s) noexcept bool String::operator<(const String &s) const { - return (d->data < s.d->data); + return d->data < s.d->data; } //////////////////////////////////////////////////////////////////////////////// diff --git a/taglib/toolkit/tvariant.cpp b/taglib/toolkit/tvariant.cpp index 8a7f5d1c..e5950cc7 100644 --- a/taglib/toolkit/tvariant.cpp +++ b/taglib/toolkit/tvariant.cpp @@ -375,7 +375,7 @@ TagLib::Map Variant::toMap(bool *ok) const bool Variant::operator==(const Variant &v) const { - return (d == v.d || d->data == v.d->data); + return d == v.d || d->data == v.d->data; } bool Variant::operator!=(const Variant &v) const diff --git a/taglib/toolkit/tzlib.cpp b/taglib/toolkit/tzlib.cpp index 048b7bbf..2e055b8b 100644 --- a/taglib/toolkit/tzlib.cpp +++ b/taglib/toolkit/tzlib.cpp @@ -63,7 +63,7 @@ ByteVector zlib::decompress([[maybe_unused]] const ByteVector &data) ByteVector inData = data; - stream.avail_in = static_cast(inData.size()); + stream.avail_in = inData.size(); stream.next_in = reinterpret_cast(inData.data()); ByteVector outData; diff --git a/taglib/trueaudio/trueaudiofile.cpp b/taglib/trueaudio/trueaudiofile.cpp index 442c354c..55e697c0 100644 --- a/taglib/trueaudio/trueaudiofile.cpp +++ b/taglib/trueaudio/trueaudiofile.cpp @@ -71,7 +71,7 @@ bool TrueAudio::File::isSupported(IOStream *stream) // A TrueAudio file has to start with "TTA". An ID3v2 tag may precede. const ByteVector id = Utils::readHeader(stream, 3, true); - return (id == "TTA"); + return id == "TTA"; } //////////////////////////////////////////////////////////////////////////////// @@ -168,7 +168,7 @@ bool TrueAudio::File::save() insert(data, d->ID3v2Location, d->ID3v2OriginalSize); if(d->ID3v1Location >= 0) - d->ID3v1Location += (static_cast(data.size()) - d->ID3v2OriginalSize); + d->ID3v1Location += static_cast(data.size()) - d->ID3v2OriginalSize; d->ID3v2OriginalSize = data.size(); } @@ -241,12 +241,12 @@ void TrueAudio::File::strip(int tags) bool TrueAudio::File::hasID3v1Tag() const { - return (d->ID3v1Location >= 0); + return d->ID3v1Location >= 0; } bool TrueAudio::File::hasID3v2Tag() const { - return (d->ID3v2Location >= 0); + return d->ID3v2Location >= 0; } //////////////////////////////////////////////////////////////////////////////// @@ -287,7 +287,7 @@ void TrueAudio::File::read(bool readProperties) if(d->ID3v2Location >= 0) { seek(d->ID3v2Location + d->ID3v2OriginalSize); - streamLength -= (d->ID3v2Location + d->ID3v2OriginalSize); + streamLength -= d->ID3v2Location + d->ID3v2OriginalSize; } else { seek(0); diff --git a/taglib/wavpack/wavpackfile.cpp b/taglib/wavpack/wavpackfile.cpp index 456e6476..57573f07 100644 --- a/taglib/wavpack/wavpackfile.cpp +++ b/taglib/wavpack/wavpackfile.cpp @@ -66,7 +66,7 @@ bool WavPack::File::isSupported(IOStream *stream) // A WavPack file has to start with "wvpk". const ByteVector id = Utils::readHeader(stream, 4, false); - return (id == "wvpk"); + return id == "wvpk"; } //////////////////////////////////////////////////////////////////////////////// @@ -169,7 +169,7 @@ bool WavPack::File::save() insert(data, d->APELocation, d->APESize); if(d->ID3v1Location >= 0) - d->ID3v1Location += (static_cast(data.size()) - d->APESize); + d->ID3v1Location += static_cast(data.size()) - d->APESize; d->APESize = data.size(); } @@ -215,12 +215,12 @@ void WavPack::File::strip(int tags) bool WavPack::File::hasID3v1Tag() const { - return (d->ID3v1Location >= 0); + return d->ID3v1Location >= 0; } bool WavPack::File::hasAPETag() const { - return (d->APELocation >= 0); + return d->APELocation >= 0; } //////////////////////////////////////////////////////////////////////////////// diff --git a/tests/main.cpp b/tests/main.cpp index cca69d68..22265b99 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -37,7 +37,7 @@ int main(int argc, char* argv[]) { - std::string testPath = (argc > 1) ? std::string(argv[1]) : ""; + std::string testPath = argc > 1 ? std::string(argv[1]) : ""; // Create the event manager and test controller CppUnit::TestResult controller; diff --git a/tests/test_map.cpp b/tests/test_map.cpp index 2228eebd..cc80440d 100644 --- a/tests/test_map.cpp +++ b/tests/test_map.cpp @@ -63,7 +63,7 @@ public: Map m2 = m1; auto it = m2.find("bob"); - (*it).second = 99; + it->second = 99; CPPUNIT_ASSERT_EQUAL(9, m1["bob"]); CPPUNIT_ASSERT_EQUAL(99, m2["bob"]); } diff --git a/tests/test_xiphcomment.cpp b/tests/test_xiphcomment.cpp index dd477377..8cb1ff83 100644 --- a/tests/test_xiphcomment.cpp +++ b/tests/test_xiphcomment.cpp @@ -183,10 +183,10 @@ public: Vorbis::File f(newname.c_str()); List lst = f.tag()->pictureList(); CPPUNIT_ASSERT_EQUAL(static_cast(1), lst.size()); - CPPUNIT_ASSERT_EQUAL(static_cast(5), lst[0]->width()); - CPPUNIT_ASSERT_EQUAL(static_cast(6), lst[0]->height()); - CPPUNIT_ASSERT_EQUAL(static_cast(16), lst[0]->colorDepth()); - CPPUNIT_ASSERT_EQUAL(static_cast(7), lst[0]->numColors()); + CPPUNIT_ASSERT_EQUAL(5, lst[0]->width()); + CPPUNIT_ASSERT_EQUAL(6, lst[0]->height()); + CPPUNIT_ASSERT_EQUAL(16, lst[0]->colorDepth()); + CPPUNIT_ASSERT_EQUAL(7, lst[0]->numColors()); CPPUNIT_ASSERT_EQUAL(String("image/jpeg"), lst[0]->mimeType()); CPPUNIT_ASSERT_EQUAL(String("new image"), lst[0]->description()); CPPUNIT_ASSERT_EQUAL(ByteVector("JPEG data"), lst[0]->data());