Fix issues reported by Clang Static Analyzer

Some deadcode.DeadStores.

On Debian 12:
CXXFLAGS=-I/usr/include/x86_64-linux-gnu/c++/12 \
cmake -DCMAKE_C_COMPILER=/usr/share/clang/scan-build-14/libexec/ccc-analyzer \
    -DCMAKE_CXX_COMPILER=/usr/share/clang/scan-build-14/libexec/c++-analyzer \
    -DBUILD_SHARED_LIBS=OFF \
    -DCMAKE_EXPORT_COMPILE_COMMANDS=1 \
    -DENABLE_CCACHE=ON -DBUILD_TESTING=ON -DBUILD_EXAMPLES=ON \
    -DCMAKE_BUILD_TYPE=Debug ../taglib
scan-build make
This commit is contained in:
Urs Fleisch
2023-12-02 11:44:00 +01:00
parent cf2bdce21d
commit 131918333b
12 changed files with 117 additions and 97 deletions

View File

@ -24,8 +24,8 @@
***************************************************************************/
#include <string>
#include <cstdio>
#include <utility>
#include <cassert>
#include "tdebug.h"
#include "tpropertymap.h"
@ -307,6 +307,7 @@ public:
dynamic_cast<TagLib::ID3v2::AttachedPictureFrame *>(factory->createFrame(data, &header));
CPPUNIT_ASSERT(frame);
assert(frame != nullptr); // to silence the clang analyzer
CPPUNIT_ASSERT_EQUAL(String("image/jpeg"), frame->mimeType());
CPPUNIT_ASSERT_EQUAL(ID3v2::AttachedPictureFrame::FileIcon, frame->type());
CPPUNIT_ASSERT_EQUAL(String("d"), frame->description());
@ -1126,6 +1127,7 @@ public:
ID3v2::AttachedPictureFrame *frame
= dynamic_cast<TagLib::ID3v2::AttachedPictureFrame*>(f.ID3v2Tag()->frameListMap()["APIC"].front());
CPPUNIT_ASSERT(frame);
assert(frame != nullptr); // to silence the clang analyzer
CPPUNIT_ASSERT_EQUAL(String("image/bmp"), frame->mimeType());
CPPUNIT_ASSERT_EQUAL(ID3v2::AttachedPictureFrame::Other, frame->type());
CPPUNIT_ASSERT_EQUAL(String(""), frame->description());
@ -1148,6 +1150,7 @@ public:
ID3v2::UrlLinkFrame *frame =
dynamic_cast<TagLib::ID3v2::UrlLinkFrame*>(f.ID3v2Tag()->frameListMap()["W000"].front());
CPPUNIT_ASSERT(frame);
assert(frame != nullptr); // to silence the clang analyzer
CPPUNIT_ASSERT_EQUAL(String("lukas.lalinsky@example.com____"), frame->url());
}

View File

@ -23,6 +23,7 @@
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include <cassert>
#include "tstringlist.h"
#include "itfile.h"
#include <cppunit/extensions/HelperMacros.h>
@ -106,6 +107,7 @@ private:
CPPUNIT_ASSERT(nullptr != p);
CPPUNIT_ASSERT(nullptr != t);
assert(p != nullptr); // to silence the clang analyzer
CPPUNIT_ASSERT_EQUAL( 0, p->lengthInSeconds());
CPPUNIT_ASSERT_EQUAL( 0, p->bitrate());

View File

@ -23,6 +23,7 @@
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include <cassert>
#include "tpropertymap.h"
#include "modfile.h"
#include <cppunit/extensions/HelperMacros.h>
@ -112,6 +113,7 @@ private:
CPPUNIT_ASSERT(nullptr != p);
CPPUNIT_ASSERT(nullptr != t);
assert(p != nullptr); // to silence the clang analyzer
CPPUNIT_ASSERT_EQUAL(0, p->lengthInSeconds());
CPPUNIT_ASSERT_EQUAL(0, p->bitrate());

View File

@ -23,6 +23,7 @@
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include <cassert>
#include "s3mfile.h"
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
@ -97,6 +98,7 @@ private:
CPPUNIT_ASSERT(nullptr != p);
CPPUNIT_ASSERT(nullptr != t);
assert(p != nullptr); // to silence the clang analyzer
CPPUNIT_ASSERT_EQUAL( 0, p->lengthInSeconds());
CPPUNIT_ASSERT_EQUAL( 0, p->bitrate());

View File

@ -23,6 +23,7 @@
* http://www.mozilla.org/MPL/ *
***************************************************************************/
#include <cassert>
#include "xmfile.h"
#include <cppunit/extensions/HelperMacros.h>
#include "utils.h"
@ -129,6 +130,7 @@ public:
CPPUNIT_ASSERT(nullptr != p);
CPPUNIT_ASSERT(nullptr != t);
assert(p != nullptr); // to silence the clang analyzer
CPPUNIT_ASSERT_EQUAL(0, p->lengthInSeconds());
CPPUNIT_ASSERT_EQUAL(0, p->bitrate());
@ -175,6 +177,7 @@ private:
CPPUNIT_ASSERT(nullptr != p);
CPPUNIT_ASSERT(nullptr != t);
assert(p != nullptr); // to silence the clang analyzer
CPPUNIT_ASSERT_EQUAL(0, p->lengthInSeconds());
CPPUNIT_ASSERT_EQUAL(0, p->bitrate());