From 8b0e6ac7eac18a6ef0ce965e4c46a8685dba0395 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Devernay?= Date: Mon, 14 Mar 2016 09:02:39 +0100 Subject: [PATCH] fix coverity issues --- AppendClip/AppendClip.cpp | 2 ++ Dissolve/Dissolve.cpp | 2 ++ Merge/Merge.cpp | 1 + Switch/Switch.cpp | 2 ++ TimeBuffer/TimeBuffer.cpp | 8 ++++++++ 5 files changed, 15 insertions(+) diff --git a/AppendClip/AppendClip.cpp b/AppendClip/AppendClip.cpp index 62cd2216e..1da691533 100644 --- a/AppendClip/AppendClip.cpp +++ b/AppendClip/AppendClip.cpp @@ -112,6 +112,7 @@ class AppendClipPlugin assert(i < 1000); name[0] = (i < 10) ? ('0' + i) : ((i < 100) ? ('0' + i / 10) : ('0' + i / 100)); name[1] = (i < 10) ? 0 : ((i < 100) ? ('0' + i % 10) : ('0' + ((i/10)%10))); + // coverity[dead_error_line] name[2] = (i < 10) ? 0 : ((i < 100) ? 0 : ('0' + i % 10)); _srcClip[j] = fetchClip(name); } @@ -927,6 +928,7 @@ AppendClipPluginFactory::describeInContext(OFX::ImageEffectDescriptor &desc, assert(i < 1000); name[0] = (i < 10) ? ('0' + i) : ((i < 100) ? ('0' + i / 10) : ('0' + i / 100)); name[1] = (i < 10) ? 0 : ((i < 100) ? ('0' + i % 10) : ('0' + ((i/10)%10))); + // coverity[dead_error_line] name[2] = (i < 10) ? 0 : ((i < 100) ? 0 : ('0' + i % 10)); srcClip = desc.defineClip(name); srcClip->setOptional(true); diff --git a/Dissolve/Dissolve.cpp b/Dissolve/Dissolve.cpp index 9df45f639..5ee4327f7 100644 --- a/Dissolve/Dissolve.cpp +++ b/Dissolve/Dissolve.cpp @@ -82,6 +82,7 @@ class DissolvePlugin char name[4] = { 0, 0, 0, 0 }; // don't use std::stringstream (not thread-safe on OSX) name[0] = (i < 10) ? ('0' + i) : ((i < 100) ? ('0' + i / 10) : ('0' + i / 100)); name[1] = (i < 10) ? 0 : ((i < 100) ? ('0' + i % 10) : ('0' + ((i/10)%10))); + // coverity[dead_error_line] name[2] = (i < 10) ? 0 : ((i < 100) ? 0 : ('0' + i % 10)); _srcClip[i] = fetchClip(name); } @@ -553,6 +554,7 @@ DissolvePluginFactory::describeInContext(OFX::ImageEffectDescriptor &desc, char name[4] = { 0, 0, 0, 0 }; // don't use std::stringstream (not thread-safe on OSX) name[0] = (i < 10) ? ('0' + i) : ((i < 100) ? ('0' + i / 10) : ('0' + i / 100)); name[1] = (i < 10) ? 0 : ((i < 100) ? ('0' + i % 10) : ('0' + ((i/10)%10))); + // coverity[dead_error_line] name[2] = (i < 10) ? 0 : ((i < 100) ? 0 : ('0' + i % 10)); srcClip = desc.defineClip(name); srcClip->setOptional(true); diff --git a/Merge/Merge.cpp b/Merge/Merge.cpp index 8b2ffb127..66a4313ed 100644 --- a/Merge/Merge.cpp +++ b/Merge/Merge.cpp @@ -1171,6 +1171,7 @@ MergePluginFactory::describeInContext(OFX::ImageEffectDescriptor &desc, assert(i < 1000); name[1] = (i < 10) ? ('0' + i) : ((i < 100) ? ('0' + i / 10) : ('0' + i / 100)); name[2] = (i < 10) ? 0 : ((i < 100) ? ('0' + i % 10) : ('0' + ((i/10)%10))); + // coverity[dead_error_line] name[3] = (i < 10) ? 0 : ((i < 100) ? 0 : ('0' + i % 10)); OFX::ClipDescriptor* optionalSrcClip = desc.defineClip(name); optionalSrcClip->addSupportedComponent( OFX::ePixelComponentRGBA ); diff --git a/Switch/Switch.cpp b/Switch/Switch.cpp index 2db968e06..3674c5ae5 100644 --- a/Switch/Switch.cpp +++ b/Switch/Switch.cpp @@ -168,6 +168,7 @@ SwitchPlugin::SwitchPlugin(OfxImageEffectHandle handle, bool numerousInputs) char name[4] = { 0, 0, 0, 0 }; // don't use std::stringstream (not thread-safe on OSX) name[0] = (i < 10) ? ('0' + i) : ((i < 100) ? ('0' + i / 10) : ('0' + i / 100)); name[1] = (i < 10) ? 0 : ((i < 100) ? ('0' + i % 10) : ('0' + ((i/10)%10))); + // coverity[dead_error_line] name[2] = (i < 10) ? 0 : ((i < 100) ? 0 : ('0' + i % 10)); _srcClip[i] = fetchClip(name); } @@ -434,6 +435,7 @@ void SwitchPluginFactory::describeInContext(OFX::ImageEffectDescriptor &desc, OF char name[4] = { 0, 0, 0, 0 }; // don't use std::stringstream (not thread-safe on OSX) name[0] = (i < 10) ? ('0' + i) : ((i < 100) ? ('0' + i / 10) : ('0' + i / 100)); name[1] = (i < 10) ? 0 : ((i < 100) ? ('0' + i % 10) : ('0' + ((i/10)%10))); + // coverity[dead_error_line] name[2] = (i < 10) ? 0 : ((i < 100) ? 0 : ('0' + i % 10)); srcClip = desc.defineClip(name); srcClip->setOptional(true); diff --git a/TimeBuffer/TimeBuffer.cpp b/TimeBuffer/TimeBuffer.cpp index b14ffe372..b07c661db 100644 --- a/TimeBuffer/TimeBuffer.cpp +++ b/TimeBuffer/TimeBuffer.cpp @@ -390,19 +390,23 @@ class TimeBufferReadPlugin : public OFX::ImageEffect if (!timeBuffer) { setPersistentMessage(OFX::Message::eMessageError, "", std::string("No TimeBuffer exists with name \"")+_name+"\". Try using another name."); throwSuiteStatusException(kOfxStatFailed); + return NULL; } if (timeBuffer && !timeBuffer->readInstance) { setPersistentMessage(OFX::Message::eMessageError, "", std::string("Another TimeBufferRead already exists with name \"")+_name+"\". Try using another name."); throwSuiteStatusException(kOfxStatFailed); + return NULL; } if (timeBuffer && timeBuffer->readInstance && timeBuffer->readInstance != this) { // a buffer already exists with that name setPersistentMessage(OFX::Message::eMessageError, "", std::string("Another TimeBufferRead already exists with name \"")+_name+"\". Try using another name."); throwSuiteStatusException(kOfxStatFailed); + return NULL; } if (timeBuffer && !timeBuffer->writeInstance) { setPersistentMessage(OFX::Message::eMessageError, "", std::string("No TimeBufferWrite exists with name \"")+_name+"\". Create one and connect it to this TimeBufferRead via the Sync input."); throwSuiteStatusException(kOfxStatFailed); + return NULL; } return timeBuffer; } @@ -447,6 +451,7 @@ TimeBufferReadPlugin::render(const OFX::RenderArguments &args) (dst->getField() != OFX::eFieldNone /* for DaVinci Resolve */ && dst->getField() != args.fieldToRender)) { setPersistentMessage(OFX::Message::eMessageError, "", "OFX Host gave image with wrong scale or field properties"); OFX::throwSuiteStatusException(kOfxStatFailed); + return; } OFX::BitDepthEnum dstBitDepth = dst->getPixelDepth(); OFX::PixelComponentEnum dstComponents = dst->getPixelComponents(); @@ -460,6 +465,7 @@ TimeBufferReadPlugin::render(const OFX::RenderArguments &args) timeBuffer = getBuffer(); if (!timeBuffer) { throwSuiteStatusException(kOfxStatFailed); + return; } int startFrame = _startFrame->getValue(); // * if t <= startTime: @@ -562,6 +568,7 @@ TimeBufferReadPlugin::getClipPreferences(OFX::ClipPreferencesSetter &clipPrefere TimeBuffer* timeBuffer = getBuffer(); if (!timeBuffer) { throwSuiteStatusException(kOfxStatFailed); + return; } clearPersistentMessage(); clipPreferences.setOutputFrameVarying(true); @@ -576,6 +583,7 @@ TimeBufferReadPlugin::getRegionOfDefinition(const OFX::RegionOfDefinitionArgumen timeBuffer = getBuffer(); if (!timeBuffer) { throwSuiteStatusException(kOfxStatFailed); + return; } // * if t <= startTime: // - the RoD is empty