diff --git a/bindings/c/tag_c.cpp b/bindings/c/tag_c.cpp index 4eda88e1..a12ec192 100644 --- a/bindings/c/tag_c.cpp +++ b/bindings/c/tag_c.cpp @@ -520,8 +520,7 @@ bool _taglib_complex_property_set( while(*attrPtr) { const TagLib_Complex_Property_Attribute *attr = *attrPtr; String attrKey(attr->key); - TagLib_Variant_Type type = attr->value.type; - switch(type) { + switch(attr->value.type) { case TagLib_Variant_Void: map.insert(attrKey, Variant()); break; @@ -727,8 +726,7 @@ void taglib_picture_from_complex_property( TagLib_Complex_Property_Attribute** attrPtr = *propPtr; while(*attrPtr) { TagLib_Complex_Property_Attribute *attr = *attrPtr; - TagLib_Variant_Type type = attr->value.type; - switch(type) { + switch(attr->value.type) { case TagLib_Variant_String: if(strcmp("mimeType", attr->key) == 0) { picture->mimeType = attr->value.value.stringValue; @@ -779,8 +777,7 @@ void taglib_complex_property_free( TagLib_Complex_Property_Attribute** attrPtr = *propPtr; while(*attrPtr) { TagLib_Complex_Property_Attribute *attr = *attrPtr; - TagLib_Variant_Type type = attr->value.type; - switch(type) { + switch(attr->value.type) { case TagLib_Variant_String: free(attr->value.value.stringValue); break; diff --git a/taglib/mp4/mp4itemfactory.cpp b/taglib/mp4/mp4itemfactory.cpp index 0eb3d6df..8a097d1e 100644 --- a/taglib/mp4/mp4itemfactory.cpp +++ b/taglib/mp4/mp4itemfactory.cpp @@ -57,8 +57,7 @@ ItemFactory *ItemFactory::instance() std::pair ItemFactory::parseItem( const Atom *atom, const ByteVector &data) const { - auto handlerType = handlerTypeForName(atom->name()); - switch(handlerType) { + switch(handlerTypeForName(atom->name())) { case ItemHandlerType::Unknown: break; case ItemHandlerType::FreeForm: @@ -98,8 +97,7 @@ ByteVector ItemFactory::renderItem( } else { const ByteVector name = itemName.data(String::Latin1); - auto handlerType = handlerTypeForName(name); - switch(handlerType) { + switch(handlerTypeForName(name)) { case ItemHandlerType::Unknown: debug("MP4: Unknown item name \"" + name + "\""); break; @@ -142,10 +140,9 @@ std::pair ItemFactory::itemFromProperty( if(values.isEmpty()) { return {name, values}; } - auto handlerType = name.startsWith("----") - ? ItemHandlerType::FreeForm - : handlerTypeForName(name); - switch(handlerType) { + switch(name.startsWith("----") + ? ItemHandlerType::FreeForm + : handlerTypeForName(name)) { case ItemHandlerType::IntPair: case ItemHandlerType::IntPairNoTrailing: if(StringList parts = StringList::split(values.front(), "/"); @@ -190,10 +187,9 @@ std::pair ItemFactory::itemToProperty( const ByteVector &itemName, const Item &item) const { if(const String key = propertyKeyForName(itemName); !key.isEmpty()) { - auto handlerType = itemName.startsWith("----") - ? ItemHandlerType::FreeForm - : handlerTypeForName(itemName); - switch(handlerType) { + switch(itemName.startsWith("----") + ? ItemHandlerType::FreeForm + : handlerTypeForName(itemName)) { case ItemHandlerType::IntPair: case ItemHandlerType::IntPairNoTrailing: { diff --git a/taglib/mp4/mp4tag.cpp b/taglib/mp4/mp4tag.cpp index c4277d23..e56d1ab0 100644 --- a/taglib/mp4/mp4tag.cpp +++ b/taglib/mp4/mp4tag.cpp @@ -162,8 +162,7 @@ MP4::Tag::updateParents(const AtomList &path, offset_t delta, int ignore) void MP4::Tag::updateOffsets(offset_t delta, offset_t offset) { - MP4::Atom *moov = d->atoms->find("moov"); - if(moov) { + if(MP4::Atom *moov = d->atoms->find("moov")) { const MP4::AtomList stco = moov->findall("stco", true); for(const auto &atom : stco) { if(atom->offset() > offset) { @@ -205,8 +204,7 @@ MP4::Tag::updateOffsets(offset_t delta, offset_t offset) } } - MP4::Atom *moof = d->atoms->find("moof"); - if(moof) { + if(MP4::Atom *moof = d->atoms->find("moof")) { const MP4::AtomList tfhd = moof->findall("tfhd", true); for(const auto &atom : tfhd) { if(atom->offset() > offset) { diff --git a/taglib/mpc/mpcproperties.cpp b/taglib/mpc/mpcproperties.cpp index 5bbf6423..daf5f9c8 100644 --- a/taglib/mpc/mpcproperties.cpp +++ b/taglib/mpc/mpcproperties.cpp @@ -303,8 +303,7 @@ void MPC::Properties::readSV7(const ByteVector &data, offset_t streamLength) if (d->albumPeak != 0) d->albumPeak = static_cast(log10(static_cast(d->albumPeak)) * 20 * 256 + .5); - bool trueGapless = (gapless >> 31) & 0x0001; - if(trueGapless) { + if((gapless >> 31) & 0x0001) { unsigned int lastFrameSamples = (gapless >> 20) & 0x07FF; d->sampleFrames = d->totalFrames * 1152 - lastFrameSamples; } diff --git a/taglib/mpeg/id3v2/frames/textidentificationframe.cpp b/taglib/mpeg/id3v2/frames/textidentificationframe.cpp index 6a03aa79..739b2b6f 100644 --- a/taglib/mpeg/id3v2/frames/textidentificationframe.cpp +++ b/taglib/mpeg/id3v2/frames/textidentificationframe.cpp @@ -173,9 +173,9 @@ PropertyMap TextIdentificationFrame::asProperties() const return makeTIPLProperties(); if(frameID() == "TMCL") return makeTMCLProperties(); - PropertyMap map; String tagName = frameIDToKey(frameID()); if(tagName.isEmpty()) { + PropertyMap map; map.addUnsupportedData(frameID()); return map; } diff --git a/taglib/toolkit/tbytevector.cpp b/taglib/toolkit/tbytevector.cpp index 5ce4bd86..d025c226 100644 --- a/taglib/toolkit/tbytevector.cpp +++ b/taglib/toolkit/tbytevector.cpp @@ -148,9 +148,8 @@ template ByteVector fromNumber(T value, bool mostSignificantByteFirst) { const bool isBigEndian = (Utils::systemByteOrder() == Utils::BigEndian); - const bool swap = (mostSignificantByteFirst != isBigEndian); - if(swap) + if(mostSignificantByteFirst != isBigEndian) value = Utils::byteSwap(value); return ByteVector(reinterpret_cast(&value), sizeof(T)); diff --git a/taglib/toolkit/tzlib.cpp b/taglib/toolkit/tzlib.cpp index 4ddb8a63..048b7bbf 100644 --- a/taglib/toolkit/tzlib.cpp +++ b/taglib/toolkit/tzlib.cpp @@ -66,11 +66,10 @@ ByteVector zlib::decompress([[maybe_unused]] const ByteVector &data) stream.avail_in = static_cast(inData.size()); stream.next_in = reinterpret_cast(inData.data()); - const unsigned int chunkSize = 1024; - ByteVector outData; do { + constexpr unsigned int chunkSize = 1024; const size_t offset = outData.size(); outData.resize(outData.size() + chunkSize); diff --git a/tests/test_asf.cpp b/tests/test_asf.cpp index 538fd7ee..e48e1ced 100644 --- a/tests/test_asf.cpp +++ b/tests/test_asf.cpp @@ -395,16 +395,13 @@ public: void testRepeatedSave() { ScopedFileCopy copy("silence-1", ".wma"); - - { - ASF::File f(copy.fileName().c_str()); - f.tag()->setTitle(longText(128 * 1024)); - f.save(); - CPPUNIT_ASSERT_EQUAL(static_cast(297578), f.length()); - f.tag()->setTitle(longText(16 * 1024)); - f.save(); - CPPUNIT_ASSERT_EQUAL(static_cast(68202), f.length()); - } + ASF::File f(copy.fileName().c_str()); + f.tag()->setTitle(longText(128 * 1024)); + f.save(); + CPPUNIT_ASSERT_EQUAL(static_cast(297578), f.length()); + f.tag()->setTitle(longText(16 * 1024)); + f.save(); + CPPUNIT_ASSERT_EQUAL(static_cast(68202), f.length()); } }; diff --git a/tests/test_flac.cpp b/tests/test_flac.cpp index d5fd6bf3..763a1162 100644 --- a/tests/test_flac.cpp +++ b/tests/test_flac.cpp @@ -445,24 +445,20 @@ public: void testSaveID3v1() { ScopedFileCopy copy("no-tags", ".flac"); + FLAC::File f(copy.fileName().c_str()); + CPPUNIT_ASSERT(!f.hasID3v1Tag()); + CPPUNIT_ASSERT_EQUAL(static_cast(4692), f.length()); - ByteVector audioStream; - { - FLAC::File f(copy.fileName().c_str()); - CPPUNIT_ASSERT(!f.hasID3v1Tag()); - CPPUNIT_ASSERT_EQUAL(static_cast(4692), f.length()); + f.seek(0x0100); + ByteVector audioStream = f.readBlock(4436); - f.seek(0x0100); - audioStream = f.readBlock(4436); + f.ID3v1Tag(true)->setTitle("01234 56789 ABCDE FGHIJ"); + f.save(); + CPPUNIT_ASSERT(f.hasID3v1Tag()); + CPPUNIT_ASSERT_EQUAL(static_cast(4820), f.length()); - f.ID3v1Tag(true)->setTitle("01234 56789 ABCDE FGHIJ"); - f.save(); - CPPUNIT_ASSERT(f.hasID3v1Tag()); - CPPUNIT_ASSERT_EQUAL(static_cast(4820), f.length()); - - f.seek(0x0100); - CPPUNIT_ASSERT_EQUAL(audioStream, f.readBlock(4436)); - } + f.seek(0x0100); + CPPUNIT_ASSERT_EQUAL(audioStream, f.readBlock(4436)); } void testUpdateID3v2() diff --git a/tests/test_id3v2.cpp b/tests/test_id3v2.cpp index e0489838..057da9c7 100644 --- a/tests/test_id3v2.cpp +++ b/tests/test_id3v2.cpp @@ -1107,10 +1107,8 @@ public: PlainFile(newname.c_str()).readBlock(expectedId3v23Data.size()); CPPUNIT_ASSERT_EQUAL(expectedId3v23Data, actualId3v23Data); } - - ScopedFileCopy rareFramesCopy("rare_frames", ".mp3"); - { + ScopedFileCopy rareFramesCopy("rare_frames", ".mp3"); MPEG::File f(rareFramesCopy.fileName().c_str()); f.save(MPEG::File::AllTags, File::StripOthers, ID3v2::v3); f.seek(f.find("TCON") + 11); diff --git a/tests/test_mpeg.cpp b/tests/test_mpeg.cpp index 3f8c7ad7..2ebfc407 100644 --- a/tests/test_mpeg.cpp +++ b/tests/test_mpeg.cpp @@ -562,23 +562,21 @@ public: void testExtendedHeader() { const ScopedFileCopy copy("extended-header", ".mp3"); - { - MPEG::File f(copy.fileName().c_str()); - CPPUNIT_ASSERT(f.isValid()); - CPPUNIT_ASSERT(f.hasID3v2Tag()); - ID3v2::Tag *tag = f.ID3v2Tag(); - ID3v2::ExtendedHeader *ext = tag->extendedHeader(); - CPPUNIT_ASSERT(ext); - CPPUNIT_ASSERT_EQUAL(12U, ext->size()); - CPPUNIT_ASSERT_EQUAL(String("Druids"), tag->title()); - CPPUNIT_ASSERT_EQUAL(String("Excelsis"), tag->artist()); - CPPUNIT_ASSERT_EQUAL(String("Vo Chrieger U Drache"), tag->album()); - CPPUNIT_ASSERT_EQUAL(2013U, tag->year()); - CPPUNIT_ASSERT_EQUAL(String("Folk/Power Metal"), tag->genre()); - CPPUNIT_ASSERT_EQUAL(3U, tag->track()); - CPPUNIT_ASSERT_EQUAL(String("2013"), - f.properties().value("ORIGINALDATE").front()); - } + MPEG::File f(copy.fileName().c_str()); + CPPUNIT_ASSERT(f.isValid()); + CPPUNIT_ASSERT(f.hasID3v2Tag()); + ID3v2::Tag *tag = f.ID3v2Tag(); + ID3v2::ExtendedHeader *ext = tag->extendedHeader(); + CPPUNIT_ASSERT(ext); + CPPUNIT_ASSERT_EQUAL(12U, ext->size()); + CPPUNIT_ASSERT_EQUAL(String("Druids"), tag->title()); + CPPUNIT_ASSERT_EQUAL(String("Excelsis"), tag->artist()); + CPPUNIT_ASSERT_EQUAL(String("Vo Chrieger U Drache"), tag->album()); + CPPUNIT_ASSERT_EQUAL(2013U, tag->year()); + CPPUNIT_ASSERT_EQUAL(String("Folk/Power Metal"), tag->genre()); + CPPUNIT_ASSERT_EQUAL(3U, tag->track()); + CPPUNIT_ASSERT_EQUAL(String("2013"), + f.properties().value("ORIGINALDATE").front()); } void testReadStyleFast()