From b6bdbf5574071cc03c73f5a9d4e14daa1c789a72 Mon Sep 17 00:00:00 2001 From: Rosen Penev Date: Mon, 7 Mar 2022 14:41:06 -0800 Subject: [PATCH] clang-tidy: don't use else after return/throw Signed-off-by: Rosen Penev --- samples/exifprint.cpp | 3 ++- src/types.cpp | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/samples/exifprint.cpp b/samples/exifprint.cpp index 65ff5e47..bc5c3d2a 100644 --- a/samples/exifprint.cpp +++ b/samples/exifprint.cpp @@ -58,7 +58,8 @@ try { std::vector keys; Exiv2::dumpLibraryInfo(std::cout,keys); return rc; - } else if ( strcmp(file,"--version-test") == 0 ) { + } + if (strcmp(file, "--version-test") == 0) { // verifies/test macro EXIV2_TEST_VERSION // described in include/exiv2/version.hpp std::cout << "EXV_PACKAGE_VERSION " << EXV_PACKAGE_VERSION << std::endl diff --git a/src/types.cpp b/src/types.cpp index 8f6ba372..19e8066e 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -199,7 +199,8 @@ namespace Exiv2 { /// \todo this first check should be for <= offset if (pData_.size() < offset) { throw std::overflow_error("Overflow in Exiv2::DataBuf::c_data"); - } else if (pData_.empty() || pData_.size() == offset) { + } + if (pData_.empty() || pData_.size() == offset) { return nullptr; } return &pData_[offset]; @@ -209,7 +210,8 @@ namespace Exiv2 { /// \todo this first check should be for <= offset if (pData_.size() < offset) { throw std::overflow_error("Overflow in Exiv2::DataBuf::c_data"); - } else if (pData_.empty() || pData_.size() == offset) { + } + if (pData_.empty() || pData_.size() == offset) { return nullptr; } return &pData_[offset];