Skip to content

Commit

Permalink
tidy: Remove extraneous 'if' checks before calling delete.
Browse files Browse the repository at this point in the history
According to the c++ reference, deleting a null pointer has no effect,
so non-null checks are unnecessary.

https://clang.llvm.org/extra/clang-tidy/checks/readability-delete-null-pointer.html
  • Loading branch information
linuxdude42 committed Dec 23, 2019
1 parent b32676f commit 4ad8b31
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 7 deletions.
3 changes: 1 addition & 2 deletions mythplugins/mytharchive/mytharchive/remoteavformatcontext.h
Expand Up @@ -35,8 +35,7 @@ class RemoteAVFormatContext
avformat_free_context(m_inputFC);
m_inputFC = avformat_alloc_context();

if (m_rf)
delete m_rf;
delete m_rf;

m_inputIsRemote = filename.startsWith("myth://");
if (m_inputIsRemote)
Expand Down
3 changes: 1 addition & 2 deletions mythtv/libs/libmythservicecontracts/datacontracthelper.h
Expand Up @@ -118,8 +118,7 @@ inline void DeleteListContents( QVariantList &list )

const QObject *pObject = vValue.value< QObject* >();

if (pObject != nullptr)
delete pObject;
delete pObject;
}
}

Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/decoders/nuppeldecoder.h
Expand Up @@ -24,7 +24,7 @@ class RawDataList
public:
RawDataList(struct rtframeheader frameh, unsigned char *data) :
frameheader(frameh), packet(data) {}
~RawDataList() { if (packet) delete [] packet; }
~RawDataList() { delete [] packet; }

struct rtframeheader frameheader;
unsigned char *packet;
Expand Down
3 changes: 1 addition & 2 deletions mythtv/libs/libmythui/platforms/mythdisplaydrm.cpp
Expand Up @@ -12,8 +12,7 @@ MythDisplayDRM::MythDisplayDRM()

MythDisplayDRM::~MythDisplayDRM()
{
if (m_device)
delete m_device;
delete m_device;
}

void MythDisplayDRM::ScreenChanged(QScreen *qScreen)
Expand Down

0 comments on commit 4ad8b31

Please sign in to comment.