Skip to content

Commit

Permalink
cppcheck: Remove several redundant conditions.
Browse files Browse the repository at this point in the history
All of these are in the form "!A || (A && B)" which is equivalent to
"!A || B".  If A is false, the first clause is true and the whole
condition is true.  The only time the second clause is evaluated is
when A is true, so to actually test for that in the second clause is
unnecessary.
  • Loading branch information
linuxdude42 committed Oct 2, 2020
1 parent a298475 commit c5ff4fa
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 20 deletions.
4 changes: 2 additions & 2 deletions mythtv/libs/libmythtv/Bluray/mythbdbuffer.cpp
Expand Up @@ -1358,7 +1358,7 @@ MythBDOverlay* MythBDBuffer::GetOverlay(void)

void MythBDBuffer::SubmitOverlay(const bd_overlay_s* const Overlay)
{
if (!Overlay || (Overlay && (Overlay->plane > m_overlayPlanes.size())))
if (!Overlay || (Overlay->plane > m_overlayPlanes.size()))
return;

LOG(VB_PLAYBACK, LOG_DEBUG, QString("--------------------"));
Expand Down Expand Up @@ -1438,7 +1438,7 @@ void MythBDBuffer::SubmitOverlay(const bd_overlay_s* const Overlay)

void MythBDBuffer::SubmitARGBOverlay(const bd_argb_overlay_s * const Overlay)
{
if (!Overlay || (Overlay && (Overlay->plane > m_overlayPlanes.size())))
if (!Overlay || (Overlay->plane > m_overlayPlanes.size()))
return;

LOG(VB_PLAYBACK, LOG_DEBUG, QString("--------------------"));
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/decoders/mythv4l2m2mcontext.cpp
Expand Up @@ -445,7 +445,7 @@ int MythV4L2M2MContext::InitialiseV4L2RequestContext(AVCodecContext *Context)
}

auto* hwdevicecontext = reinterpret_cast<AVHWDeviceContext*>(hwdeviceref->data);
if (!hwdevicecontext || (hwdevicecontext && !hwdevicecontext->hwctx))
if (!hwdevicecontext || !hwdevicecontext->hwctx)
{
interop->DecrRef();
return -1;
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythtv/decoders/mythvaapicontext.cpp
Expand Up @@ -288,14 +288,14 @@ int MythVAAPIContext::InitialiseContext(AVCodecContext *Context)

// Create hardware device context
AVBufferRef* hwdeviceref = av_hwdevice_ctx_alloc(AV_HWDEVICE_TYPE_VAAPI);
if (!hwdeviceref || (hwdeviceref && !hwdeviceref->data))
if (!hwdeviceref || !hwdeviceref->data)
{
LOG(VB_GENERAL, LOG_ERR, LOC + "Failed to create VAAPI hardware device context");
return -1;
}

auto* hwdevicecontext = reinterpret_cast<AVHWDeviceContext*>(hwdeviceref->data);
if (!hwdevicecontext || (hwdevicecontext && !hwdevicecontext->hwctx))
if (!hwdevicecontext || !hwdevicecontext->hwctx)
return -1;
auto *vaapidevicectx = reinterpret_cast<AVVAAPIDeviceContext*>(hwdevicecontext->hwctx);
if (!vaapidevicectx)
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/decoders/mythvdpaucontext.cpp
Expand Up @@ -64,7 +64,7 @@ int MythVDPAUContext::InitialiseContext(AVCodecContext* Context)
return -1;

auto* hwdevicecontext = reinterpret_cast<AVHWDeviceContext*>(hwdeviceref->data);
if (!hwdevicecontext || (hwdevicecontext && !hwdevicecontext->hwctx))
if (!hwdevicecontext || !hwdevicecontext->hwctx)
return -1;

// Initialise device context
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/io/mythinteractivebuffer.cpp
Expand Up @@ -47,7 +47,7 @@ bool MythInteractiveBuffer::OpenFile(const QString &Url, uint /*Retry*/)
}

QScopedPointer<NetStream> stream(new NetStream(Url, NetStream::kNeverCache));
if (!stream || (stream && !stream->IsOpen()))
if (!stream || !stream->IsOpen())
{
LOG(VB_GENERAL, LOG_ERR, LOC + QString("Failed to open '%1'").arg(Url));
return false;
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/mythframe.h
Expand Up @@ -488,7 +488,7 @@ static inline int height_for_plane(VideoFrameType Type, int Height, uint Plane)
}
static inline void clear_vf(VideoFrame *vf)
{
if (!vf || (vf && !vf->buf))
if (!vf || !vf->buf)
return;

// luma (or RGBA)
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/mythvideooutgpu.cpp
Expand Up @@ -171,7 +171,7 @@ void MythVideoOutputGPU::DoneDisplayingFrame(VideoFrame* Frame)
while (m_videoBuffers.Size(kVideoBuffer_pause))
{
VideoFrame* frame = m_videoBuffers.Dequeue(kVideoBuffer_pause);
if (!retain || (retain && (frame != Frame)))
if (!retain || (frame != Frame))
release.append(frame);
}

Expand Down
6 changes: 3 additions & 3 deletions mythtv/libs/libmythtv/opengl/mythopenglinterop.cpp
Expand Up @@ -187,19 +187,19 @@ vector<MythVideoTexture*> MythOpenGLInterop::Retrieve(MythRenderOpenGL *Context,
{
// Unpick
auto* buffer = reinterpret_cast<AVBufferRef*>(Frame->priv[1]);
if (!buffer || (buffer && !buffer->data))
if (!buffer || !buffer->data)
return result;
if (Frame->codec == FMT_NVDEC)
{
auto* context = reinterpret_cast<AVHWDeviceContext*>(buffer->data);
if (!context || (context && !context->user_opaque))
if (!context || !context->user_opaque)
return result;
interop = reinterpret_cast<MythOpenGLInterop*>(context->user_opaque);
}
else
{
auto* frames = reinterpret_cast<AVHWFramesContext*>(buffer->data);
if (!frames || (frames && !frames->user_opaque))
if (!frames || !frames->user_opaque)
return result;
interop = reinterpret_cast<MythOpenGLInterop*>(frames->user_opaque);
}
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmythtv/opengl/mythvdpauinterop.cpp
Expand Up @@ -257,10 +257,10 @@ vector<MythVideoTexture*> MythVDPAUInterop::Acquire(MythRenderOpenGL *Context,
return result;

auto* buffer = reinterpret_cast<AVBufferRef*>(Frame->priv[1]);
if (!buffer || (buffer && !buffer->data))
if (!buffer || !buffer->data)
return result;
auto* frames = reinterpret_cast<AVHWFramesContext*>(buffer->data);
if (!frames || (frames && !frames->device_ctx))
if (!frames || !frames->device_ctx)
return result;
auto *devicecontext = reinterpret_cast<AVVDPAUDeviceContext*>(frames->device_ctx->hwctx);
if (!devicecontext)
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/opengl/mythvideooutopengl.cpp
Expand Up @@ -288,7 +288,7 @@ void MythVideoOutputOpenGL::RenderFrame(VideoFrame* Frame, FrameScanType Scan, O

uint8_t gray = m_dbLetterboxColour == kLetterBoxColour_Gray25 ? 64 : 0;

if (!Frame || (Frame && Frame->dummy) || ((m_openglRender->GetExtraFeatures() & kGLTiled) != 0))
if (!Frame || Frame->dummy || ((m_openglRender->GetExtraFeatures() & kGLTiled) != 0))
{
m_openglRender->SetBackground(gray, gray, gray, 255);
m_openglRender->ClearFramebuffer();
Expand Down
8 changes: 4 additions & 4 deletions mythtv/libs/libmythui/opengl/mythrenderopengl.cpp
Expand Up @@ -663,7 +663,7 @@ int MythRenderOpenGL::GetTextureDataSize(MythGLTexture *Texture)

void MythRenderOpenGL::SetTextureFilters(MythGLTexture *Texture, QOpenGLTexture::Filter Filter, QOpenGLTexture::WrapMode Wrap)
{
if (!Texture || (Texture && !(Texture->m_texture || Texture->m_textureId)))
if (!Texture || !(Texture->m_texture || Texture->m_textureId))
return;

makeCurrent();
Expand Down Expand Up @@ -799,7 +799,7 @@ void MythRenderOpenGL::DrawBitmap(MythGLTexture *Texture, QOpenGLFramebufferObje
{
makeCurrent();

if (!Texture || (Texture && !((Texture->m_texture || Texture->m_textureId) && Texture->m_vbo)))
if (!Texture || !((Texture->m_texture || Texture->m_textureId) && Texture->m_vbo))
return;

if (Program == nullptr)
Expand Down Expand Up @@ -865,7 +865,7 @@ void MythRenderOpenGL::DrawBitmap(std::vector<MythGLTexture *> &Textures,
Program = m_defaultPrograms[kShaderDefault];

MythGLTexture* first = Textures[0];
if (!first || (first && !((first->m_texture || first->m_textureId) && first->m_vbo)))
if (!first || !((first->m_texture || first->m_textureId) && first->m_vbo))
return;

SetShaderProjection(Program);
Expand Down Expand Up @@ -1263,7 +1263,7 @@ QStringList MythRenderOpenGL::GetDescription(void)
bool MythRenderOpenGL::UpdateTextureVertices(MythGLTexture *Texture, const QRect &Source,
const QRect &Destination, int Rotation, qreal Scale)
{
if (!Texture || (Texture && Texture->m_size.isEmpty()))
if (!Texture || Texture->m_size.isEmpty())
return false;

if ((Texture->m_source == Source) && (Texture->m_destination == Destination) &&
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmythui/vulkan/mythpaintervulkan.cpp
Expand Up @@ -129,7 +129,7 @@ bool MythPainterVulkan::Ready()
// device setup can be delayed by a few frames on startup - check status
// before continuing
auto * window = MythRenderVulkan::GetVulkanRender()->GetVulkanWindow();
if (!window || (window && !window->device()))
if (!window || !window->device())
return false;

m_vulkan = MythVulkanObject::Create(MythRenderVulkan::GetVulkanRender());
Expand Down

0 comments on commit c5ff4fa

Please sign in to comment.