From f453ee7d3ab4be78f7bd0be5aa14d2a281552629 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Fri, 7 Aug 2020 12:32:45 +0200 Subject: Cleanup: Compositor, Clang-Tidy else-after-return fixes This addresses warnings from Clang-Tidy's `readability-else-after-return` rule in the `source/blender/compositor` module. No functional changes. --- .../compositor/intern/COM_CompositorContext.cpp | 5 +-- source/blender/compositor/intern/COM_Converter.cpp | 10 ++--- .../blender/compositor/intern/COM_MemoryBuffer.cpp | 7 ++- .../compositor/intern/COM_NodeOperation.cpp | 51 ++++++++++------------ .../operations/COM_AntiAliasOperation.cpp | 6 +-- .../COM_ConvertDepthToRadiusOperation.cpp | 5 +-- .../compositor/operations/COM_DenoiseOperation.cpp | 15 +++---- .../operations/COM_DisplaceOperation.cpp | 13 +++--- .../operations/COM_DoubleEdgeMaskOperation.cpp | 5 +-- .../operations/COM_FastGaussianBlurOperation.cpp | 33 +++++++------- .../operations/COM_GaussianBokehBlurOperation.cpp | 46 ++++++++++--------- .../operations/COM_GlareBaseOperation.cpp | 15 +++---- .../operations/COM_GlareGhostOperation.cpp | 5 +-- .../compositor/operations/COM_InpaintOperation.cpp | 15 +++---- .../compositor/operations/COM_MapUVOperation.cpp | 15 +++---- .../operations/COM_OutputFileOperation.cpp | 5 +-- .../COM_ScreenLensDistortionOperation.cpp | 5 +-- .../operations/COM_VectorBlurOperation.cpp | 5 +-- .../compositor/operations/COM_ViewerOperation.cpp | 5 +-- 19 files changed, 123 insertions(+), 143 deletions(-) (limited to 'source/blender') diff --git a/source/blender/compositor/intern/COM_CompositorContext.cpp b/source/blender/compositor/intern/COM_CompositorContext.cpp index e572fe7c99e..3d55fcba086 100644 --- a/source/blender/compositor/intern/COM_CompositorContext.cpp +++ b/source/blender/compositor/intern/COM_CompositorContext.cpp @@ -36,7 +36,6 @@ int CompositorContext::getFramenumber() const if (this->m_rd) { return this->m_rd->cfra; } - else { - return -1; /* this should never happen */ - } + + return -1; /* this should never happen */ } diff --git a/source/blender/compositor/intern/COM_Converter.cpp b/source/blender/compositor/intern/COM_Converter.cpp index edfeb3a3a04..60676ee42b7 100644 --- a/source/blender/compositor/intern/COM_Converter.cpp +++ b/source/blender/compositor/intern/COM_Converter.cpp @@ -416,19 +416,19 @@ NodeOperation *Converter::convertDataType(NodeOperationOutput *from, NodeOperati if (fromDatatype == COM_DT_VALUE && toDatatype == COM_DT_COLOR) { return new ConvertValueToColorOperation(); } - else if (fromDatatype == COM_DT_VALUE && toDatatype == COM_DT_VECTOR) { + if (fromDatatype == COM_DT_VALUE && toDatatype == COM_DT_VECTOR) { return new ConvertValueToVectorOperation(); } - else if (fromDatatype == COM_DT_COLOR && toDatatype == COM_DT_VALUE) { + if (fromDatatype == COM_DT_COLOR && toDatatype == COM_DT_VALUE) { return new ConvertColorToValueOperation(); } - else if (fromDatatype == COM_DT_COLOR && toDatatype == COM_DT_VECTOR) { + if (fromDatatype == COM_DT_COLOR && toDatatype == COM_DT_VECTOR) { return new ConvertColorToVectorOperation(); } - else if (fromDatatype == COM_DT_VECTOR && toDatatype == COM_DT_VALUE) { + if (fromDatatype == COM_DT_VECTOR && toDatatype == COM_DT_VALUE) { return new ConvertVectorToValueOperation(); } - else if (fromDatatype == COM_DT_VECTOR && toDatatype == COM_DT_COLOR) { + if (fromDatatype == COM_DT_VECTOR && toDatatype == COM_DT_COLOR) { return new ConvertVectorToColorOperation(); } diff --git a/source/blender/compositor/intern/COM_MemoryBuffer.cpp b/source/blender/compositor/intern/COM_MemoryBuffer.cpp index b958314d1b4..f58d7a768cc 100644 --- a/source/blender/compositor/intern/COM_MemoryBuffer.cpp +++ b/source/blender/compositor/intern/COM_MemoryBuffer.cpp @@ -136,10 +136,9 @@ float MemoryBuffer::getMaximumValue(rcti *rect) delete temp; return result; } - else { - BLI_assert(0); - return 0.0f; - } + + BLI_assert(0); + return 0.0f; } MemoryBuffer::~MemoryBuffer() diff --git a/source/blender/compositor/intern/COM_NodeOperation.cpp b/source/blender/compositor/intern/COM_NodeOperation.cpp index fa4b5a07c65..4e3c5d2df6c 100644 --- a/source/blender/compositor/intern/COM_NodeOperation.cpp +++ b/source/blender/compositor/intern/COM_NodeOperation.cpp @@ -145,9 +145,8 @@ NodeOperation *NodeOperation::getInputOperation(unsigned int inputSocketIndex) if (input && input->isConnected()) { return &input->getLink()->getOperation(); } - else { - return NULL; - } + + return NULL; } void NodeOperation::getConnectedInputSockets(Inputs *sockets) @@ -168,30 +167,29 @@ bool NodeOperation::determineDependingAreaOfInterest(rcti *input, BLI_rcti_init(output, input->xmin, input->xmax, input->ymin, input->ymax); return false; } - else { - rcti tempOutput; - bool first = true; - for (int i = 0; i < getNumberOfInputSockets(); i++) { - NodeOperation *inputOperation = this->getInputOperation(i); - if (inputOperation && - inputOperation->determineDependingAreaOfInterest(input, readOperation, &tempOutput)) { - if (first) { - output->xmin = tempOutput.xmin; - output->ymin = tempOutput.ymin; - output->xmax = tempOutput.xmax; - output->ymax = tempOutput.ymax; - first = false; - } - else { - output->xmin = min(output->xmin, tempOutput.xmin); - output->ymin = min(output->ymin, tempOutput.ymin); - output->xmax = max(output->xmax, tempOutput.xmax); - output->ymax = max(output->ymax, tempOutput.ymax); - } + + rcti tempOutput; + bool first = true; + for (int i = 0; i < getNumberOfInputSockets(); i++) { + NodeOperation *inputOperation = this->getInputOperation(i); + if (inputOperation && + inputOperation->determineDependingAreaOfInterest(input, readOperation, &tempOutput)) { + if (first) { + output->xmin = tempOutput.xmin; + output->ymin = tempOutput.ymin; + output->xmax = tempOutput.xmax; + output->ymax = tempOutput.ymax; + first = false; + } + else { + output->xmin = min(output->xmin, tempOutput.xmin); + output->ymin = min(output->ymin, tempOutput.ymin); + output->xmax = max(output->xmax, tempOutput.xmax); + output->ymax = max(output->ymax, tempOutput.ymax); } } - return !first; } + return !first; } /***************** @@ -210,9 +208,8 @@ SocketReader *NodeOperationInput::getReader() if (isConnected()) { return &m_link->getOperation(); } - else { - return NULL; - } + + return NULL; } void NodeOperationInput::determineResolution(unsigned int resolution[2], diff --git a/source/blender/compositor/operations/COM_AntiAliasOperation.cpp b/source/blender/compositor/operations/COM_AntiAliasOperation.cpp index 85725cc1d37..2c762323104 100644 --- a/source/blender/compositor/operations/COM_AntiAliasOperation.cpp +++ b/source/blender/compositor/operations/COM_AntiAliasOperation.cpp @@ -105,9 +105,9 @@ static int extrapolate9(float *E0, } return 1; } - else { - return 0; - } + + return 0; + #undef PEQ #undef PCPY } diff --git a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp index 66043abd951..50f8eab5fbc 100644 --- a/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp +++ b/source/blender/compositor/operations/COM_ConvertDepthToRadiusOperation.cpp @@ -39,9 +39,8 @@ float ConvertDepthToRadiusOperation::determineFocalDistance() this->m_cam_lens = camera->lens; return BKE_camera_object_dof_distance(this->m_cameraObject); } - else { - return 10.0f; - } + + return 10.0f; } void ConvertDepthToRadiusOperation::initExecution() diff --git a/source/blender/compositor/operations/COM_DenoiseOperation.cpp b/source/blender/compositor/operations/COM_DenoiseOperation.cpp index d9a59002caf..202e614c0c5 100644 --- a/source/blender/compositor/operations/COM_DenoiseOperation.cpp +++ b/source/blender/compositor/operations/COM_DenoiseOperation.cpp @@ -73,14 +73,13 @@ bool DenoiseOperation::determineDependingAreaOfInterest(rcti * /*input*/, if (isCached()) { return false; } - else { - rcti newInput; - newInput.xmax = this->getWidth(); - newInput.xmin = 0; - newInput.ymax = this->getHeight(); - newInput.ymin = 0; - return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); - } + + rcti newInput; + newInput.xmax = this->getWidth(); + newInput.xmin = 0; + newInput.ymax = this->getHeight(); + newInput.ymin = 0; + return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } void DenoiseOperation::generateDenoise(float *data, diff --git a/source/blender/compositor/operations/COM_DisplaceOperation.cpp b/source/blender/compositor/operations/COM_DisplaceOperation.cpp index b775bfdee4c..73790447216 100644 --- a/source/blender/compositor/operations/COM_DisplaceOperation.cpp +++ b/source/blender/compositor/operations/COM_DisplaceOperation.cpp @@ -74,13 +74,12 @@ bool DisplaceOperation::read_displacement( r_v = 0.0f; return false; } - else { - float col[4]; - m_inputVectorProgram->readSampled(col, x, y, COM_PS_BILINEAR); - r_u = origin[0] - col[0] * xscale; - r_v = origin[1] - col[1] * yscale; - return true; - } + + float col[4]; + m_inputVectorProgram->readSampled(col, x, y, COM_PS_BILINEAR); + r_u = origin[0] - col[0] * xscale; + r_v = origin[1] - col[1] * yscale; + return true; } void DisplaceOperation::pixelTransform(const float xy[2], float r_uv[2], float r_deriv[2][2]) diff --git a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp index 84f7fe2d225..675a402de6f 100644 --- a/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp +++ b/source/blender/compositor/operations/COM_DoubleEdgeMaskOperation.cpp @@ -1330,9 +1330,8 @@ bool DoubleEdgeMaskOperation::determineDependingAreaOfInterest(rcti * /*input*/, newInput.ymin = 0; return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } - else { - return false; - } + + return false; } void DoubleEdgeMaskOperation::initExecution() diff --git a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp index 7a6b69d12fa..0ccb959712f 100644 --- a/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_FastGaussianBlurOperation.cpp @@ -47,18 +47,17 @@ bool FastGaussianBlurOperation::determineDependingAreaOfInterest( if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) { return true; } - else { - if (this->m_iirgaus) { - return false; - } - else { - newInput.xmin = 0; - newInput.ymin = 0; - newInput.xmax = this->getWidth(); - newInput.ymax = this->getHeight(); - } - return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); + + if (this->m_iirgaus) { + return false; } + + newInput.xmin = 0; + newInput.ymin = 0; + newInput.xmax = this->getWidth(); + newInput.ymax = this->getHeight(); + + return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } void FastGaussianBlurOperation::initExecution() @@ -282,12 +281,12 @@ bool FastGaussianBlurValueOperation::determineDependingAreaOfInterest( if (this->m_iirgaus) { return false; } - else { - newInput.xmin = 0; - newInput.ymin = 0; - newInput.xmax = this->getWidth(); - newInput.ymax = this->getHeight(); - } + + newInput.xmin = 0; + newInput.ymin = 0; + newInput.xmax = this->getWidth(); + newInput.ymax = this->getHeight(); + return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } diff --git a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp index 43e571c4bb7..dd479da864c 100644 --- a/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_GaussianBokehBlurOperation.cpp @@ -176,23 +176,22 @@ bool GaussianBokehBlurOperation::determineDependingAreaOfInterest( if (operation->determineDependingAreaOfInterest(&sizeInput, readOperation, output)) { return true; } + + if (this->m_sizeavailable && this->m_gausstab != NULL) { + newInput.xmin = 0; + newInput.ymin = 0; + newInput.xmax = this->getWidth(); + newInput.ymax = this->getHeight(); + } else { - if (this->m_sizeavailable && this->m_gausstab != NULL) { - newInput.xmin = 0; - newInput.ymin = 0; - newInput.xmax = this->getWidth(); - newInput.ymax = this->getHeight(); - } - else { - int addx = this->m_radx; - int addy = this->m_rady; - newInput.xmax = input->xmax + addx; - newInput.xmin = input->xmin - addx; - newInput.ymax = input->ymax + addy; - newInput.ymin = input->ymin - addy; - } - return BlurBaseOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); + int addx = this->m_radx; + int addy = this->m_rady; + newInput.xmax = input->xmax + addx; + newInput.xmin = input->xmin - addx; + newInput.ymax = input->ymax + addy; + newInput.ymin = input->ymin - addy; } + return BlurBaseOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } // reference image @@ -351,13 +350,12 @@ bool GaussianBlurReferenceOperation::determineDependingAreaOfInterest( if (operation->determineDependingAreaOfInterest(input, readOperation, output)) { return true; } - else { - int addx = this->m_data.sizex + 2; - int addy = this->m_data.sizey + 2; - newInput.xmax = input->xmax + addx; - newInput.xmin = input->xmin - addx; - newInput.ymax = input->ymax + addy; - newInput.ymin = input->ymin - addy; - return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); - } + + int addx = this->m_data.sizex + 2; + int addy = this->m_data.sizey + 2; + newInput.xmax = input->xmax + addx; + newInput.xmin = input->xmin - addx; + newInput.ymax = input->ymax + addy; + newInput.ymin = input->ymin - addy; + return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } diff --git a/source/blender/compositor/operations/COM_GlareBaseOperation.cpp b/source/blender/compositor/operations/COM_GlareBaseOperation.cpp index 593f1eaeefa..278e65a7dfd 100644 --- a/source/blender/compositor/operations/COM_GlareBaseOperation.cpp +++ b/source/blender/compositor/operations/COM_GlareBaseOperation.cpp @@ -58,12 +58,11 @@ bool GlareBaseOperation::determineDependingAreaOfInterest(rcti * /*input*/, if (isCached()) { return false; } - else { - rcti newInput; - newInput.xmax = this->getWidth(); - newInput.xmin = 0; - newInput.ymax = this->getHeight(); - newInput.ymin = 0; - return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); - } + + rcti newInput; + newInput.xmax = this->getWidth(); + newInput.xmin = 0; + newInput.ymax = this->getHeight(); + newInput.ymin = 0; + return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } diff --git a/source/blender/compositor/operations/COM_GlareGhostOperation.cpp b/source/blender/compositor/operations/COM_GlareGhostOperation.cpp index 9f01cf5d63a..760b833d1e1 100644 --- a/source/blender/compositor/operations/COM_GlareGhostOperation.cpp +++ b/source/blender/compositor/operations/COM_GlareGhostOperation.cpp @@ -28,9 +28,8 @@ static float smoothMask(float x, float y) if ((t = 1.0f - sqrtf(x * x + y * y)) > 0.0f) { return t; } - else { - return 0.0f; - } + + return 0.0f; } void GlareGhostOperation::generateGlare(float *data, MemoryBuffer *inputTile, NodeGlare *settings) diff --git a/source/blender/compositor/operations/COM_InpaintOperation.cpp b/source/blender/compositor/operations/COM_InpaintOperation.cpp index b8329b1cb29..0555ee24b9b 100644 --- a/source/blender/compositor/operations/COM_InpaintOperation.cpp +++ b/source/blender/compositor/operations/COM_InpaintOperation.cpp @@ -272,14 +272,13 @@ bool InpaintSimpleOperation::determineDependingAreaOfInterest(rcti * /*input*/, if (this->m_cached_buffer_ready) { return false; } - else { - rcti newInput; - newInput.xmax = getWidth(); - newInput.xmin = 0; - newInput.ymax = getHeight(); - newInput.ymin = 0; + rcti newInput; - return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); - } + newInput.xmax = getWidth(); + newInput.xmin = 0; + newInput.ymax = getHeight(); + newInput.ymin = 0; + + return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } diff --git a/source/blender/compositor/operations/COM_MapUVOperation.cpp b/source/blender/compositor/operations/COM_MapUVOperation.cpp index de55c9fb4b8..9101b82202a 100644 --- a/source/blender/compositor/operations/COM_MapUVOperation.cpp +++ b/source/blender/compositor/operations/COM_MapUVOperation.cpp @@ -87,14 +87,13 @@ bool MapUVOperation::read_uv(float x, float y, float &r_u, float &r_v, float &r_ r_alpha = 0.0f; return false; } - else { - float vector[3]; - m_inputUVProgram->readSampled(vector, x, y, COM_PS_BILINEAR); - r_u = vector[0] * m_inputColorProgram->getWidth(); - r_v = vector[1] * m_inputColorProgram->getHeight(); - r_alpha = vector[2]; - return true; - } + + float vector[3]; + m_inputUVProgram->readSampled(vector, x, y, COM_PS_BILINEAR); + r_u = vector[0] * m_inputColorProgram->getWidth(); + r_v = vector[1] * m_inputColorProgram->getHeight(); + r_alpha = vector[2]; + return true; } void MapUVOperation::pixelTransform(const float xy[2], diff --git a/source/blender/compositor/operations/COM_OutputFileOperation.cpp b/source/blender/compositor/operations/COM_OutputFileOperation.cpp index ee3779edcb4..374189a5c50 100644 --- a/source/blender/compositor/operations/COM_OutputFileOperation.cpp +++ b/source/blender/compositor/operations/COM_OutputFileOperation.cpp @@ -129,9 +129,8 @@ static float *init_buffer(unsigned int width, unsigned int height, DataType data int size = get_datatype_size(datatype); return (float *)MEM_callocN(width * height * size * sizeof(float), "OutputFile buffer"); } - else { - return NULL; - } + + return NULL; } static void write_buffer_rect(rcti *rect, diff --git a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp index 738c51fc719..b7731a34c91 100644 --- a/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp +++ b/source/blender/compositor/operations/COM_ScreenLensDistortionOperation.cpp @@ -124,9 +124,8 @@ bool ScreenLensDistortionOperation::get_delta(float r_sq, distort_uv(uv, t, delta); return true; } - else { - return false; - } + + return false; } void ScreenLensDistortionOperation::accumulate(MemoryBuffer *buffer, diff --git a/source/blender/compositor/operations/COM_VectorBlurOperation.cpp b/source/blender/compositor/operations/COM_VectorBlurOperation.cpp index 56e0ab9b93f..0f81780bb00 100644 --- a/source/blender/compositor/operations/COM_VectorBlurOperation.cpp +++ b/source/blender/compositor/operations/COM_VectorBlurOperation.cpp @@ -115,9 +115,8 @@ bool VectorBlurOperation::determineDependingAreaOfInterest(rcti * /*input*/, newInput.ymin = 0; return NodeOperation::determineDependingAreaOfInterest(&newInput, readOperation, output); } - else { - return false; - } + + return false; } void VectorBlurOperation::generateVectorBlur(float *data, diff --git a/source/blender/compositor/operations/COM_ViewerOperation.cpp b/source/blender/compositor/operations/COM_ViewerOperation.cpp index fc26d6219e1..3d5d50e1c7f 100644 --- a/source/blender/compositor/operations/COM_ViewerOperation.cpp +++ b/source/blender/compositor/operations/COM_ViewerOperation.cpp @@ -199,7 +199,6 @@ CompositorPriority ViewerOperation::getRenderPriority() const if (this->isActiveViewerOutput()) { return COM_PRIORITY_HIGH; } - else { - return COM_PRIORITY_LOW; - } + + return COM_PRIORITY_LOW; } -- cgit v1.2.3