diff --git a/Common/Core/Testing/Cxx/TestArrayAPI.cxx b/Common/Core/Testing/Cxx/TestArrayAPI.cxx index 1d27b5d55df71a01820659b9f60301604e2e1330..a0e7ddcdfe374f16a430fc0d3d6de3e9c2b280a8 100644 --- a/Common/Core/Testing/Cxx/TestArrayAPI.cxx +++ b/Common/Core/Testing/Cxx/TestArrayAPI.cxx @@ -28,6 +28,7 @@ #include <stdexcept> #define test_expression(expression) \ + do \ { \ if (!(expression)) \ { \ @@ -35,7 +36,7 @@ buffer << "Expression failed at line " << __LINE__ << ": " << #expression; \ throw std::runtime_error(buffer.str()); \ } \ - } + } while (false) int TestArrayAPI(int vtkNotUsed(argc), char* vtkNotUsed(argv)[]) { diff --git a/Common/Core/Testing/Cxx/TestArrayAPIConvenience.cxx b/Common/Core/Testing/Cxx/TestArrayAPIConvenience.cxx index 337d90b35b7a04161ce81b3993207d648c04ae7a..ae7d03711e9d604f850e139c57c9bbd774ef6fc5 100644 --- a/Common/Core/Testing/Cxx/TestArrayAPIConvenience.cxx +++ b/Common/Core/Testing/Cxx/TestArrayAPIConvenience.cxx @@ -27,6 +27,7 @@ #include <stdexcept> #define test_expression(expression) \ + do \ { \ if (!(expression)) \ { \ @@ -34,7 +35,7 @@ buffer << "Expression failed at line " << __LINE__ << ": " << #expression; \ throw std::runtime_error(buffer.str()); \ } \ - } + } while (false) int TestArrayAPIConvenience(int vtkNotUsed(argc), char* vtkNotUsed(argv)[]) { diff --git a/Common/Core/Testing/Cxx/TestArrayAPIDense.cxx b/Common/Core/Testing/Cxx/TestArrayAPIDense.cxx index 0c0df3b14734bbf520e4a46e2bd7296d82a05206..480881e5dafd8902872e88dbf6a9ed8cf92636af 100644 --- a/Common/Core/Testing/Cxx/TestArrayAPIDense.cxx +++ b/Common/Core/Testing/Cxx/TestArrayAPIDense.cxx @@ -27,6 +27,7 @@ #include <stdexcept> #define test_expression(expression) \ + do \ { \ if (!(expression)) \ { \ @@ -34,7 +35,7 @@ buffer << "Expression failed at line " << __LINE__ << ": " << #expression; \ throw std::runtime_error(buffer.str()); \ } \ - } + } while (false) int TestArrayAPIDense(int vtkNotUsed(argc), char* vtkNotUsed(argv)[]) { diff --git a/Common/Core/Testing/Cxx/TestArrayAPISparse.cxx b/Common/Core/Testing/Cxx/TestArrayAPISparse.cxx index 8610cb2123101cc7d491ccdd20ba87de1b0ad4e7..8c717ee447cdff9250f68651230ce6051da83e10 100644 --- a/Common/Core/Testing/Cxx/TestArrayAPISparse.cxx +++ b/Common/Core/Testing/Cxx/TestArrayAPISparse.cxx @@ -30,10 +30,11 @@ #include <vector> #define test_expression(expression) \ + do \ { \ if (!(expression)) \ throw std::runtime_error("Expression failed: " #expression); \ - } + } while (false) int TestArrayAPISparse(int vtkNotUsed(argc), char* vtkNotUsed(argv)[]) { diff --git a/Common/Core/Testing/Cxx/TestArrayBool.cxx b/Common/Core/Testing/Cxx/TestArrayBool.cxx index 6777a56730d6cb31b3e3a24882ae5c04b6cb89cb..afe0b421ad55aa0b2ddb47ec0a780e3e5fa796dc 100644 --- a/Common/Core/Testing/Cxx/TestArrayBool.cxx +++ b/Common/Core/Testing/Cxx/TestArrayBool.cxx @@ -28,6 +28,7 @@ #include <stdexcept> #define test_expression(expression) \ + do \ { \ if (!(expression)) \ { \ @@ -35,7 +36,7 @@ buffer << "Expression failed at line " << __LINE__ << ": " << #expression; \ throw std::runtime_error(buffer.str()); \ } \ - } + } while (false) int TestArrayBool(int vtkNotUsed(argc), char* vtkNotUsed(argv)[]) { diff --git a/Common/Core/Testing/Cxx/TestArrayExtents.cxx b/Common/Core/Testing/Cxx/TestArrayExtents.cxx index e29fe1f4575051fecd7e228d934c4674f6461ba3..c6a754dbc350d2b2748f290ecd0a89dd93c24ecc 100644 --- a/Common/Core/Testing/Cxx/TestArrayExtents.cxx +++ b/Common/Core/Testing/Cxx/TestArrayExtents.cxx @@ -28,6 +28,7 @@ #include <stdexcept> #define test_expression(expression) \ + do \ { \ if (!(expression)) \ { \ @@ -35,7 +36,7 @@ buffer << "Expression failed at line " << __LINE__ << ": " << #expression; \ throw std::runtime_error(buffer.str()); \ } \ - } + } while (false) int TestArrayExtents(int vtkNotUsed(argc), char* vtkNotUsed(argv)[]) { diff --git a/Common/Core/Testing/Cxx/TestArrayFreeFunctions.cxx b/Common/Core/Testing/Cxx/TestArrayFreeFunctions.cxx index 7764d7750f540cea3b4c298e1a06014c2171111e..7ba44722e9c1cc4fed3938d4baec3b58c90b801f 100644 --- a/Common/Core/Testing/Cxx/TestArrayFreeFunctions.cxx +++ b/Common/Core/Testing/Cxx/TestArrayFreeFunctions.cxx @@ -57,11 +57,14 @@ int timesLambdaFreeCalled = 0; //------------------------------------------------------------------------------ #define testAssert(expr, errorMessage) \ - if (!(expr)) \ + do \ { \ - ++errors; \ - vtkGenericWarningMacro(<< "Assertion failed: " #expr << "\n" << errorMessage); \ - } + if (!(expr)) \ + { \ + ++errors; \ + vtkGenericWarningMacro(<< "Assertion failed: " #expr << "\n" << errorMessage); \ + } \ + } while (false) //------------------------------------------------------------------------------ void* make_allocation(UseFree, std::size_t size, int) diff --git a/Common/Core/Testing/Cxx/TestArraySize.cxx b/Common/Core/Testing/Cxx/TestArraySize.cxx index 1cf46a115e912a0201d46f7fd012bf03c37e678a..370f9f38fa5a3eda9bfc9b860acc41e869c85fe7 100644 --- a/Common/Core/Testing/Cxx/TestArraySize.cxx +++ b/Common/Core/Testing/Cxx/TestArraySize.cxx @@ -28,6 +28,7 @@ #include <stdexcept> #define test_expression(expression) \ + do \ { \ if (!(expression)) \ { \ @@ -35,7 +36,7 @@ buffer << "Expression failed at line " << __LINE__ << ": " << #expression; \ throw std::runtime_error(buffer.str()); \ } \ - } + } while (false) int TestArraySize(int vtkNotUsed(argc), char* vtkNotUsed(argv)[]) { diff --git a/Common/Core/Testing/Cxx/TestArrayUserTypes.cxx b/Common/Core/Testing/Cxx/TestArrayUserTypes.cxx index c865ad41b7b22271f93ea444a83159b9e413a09b..afa13b28639bf01ba3deda8b99ee913e25ee4c0f 100644 --- a/Common/Core/Testing/Cxx/TestArrayUserTypes.cxx +++ b/Common/Core/Testing/Cxx/TestArrayUserTypes.cxx @@ -28,6 +28,7 @@ #include <stdexcept> #define test_expression(expression) \ + do \ { \ if (!(expression)) \ { \ @@ -35,7 +36,7 @@ buffer << "Expression failed at line " << __LINE__ << ": " << #expression; \ throw std::runtime_error(buffer.str()); \ } \ - } + } while (false) class UserType { diff --git a/Common/Core/Testing/Cxx/TestArrayVariants.cxx b/Common/Core/Testing/Cxx/TestArrayVariants.cxx index 1e9e94c130b064f611ba5ca45f730cd6b7d44953..c72345956b0f0fadd0f1bb20b3589466d77d500c 100644 --- a/Common/Core/Testing/Cxx/TestArrayVariants.cxx +++ b/Common/Core/Testing/Cxx/TestArrayVariants.cxx @@ -27,6 +27,7 @@ #include <stdexcept> #define test_expression(expression) \ + do \ { \ if (!(expression)) \ { \ @@ -34,7 +35,7 @@ buffer << "Expression failed at line " << __LINE__ << ": " << #expression; \ throw std::runtime_error(buffer.str()); \ } \ - } + } while (false) int TestArrayVariants(int vtkNotUsed(argc), char* vtkNotUsed(argv)[]) { diff --git a/Common/Core/Testing/Cxx/TestDataArraySelection.cxx b/Common/Core/Testing/Cxx/TestDataArraySelection.cxx index ce38edc8b063964749a77afe1514667840b6ff05..797af65d0e614e7d999b376295f59803fb83bdca 100644 --- a/Common/Core/Testing/Cxx/TestDataArraySelection.cxx +++ b/Common/Core/Testing/Cxx/TestDataArraySelection.cxx @@ -2,10 +2,13 @@ #include "vtkNew.h" #define TASSERT(x) \ - if (!(x)) \ + do \ { \ - cerr << "ERROR: failed at " << __LINE__ << "!" << endl; /*return EXIT_FAILURE;*/ \ - } + if (!(x)) \ + { \ + cerr << "ERROR: failed at " << __LINE__ << "!" << endl; /*return EXIT_FAILURE;*/ \ + } \ + } while (false) int TestDataArraySelection(int, char*[]) { diff --git a/Common/Core/Testing/Cxx/TestDataArrayValueRange.cxx b/Common/Core/Testing/Cxx/TestDataArrayValueRange.cxx index c2564e6ed4b4c9d4fa095266029303dcdcd11d48..7db0f47560f0ed793d6837b01f1bb8d4e07c5aba 100644 --- a/Common/Core/Testing/Cxx/TestDataArrayValueRange.cxx +++ b/Common/Core/Testing/Cxx/TestDataArrayValueRange.cxx @@ -47,18 +47,24 @@ std::size_t NumErrors = 0; // Various properties required by random access iterators: #define CHECK_ITER_TYPE(type) \ - static_assert(std::is_default_constructible<Iter>::value, \ - "Iterator types must be default constructable at " LOCATION()); \ - static_assert(std::is_copy_constructible<Iter>::value, \ - "Iterator types must be copy constructible at " LOCATION()); \ - static_assert(std::is_copy_assignable<Iter>::value, \ - "Iterator types must be copy assignable at " LOCATION()); \ - static_assert( \ - std::is_destructible<Iter>::value, "Iterator types must be destructible at " LOCATION()); + do \ + { \ + static_assert(std::is_default_constructible<Iter>::value, \ + "Iterator types must be default constructable at " LOCATION()); \ + static_assert(std::is_copy_constructible<Iter>::value, \ + "Iterator types must be copy constructible at " LOCATION()); \ + static_assert(std::is_copy_assignable<Iter>::value, \ + "Iterator types must be copy assignable at " LOCATION()); \ + static_assert( \ + std::is_destructible<Iter>::value, "Iterator types must be destructible at " LOCATION()); \ + } while (false) #define LOG_ERROR(message) \ - ++NumErrors; \ - std::cerr << NumErrors << ": " << message << "\n" + do \ + { \ + ++NumErrors; \ + std::cerr << NumErrors << ": " << message << "\n"; \ + } while (false) #define CHECK_TRUE(expr) \ do \ diff --git a/Common/Core/Testing/Cxx/TestGenericDataArrayAPI.cxx b/Common/Core/Testing/Cxx/TestGenericDataArrayAPI.cxx index ce4f18961140336a4dd21b94337c5a495f1eda34..c55baccfe934a46430efa69dc3d93f44286fbcca 100644 --- a/Common/Core/Testing/Cxx/TestGenericDataArrayAPI.cxx +++ b/Common/Core/Testing/Cxx/TestGenericDataArrayAPI.cxx @@ -173,6 +173,7 @@ int TestGenericDataArrayAPI(int, char*[]) #define DataArrayAPICreateTestArray(name) vtkNew<ArrayT> name #define DataArrayAPINonFatalError(x) \ + do \ { \ ArrayT* errorTempArray = ArrayT::New(); \ std::cerr << "Line " << __LINE__ << ": " \ @@ -182,9 +183,11 @@ int TestGenericDataArrayAPI(int, char*[]) << x << std::endl; \ errorTempArray->Delete(); \ ++errors; \ - } + } while (false) -#define DataArrayAPIError(x) DataArrayAPINonFatalError(x) return errors; +#define DataArrayAPIError(x) \ + DataArrayAPINonFatalError(x); \ + return errors namespace { diff --git a/Common/Core/Testing/Cxx/TestLookupTable.cxx b/Common/Core/Testing/Cxx/TestLookupTable.cxx index aae44a234331a207b531d1a7395a8c52b06377e2..6d4f51301dd36c9bb3554afcd42b0ff22cebdaf2 100644 --- a/Common/Core/Testing/Cxx/TestLookupTable.cxx +++ b/Common/Core/Testing/Cxx/TestLookupTable.cxx @@ -22,12 +22,15 @@ // simple macro for performing tests #define TestAssert(t) \ - if (!(t)) \ + do \ { \ - cerr << "In " << __FILE__ << ":"; \ - cerr << " Test assertion failed line " << __LINE__ << ": " << #t << "\n"; \ - rval |= 1; \ - } + if (!(t)) \ + { \ + cerr << "In " << __FILE__ << ":"; \ + cerr << " Test assertion failed line " << __LINE__ << ": " << #t << "\n"; \ + rval |= 1; \ + } \ + } while (false) #define TestVector4d(t1, t2) \ TestAssert((vtkMathUtilities::FuzzyCompare<double>(t1[0], t2[0]) && \ diff --git a/Common/Core/Testing/Cxx/TestMath.cxx b/Common/Core/Testing/Cxx/TestMath.cxx index 49f734418c79b23509ac8bf16196322b67c74594..41b5062595a7ae90d3cce9a055867a7ced0c71fe 100644 --- a/Common/Core/Testing/Cxx/TestMath.cxx +++ b/Common/Core/Testing/Cxx/TestMath.cxx @@ -726,12 +726,15 @@ static int TestColorConvert( Triple result1; #define COMPARE(testname, target, dest) \ - if ((target) != (dest)) \ + do \ { \ - vtkGenericWarningMacro(<< "Incorrect " #testname " conversion. Got " << (dest) \ - << " expected " << (target)); \ - return 0; \ - } + if ((target) != (dest)) \ + { \ + vtkGenericWarningMacro(<< "Incorrect " #testname " conversion. Got " << (dest) \ + << " expected " << (target)); \ + return 0; \ + } \ + } while (false) // Test conversion between RGB and HSV. vtkMath::RGBToHSV(rgb(), result1()); diff --git a/Common/Core/Testing/Cxx/TestSparseArrayValidation.cxx b/Common/Core/Testing/Cxx/TestSparseArrayValidation.cxx index a90facc7e31d49f552dbb62bf8016e87dd3aadc7..1dbfb191ea90ae2085c687549359985e20bc82ff 100644 --- a/Common/Core/Testing/Cxx/TestSparseArrayValidation.cxx +++ b/Common/Core/Testing/Cxx/TestSparseArrayValidation.cxx @@ -28,10 +28,11 @@ #include <stdexcept> #define test_expression(expression) \ + do \ { \ if (!(expression)) \ throw std::runtime_error("Expression failed: " #expression); \ - } + } while (false) int TestSparseArrayValidation(int vtkNotUsed(argc), char* vtkNotUsed(argv)[]) { diff --git a/Common/Core/Testing/Cxx/TestVariantComparison.cxx b/Common/Core/Testing/Cxx/TestVariantComparison.cxx index eeaa58b6c1026b4b4f0827819cfb44eeb4a4940c..86a166b7ce9645349e609faeb5c17e46e35dfc99 100644 --- a/Common/Core/Testing/Cxx/TestVariantComparison.cxx +++ b/Common/Core/Testing/Cxx/TestVariantComparison.cxx @@ -93,22 +93,24 @@ int TestVariantComparison(int, char*[]) int overallErrorCount = 0; #define CHECK_EXPRESSION_FALSE(expr) \ + do \ { \ if ((expr)) \ { \ ++errorCount; \ cerr << "TEST FAILED: " << #expr << " should have been false\n\n"; \ } \ - } + } while (false) #define CHECK_EXPRESSION_TRUE(expr) \ + do \ { \ if (!(expr)) \ { \ ++errorCount; \ cerr << "TEST FAILED: " << #expr << " should have been true\n\n"; \ } \ - } + } while (false) cerr << "Testing same-type comparisons... "; CHECK_EXPRESSION_FALSE(positiveCharVariant < negativeCharVariant); diff --git a/Common/Core/vtkScalarsToColors.cxx b/Common/Core/vtkScalarsToColors.cxx index 10591a75db88378932e1f53093a1d40adb4435b2..ac0b29b80636b6d73ddeb374faba27f4d12212e7 100644 --- a/Common/Core/vtkScalarsToColors.cxx +++ b/Common/Core/vtkScalarsToColors.cxx @@ -1485,10 +1485,13 @@ void vtkScalarsToColors::MapScalarsThroughTable2(void* inPtr, unsigned char* out // where 'array' is a vtkDataArray and // 'data' could be: array->GetVoidPointer(0) #define callForAnyType(array, call) \ - switch (array->GetDataType()) \ + do \ { \ - vtkTemplateMacro(call); \ - } + switch (array->GetDataType()) \ + { \ + vtkTemplateMacro(call); \ + } \ + } while (false) //------------------------------------------------------------------------------ vtkUnsignedCharArray* vtkScalarsToColors::ConvertToRGBA( diff --git a/Common/DataModel/Testing/Cxx/TestBoundingBox.cxx b/Common/DataModel/Testing/Cxx/TestBoundingBox.cxx index 4c4a5bd78a12570aa32ad6ed5dae350d61a7bedf..10499f0e11226c4d978dd959951398a6b5aed917 100644 --- a/Common/DataModel/Testing/Cxx/TestBoundingBox.cxx +++ b/Common/DataModel/Testing/Cxx/TestBoundingBox.cxx @@ -20,11 +20,14 @@ #include <limits> #define TestBoundingBoxFailMacro(b, msg) \ - if (!(b)) \ + do \ { \ - std::cerr << msg << std::endl; \ - return EXIT_FAILURE; \ - } + if (!(b)) \ + { \ + std::cerr << msg << std::endl; \ + return EXIT_FAILURE; \ + } \ + } while (false) int TestBoundingBox(int, char*[]) { diff --git a/Common/DataModel/Testing/Cxx/TestCellIterators.cxx b/Common/DataModel/Testing/Cxx/TestCellIterators.cxx index ad440cdb3c47ecc01fb68768b1d70cfb7ef72313..95a6c4e872ac03760884fced9b907c81c8041c39 100644 --- a/Common/DataModel/Testing/Cxx/TestCellIterators.cxx +++ b/Common/DataModel/Testing/Cxx/TestCellIterators.cxx @@ -108,24 +108,27 @@ bool testCellIterator(vtkCellIterator* iter, vtkUnstructuredGrid* grid) } #define TEST_ITERATOR(iter_, className_) \ - if (std::string(#className_) != std::string(iter->GetClassName())) \ + do \ { \ - cerr << "Unexpected iterator type (expected " #className_ ", got " << (iter_)->GetClassName() \ - << ")" << endl; \ - return false; \ - } \ + if (std::string(#className_) != std::string(iter->GetClassName())) \ + { \ + cerr << "Unexpected iterator type (expected " #className_ ", got " \ + << (iter_)->GetClassName() << ")" << endl; \ + return false; \ + } \ \ - if (!testCellIterator(iter_, grid)) \ - { \ - cerr << #className_ << " test failed." << endl; \ - return false; \ - } \ + if (!testCellIterator(iter_, grid)) \ + { \ + cerr << #className_ << " test failed." << endl; \ + return false; \ + } \ \ - if (!testCellIterator(iter_, grid)) \ - { \ - cerr << #className_ << " test failed after rewind." << endl; \ - return false; \ - } + if (!testCellIterator(iter_, grid)) \ + { \ + cerr << #className_ << " test failed after rewind." << endl; \ + return false; \ + } \ + } while (false) bool runValidation(vtkUnstructuredGrid* grid) { diff --git a/Common/DataModel/Testing/Cxx/TestDataAssembly.cxx b/Common/DataModel/Testing/Cxx/TestDataAssembly.cxx index ce057882a61cb8c57ec91c64ea522216d26ee31c..c07da1a61c61d993ccadff6cddeae057801d90e1 100644 --- a/Common/DataModel/Testing/Cxx/TestDataAssembly.cxx +++ b/Common/DataModel/Testing/Cxx/TestDataAssembly.cxx @@ -40,11 +40,14 @@ struct TestFailed : public std::exception } #define VERIFY(x) \ - if (!(x)) \ + do \ { \ - vtkLogF(ERROR, "Failed test '%s'", #x); \ - throw TestFailed{}; \ - } + if (!(x)) \ + { \ + vtkLogF(ERROR, "Failed test '%s'", #x); \ + throw TestFailed{}; \ + } \ + } while (false) int TestDataAssembly(int, char*[]) { diff --git a/Common/DataModel/Testing/Cxx/TestFieldList.cxx b/Common/DataModel/Testing/Cxx/TestFieldList.cxx index 7584a6650f5baa396d1783524e011daafd55b36b..029b93e541d50e386d64d6caf26ac6183e726cf0 100644 --- a/Common/DataModel/Testing/Cxx/TestFieldList.cxx +++ b/Common/DataModel/Testing/Cxx/TestFieldList.cxx @@ -20,11 +20,14 @@ vtkSmartPointer<T> CreateArray(const char* aname, int num_comps, vtkIdType numTu } #define EXPECT_THAT(v, m) \ - if ((v) != (m)) \ + do \ { \ - cerr << "FAILED at line " << __LINE__ << ": \n " << #v << " must match " << #m << endl; \ - return EXIT_FAILURE; \ - } + if ((v) != (m)) \ + { \ + cerr << "FAILED at line " << __LINE__ << ": \n " << #v << " must match " << #m << endl; \ + return EXIT_FAILURE; \ + } \ + } while (false) } int TestFieldList(int, char*[]) diff --git a/Common/DataModel/Testing/Cxx/TestPiecewiseFunction.cxx b/Common/DataModel/Testing/Cxx/TestPiecewiseFunction.cxx index e43bd8b133e17ce6cc96eb950b45974782a37c6e..9865a55022ff7edfa65313e876f7e6f358eac724 100644 --- a/Common/DataModel/Testing/Cxx/TestPiecewiseFunction.cxx +++ b/Common/DataModel/Testing/Cxx/TestPiecewiseFunction.cxx @@ -20,12 +20,15 @@ #include <cmath> #define TEST_ASSERT_FUZZY_EQUAL(expect, actual) \ - if (std::fabs((expect) - (actual)) >= 1e-5) \ + do \ { \ - std::cerr << "Error at line " << __LINE__ << ": Expected value " << (expect) << ", got " \ - << (actual) << std::endl; \ - return EXIT_FAILURE; \ - } + if (std::fabs((expect) - (actual)) >= 1e-5) \ + { \ + std::cerr << "Error at line " << __LINE__ << ": Expected value " << (expect) << ", got " \ + << (actual) << std::endl; \ + return EXIT_FAILURE; \ + } \ + } while (false) int TestPiecewiseFunction(int, char*[]) { diff --git a/Common/DataModel/Testing/Cxx/TestPiecewiseFunctionLogScale.cxx b/Common/DataModel/Testing/Cxx/TestPiecewiseFunctionLogScale.cxx index e6ada17aa15d5d0e0fca5f54d5d242cb1063e311..33f7078de7cf3984c87ed869b06c9a3747e2d79a 100644 --- a/Common/DataModel/Testing/Cxx/TestPiecewiseFunctionLogScale.cxx +++ b/Common/DataModel/Testing/Cxx/TestPiecewiseFunctionLogScale.cxx @@ -21,12 +21,15 @@ // Note that this may evaluate args twice. Use wisely. #define TEST_ASSERT_FUZZY_EQUAL(expect, actual) \ - if (std::fabs((expect) - (actual)) >= 1e-5) \ + do \ { \ - std::cerr << "Error at line " << __LINE__ << ": Expected value " << (expect) << ", got " \ - << (actual) << "\n"; \ - return EXIT_FAILURE; \ - } + if (std::fabs((expect) - (actual)) >= 1e-5) \ + { \ + std::cerr << "Error at line " << __LINE__ << ": Expected value " << (expect) << ", got " \ + << (actual) << "\n"; \ + return EXIT_FAILURE; \ + } \ + } while (false) int TestPiecewiseFunctionLogScale(int, char*[]) { diff --git a/Common/DataModel/vtkBSPIntersections.cxx b/Common/DataModel/vtkBSPIntersections.cxx index d38e83e424e901822ce0223a9a3bbdd2cb58000b..98da8825044ec8f432c60754b1a4eb641fb39ba9 100644 --- a/Common/DataModel/vtkBSPIntersections.cxx +++ b/Common/DataModel/vtkBSPIntersections.cxx @@ -31,21 +31,27 @@ vtkStandardNewMacro(vtkBSPIntersections); #define REGIONCHECK(err) \ - if (this->BuildRegionList()) \ + do \ { \ - return err; \ - } + if (this->BuildRegionList()) \ + { \ + return err; \ + } \ + } while (false) #define REGIONIDCHECK_RETURNERR(id, err) \ - if (this->BuildRegionList()) \ - { \ - return err; \ - } \ - if (((id) < 0) || ((id) >= this->NumberOfRegions)) \ + do \ { \ - vtkErrorMacro(<< "Invalid region ID"); \ - return (err); \ - } + if (this->BuildRegionList()) \ + { \ + return err; \ + } \ + if (((id) < 0) || ((id) >= this->NumberOfRegions)) \ + { \ + vtkErrorMacro(<< "Invalid region ID"); \ + return (err); \ + } \ + } while (false) //------------------------------------------------------------------------------ diff --git a/Common/DataModel/vtkKdTree.cxx b/Common/DataModel/vtkKdTree.cxx index c85ebd6e7deb2cf52399997ea8ed0f51b271e570..a9e831c0859f63a64e48ca84a08984c70bd25746 100644 --- a/Common/DataModel/vtkKdTree.cxx +++ b/Common/DataModel/vtkKdTree.cxx @@ -1420,6 +1420,7 @@ void vtkKdTree::AddNewRegions(vtkKdNode* kd, float* c1, int midpt, int dim, doub // elements X[j], j > k satisfy X[j] >= X[K]. #define Exchange(array, ids, x, y) \ + do \ { \ float temp[3]; \ temp[0] = array[3 * x]; \ @@ -1437,7 +1438,7 @@ void vtkKdTree::AddNewRegions(vtkKdNode* kd, float* c1, int midpt, int dim, doub ids[x] = ids[y]; \ ids[y] = tempid; \ } \ - } + } while (false) #define sign(x) (((x) < 0) ? (-1) : (1)) @@ -3589,6 +3590,7 @@ void vtkKdTree::GenerateRepresentation(int* regions, int len, vtkPolyData* pd) #define SORTLIST(l, lsize) std::sort(l, (l) + (lsize)) #define REMOVEDUPLICATES(l, lsize, newsize) \ + do \ { \ int ii, jj; \ for (ii = 0, jj = 0; ii < (lsize); ii++) \ @@ -3604,7 +3606,7 @@ void vtkKdTree::GenerateRepresentation(int* regions, int len, vtkPolyData* pd) jj++; \ } \ newsize = jj; \ - } + } while (false) //------------------------------------------------------------------------------ int vtkKdTree::FoundId(vtkIntArray* idArray, int id) diff --git a/Common/DataModel/vtkReebGraph.cxx b/Common/DataModel/vtkReebGraph.cxx index 0114f1d137d68bc8d0e3a0519e4687993515c04e..f4fc2e0e4376e4dc48e5f3dc4ca3b06a218f4079 100644 --- a/Common/DataModel/vtkReebGraph.cxx +++ b/Common/DataModel/vtkReebGraph.cxx @@ -51,12 +51,13 @@ inline bool vtkReebGraphVertexSoS( // INTERNAL MACROS --------------------------------------------------------- #define vtkReebGraphSwapVars(type, var1, var2) \ + do \ { \ type tmp; \ tmp = (var1); \ (var1) = (var2); \ (var2) = tmp; \ - } + } while (false) #define vtkReebGraphInitialStreamSize 1000 @@ -78,6 +79,7 @@ inline bool vtkReebGraphVertexSoS( !this->GetArc((n)->ArcUpId)->ArcDwId0)) #define vtkReebGraphAddUpArc(rg, N, A) \ + do \ { \ vtkReebNode* n = this->GetNode(N); \ vtkReebArc* a = this->GetArc(A); \ @@ -86,9 +88,10 @@ inline bool vtkReebGraphVertexSoS( if (n->ArcUpId) \ this->GetArc(n->ArcUpId)->ArcUpId0 = (A); \ n->ArcUpId = (A); \ - } + } while (false) #define vtkReebGraphAddDownArc(rg, N, A) \ + do \ { \ vtkReebNode* n = this->GetNode(N); \ vtkReebArc* a = this->GetArc(A); \ @@ -97,9 +100,10 @@ inline bool vtkReebGraphVertexSoS( if (n->ArcDownId) \ this->GetArc(n->ArcDownId)->ArcUpId1 = (A); \ n->ArcDownId = (A); \ - } + } while (false) #define vtkReebGraphRemoveUpArc(rg, N, A) \ + do \ { \ vtkReebNode* n = this->GetNode(N); \ vtkReebArc* a = this->GetArc(A); \ @@ -109,9 +113,10 @@ inline bool vtkReebGraphVertexSoS( n->ArcUpId = a->ArcDwId0; \ if (a->ArcDwId0) \ this->GetArc(a->ArcDwId0)->ArcUpId0 = a->ArcUpId0; \ - } + } while (false) #define vtkReebGraphRemoveDownArc(rg, N, A) \ + do \ { \ vtkReebNode* n = this->GetNode(N); \ vtkReebArc* a = this->GetArc(A); \ @@ -121,13 +126,14 @@ inline bool vtkReebGraphVertexSoS( n->ArcDownId = a->ArcDwId1; \ if (a->ArcDwId1) \ this->GetArc(a->ArcDwId1)->ArcUpId1 = a->ArcUpId1; \ - } + } while (false) #ifndef vtkReebGraphMax #define vtkReebGraphMax(a, b) (((a) >= (b)) ? (a) : (b)) #endif #define vtkReebGraphStackPush(N) \ + do \ { \ if (nstack == mstack) \ { \ @@ -141,7 +147,7 @@ inline bool vtkReebGraphVertexSoS( } \ } \ stack[nstack++] = (N); \ - } + } while (false) #define vtkReebGraphStackSize() (nstack) diff --git a/Common/DataModel/vtkSphere.cxx b/Common/DataModel/vtkSphere.cxx index f7b7b219da9f1a11b7ab006037586bc4c896a06f..fac70aa8bb1b3eaca901ccd31740a41504e22f43 100644 --- a/Common/DataModel/vtkSphere.cxx +++ b/Common/DataModel/vtkSphere.cxx @@ -53,11 +53,13 @@ void vtkSphere::EvaluateGradient(double x[3], double n[3]) // The following methods are used to compute bounding spheres. // #define VTK_ASSIGN_POINT(_x, _y) \ + do \ { \ _x[0] = _y[0]; \ _x[1] = _y[1]; \ _x[2] = _y[2]; \ - } + } while (false) + //------------------------------------------------------------------------------ // Inspired by Graphics Gems Vol. I ("An Efficient Bounding Sphere" by Jack Ritter). // The algorithm works in two parts: first an initial estimate of the largest sphere; @@ -173,12 +175,13 @@ void vtkSphereComputeBoundingSphere(T* pts, vtkIdType numPts, T sphere[4], vtkId #undef VTK_ASSIGN_POINT #define VTK_ASSIGN_SPHERE(_x, _y) \ + do \ { \ _x[0] = _y[0]; \ _x[1] = _y[1]; \ _x[2] = _y[2]; \ _x[3] = _y[3]; \ - } + } while (false) // An approximation to the bounding sphere of a set of spheres. The algorithm // creates an initial approximation from two spheres that are expected to be // the farthest apart (taking into account their radius). A second pass may diff --git a/Common/ExecutionModel/Testing/Cxx/TestTemporalSupport.cxx b/Common/ExecutionModel/Testing/Cxx/TestTemporalSupport.cxx index 3c42da81c6d7077db3e7812962dd9ea69998ad01..00a909f994ab40bb4a10ba6216a4b5a3460d447a 100644 --- a/Common/ExecutionModel/Testing/Cxx/TestTemporalSupport.cxx +++ b/Common/ExecutionModel/Testing/Cxx/TestTemporalSupport.cxx @@ -28,11 +28,14 @@ #include <cassert> #define CHECK(b, errors) \ - if (!(b)) \ + do \ { \ - errors++; \ - cerr << "Error on Line " << __LINE__ << ":" << endl; \ - } + if (!(b)) \ + { \ + errors++; \ + cerr << "Error on Line " << __LINE__ << ":" << endl; \ + } \ + } while (false) class TestAlgorithm : public vtkAlgorithm { diff --git a/Common/System/vtkSocket.cxx b/Common/System/vtkSocket.cxx index f44c0534be18b953d0d4e2cee91666d2653c96da..418911ac6dc6c3249ae7b6585506403f63e07813 100644 --- a/Common/System/vtkSocket.cxx +++ b/Common/System/vtkSocket.cxx @@ -72,8 +72,7 @@ do \ { \ (_ret) = (_call); \ - } while ( \ - ((_ret) == vtkSocketErrorReturnMacro) && (vtkErrnoMacro == vtkSocketErrorIdMacro(EINTR))); + } while (((_ret) == vtkSocketErrorReturnMacro) && (vtkErrnoMacro == vtkSocketErrorIdMacro(EINTR))) // use when _str may be a null pointer but _fallback is not. #define vtkSafeStrMacro(_str, _fallback) ((_str) ? (_str) : (_fallback)) @@ -81,13 +80,13 @@ // convert error number to string and report via vtkErrorMacro. #define vtkSocketErrorMacro(_eno, _message) \ vtkErrorMacro(<< (_message) << " " << vtkSafeStrMacro(vtkStrerrorMacro(_eno), "unknown error") \ - << "."); + << ".") // convert error number to string and report via vtkGenericWarningMacro #define vtkSocketGenericErrorMacro(_message) \ vtkGenericWarningMacro(<< (_message) << " " \ << vtkSafeStrMacro(vtkStrerrorMacro(vtkErrnoMacro), "unknown error") \ - << "."); + << ".") // on windows strerror doesn't handle socket error codes #if defined(_WIN32) && !defined(__CYGWIN__) diff --git a/Domains/Chemistry/Testing/Cxx/TestMoleculeToLines.cxx b/Domains/Chemistry/Testing/Cxx/TestMoleculeToLines.cxx index 9c16d9fb6a8d65e0467ff6695bd446aa8cebb7a6..fc2ef6a270f9e5e7f029dab3ee56e1035e181bac 100644 --- a/Domains/Chemistry/Testing/Cxx/TestMoleculeToLines.cxx +++ b/Domains/Chemistry/Testing/Cxx/TestMoleculeToLines.cxx @@ -25,12 +25,15 @@ #include "vtkPolyData.h" #define CheckNumbers(name, first, second) \ - if (first != second) \ + do \ { \ - cerr << "Error : wrong number of " << #name << ". Got " << first << " but expects " << second \ - << endl; \ - return EXIT_FAILURE; \ - } + if (first != second) \ + { \ + cerr << "Error : wrong number of " << #name << ". Got " << first << " but expects " \ + << second << endl; \ + return EXIT_FAILURE; \ + } \ + } while (false) int TestMoleculeToLines(int argc, char* argv[]) { diff --git a/Domains/Chemistry/Testing/Cxx/TestPointSetToMoleculeFilter.cxx b/Domains/Chemistry/Testing/Cxx/TestPointSetToMoleculeFilter.cxx index 9f5c53693cca2134b858f581ad1819a36ad3d48c..61eb26eaeaa133f00c8a848e1240f4954ae580a1 100644 --- a/Domains/Chemistry/Testing/Cxx/TestPointSetToMoleculeFilter.cxx +++ b/Domains/Chemistry/Testing/Cxx/TestPointSetToMoleculeFilter.cxx @@ -25,12 +25,15 @@ #include "vtkUnsignedShortArray.h" #define CheckNumbers(name, first, second) \ - if (first != second) \ + do \ { \ - cerr << "Error : wrong number of " << #name << ". Got " << first << " but expects " << second \ - << endl; \ - return EXIT_FAILURE; \ - } + if (first != second) \ + { \ + cerr << "Error : wrong number of " << #name << ". Got " << first << " but expects " \ + << second << endl; \ + return EXIT_FAILURE; \ + } \ + } while (false) int TestPointSetToMoleculeFilter(int, char*[]) { diff --git a/Domains/Chemistry/Testing/Cxx/TestProgrammableElectronicData.cxx b/Domains/Chemistry/Testing/Cxx/TestProgrammableElectronicData.cxx index e949f37cc83697ad031e4e085b272c1fbaa03a63..ada2ecd08a10d4155c8652fe53b2783097fb7fef 100644 --- a/Domains/Chemistry/Testing/Cxx/TestProgrammableElectronicData.cxx +++ b/Domains/Chemistry/Testing/Cxx/TestProgrammableElectronicData.cxx @@ -18,12 +18,15 @@ #include "vtkProgrammableElectronicData.h" #define CHECK_MO(num) \ - if (ed->GetMO(num) != mo##num) \ + do \ { \ - cerr << "MO number " << (num) << " has changed since being set: " \ - << "Expected @" << mo##num << ", got @" << ed->GetMO(num) << ".\n"; \ - return EXIT_FAILURE; \ - } + if (ed->GetMO(num) != mo##num) \ + { \ + cerr << "MO number " << (num) << " has changed since being set: " \ + << "Expected @" << mo##num << ", got @" << ed->GetMO(num) << ".\n"; \ + return EXIT_FAILURE; \ + } \ + } while (false) int TestProgrammableElectronicData(int, char*[]) { diff --git a/Filters/Core/Testing/Cxx/TestAppendMolecule.cxx b/Filters/Core/Testing/Cxx/TestAppendMolecule.cxx index db329928038f5ff110b18fd7b71f3bdff3d7dbc7..4415dc2c6bdaa3e6c2f8729951c187bb3e536fcc 100644 --- a/Filters/Core/Testing/Cxx/TestAppendMolecule.cxx +++ b/Filters/Core/Testing/Cxx/TestAppendMolecule.cxx @@ -23,12 +23,15 @@ #include "vtkUnsignedShortArray.h" #define CheckNumbers(name, first, second) \ - if (first != second) \ + do \ { \ - cerr << "Error : wrong number of " << #name << ". Got " << first << " but expects " << second \ - << endl; \ - return EXIT_FAILURE; \ - } + if (first != second) \ + { \ + cerr << "Error : wrong number of " << #name << ". Got " << first << " but expects " \ + << second << endl; \ + return EXIT_FAILURE; \ + } \ + } while (false) // Used to creates different atoms and data for each molecule static int NB_OF_MOL = 0; diff --git a/Filters/Core/Testing/Cxx/TestPartitionedDataSetCollectionConvertors.cxx b/Filters/Core/Testing/Cxx/TestPartitionedDataSetCollectionConvertors.cxx index 0315f29af4f5b2b35e2a36a5292c46b477d91093..4f97dd0573bfd77b25e50b9bf8ebe0201b2e42e2 100644 --- a/Filters/Core/Testing/Cxx/TestPartitionedDataSetCollectionConvertors.cxx +++ b/Filters/Core/Testing/Cxx/TestPartitionedDataSetCollectionConvertors.cxx @@ -26,11 +26,14 @@ #include <vector> #define VERIFY(x) \ - if (!(x)) \ + do \ { \ - vtkLogF(ERROR, "Check Failed: '%s'", #x); \ - return EXIT_FAILURE; \ - } + if (!(x)) \ + { \ + vtkLogF(ERROR, "Check Failed: '%s'", #x); \ + return EXIT_FAILURE; \ + } \ + } while (false) int TestPartitionedDataSetCollectionConvertors(int argc, char* argv[]) { diff --git a/Filters/Core/Testing/Cxx/TestPlaneCutter.cxx b/Filters/Core/Testing/Cxx/TestPlaneCutter.cxx index 8860969b9c0ca73cc3ea959df04dc5c4f578618c..efd235fff6403a42d7b39aabe5b3f70a1d9adcd4 100644 --- a/Filters/Core/Testing/Cxx/TestPlaneCutter.cxx +++ b/Filters/Core/Testing/Cxx/TestPlaneCutter.cxx @@ -25,17 +25,20 @@ #include "vtkUnstructuredGridBase.h" #define Compare(output, expected) \ - if (output->GetNumberOfCells() != expected) \ + do \ { \ - cerr << "Test " << __FUNCTION__ << " expected " << expected << " cells, got " \ - << output->GetNumberOfCells() << endl; \ - return false; \ - } \ - else \ - { \ - cout << "Test " << __FUNCTION__ << " succeeded with " << output->GetNumberOfCells() \ - << " cells." << endl; \ - } + if (output->GetNumberOfCells() != expected) \ + { \ + cerr << "Test " << __FUNCTION__ << " expected " << expected << " cells, got " \ + << output->GetNumberOfCells() << endl; \ + return false; \ + } \ + else \ + { \ + cout << "Test " << __FUNCTION__ << " succeeded with " << output->GetNumberOfCells() \ + << " cells." << endl; \ + } \ + } while (false) bool TestPlaneCutterStructured(int type, int expected) { diff --git a/Filters/Core/vtk3DLinearGridCrinkleExtractor.cxx b/Filters/Core/vtk3DLinearGridCrinkleExtractor.cxx index b87e7db4b50897652415a9635dfc2b9c2ccef1be..14cd4e047a23002f4849e1f1d67f9ad36bf6f389 100644 --- a/Filters/Core/vtk3DLinearGridCrinkleExtractor.cxx +++ b/Filters/Core/vtk3DLinearGridCrinkleExtractor.cxx @@ -49,27 +49,33 @@ vtkCxxSetObjectMacro(vtk3DLinearGridCrinkleExtractor, ImplicitFunction, vtkImpli // parallel processing mode. The _REDUCE_ version is used to called functors // with a Reduce() method). #define EXECUTE_SMPFOR(_seq, _num, _op) \ - if (!_seq) \ + do \ { \ - vtkSMPTools::For(0, _num, _op); \ - } \ - else \ - { \ - _op(0, _num); \ - } + if (!_seq) \ + { \ + vtkSMPTools::For(0, _num, _op); \ + } \ + else \ + { \ + _op(0, _num); \ + } \ + } while (false) #define EXECUTE_REDUCED_SMPFOR(_seq, _num, _op, _nt) \ - if (!_seq) \ - { \ - vtkSMPTools::For(0, _num, _op); \ - } \ - else \ + do \ { \ - _op.Initialize(); \ - _op(0, _num); \ - _op.Reduce(); \ - } \ - _nt = _op.NumThreadsUsed; + if (!_seq) \ + { \ + vtkSMPTools::For(0, _num, _op); \ + } \ + else \ + { \ + _op.Initialize(); \ + _op(0, _num); \ + _op.Reduce(); \ + } \ + _nt = _op.NumThreadsUsed; \ + } while (false) namespace { // anonymous diff --git a/Filters/Core/vtk3DLinearGridPlaneCutter.cxx b/Filters/Core/vtk3DLinearGridPlaneCutter.cxx index 81c804ac83e262498b538e7a78f960e75390ff10..648cdfa07698bb4aae1b343961c2c19338a06153 100644 --- a/Filters/Core/vtk3DLinearGridPlaneCutter.cxx +++ b/Filters/Core/vtk3DLinearGridPlaneCutter.cxx @@ -66,27 +66,33 @@ vtkCxxSetObjectMacro(vtk3DLinearGridPlaneCutter, Plane, vtkPlane); // parallel processing mode. The _REDUCE_ version is used to called functors // with a Reduce() method). #define EXECUTE_SMPFOR(_seq, _num, _op) \ - if (!_seq) \ + do \ { \ - vtkSMPTools::For(0, _num, _op); \ - } \ - else \ - { \ - _op(0, _num); \ - } + if (!_seq) \ + { \ + vtkSMPTools::For(0, _num, _op); \ + } \ + else \ + { \ + _op(0, _num); \ + } \ + } while (false) #define EXECUTE_REDUCED_SMPFOR(_seq, _num, _op, _nt) \ - if (!_seq) \ - { \ - vtkSMPTools::For(0, _num, _op); \ - } \ - else \ + do \ { \ - _op.Initialize(); \ - _op(0, _num); \ - _op.Reduce(); \ - } \ - _nt = _op.NumThreadsUsed; + if (!_seq) \ + { \ + vtkSMPTools::For(0, _num, _op); \ + } \ + else \ + { \ + _op.Initialize(); \ + _op(0, _num); \ + _op.Reduce(); \ + } \ + _nt = _op.NumThreadsUsed; \ + } while (false) namespace { diff --git a/Filters/Core/vtkContour3DLinearGrid.cxx b/Filters/Core/vtkContour3DLinearGrid.cxx index 915f98b19952d42ef3367ebdf4fe09c7710da39d..0a0f64803600b86de050e0110b81da5dcd55f0d6 100644 --- a/Filters/Core/vtkContour3DLinearGrid.cxx +++ b/Filters/Core/vtkContour3DLinearGrid.cxx @@ -73,27 +73,33 @@ vtkCxxSetObjectMacro(vtkContour3DLinearGrid, ScalarTree, vtkScalarTree); // parallel processing mode. The _REDUCE_ version is used to called functors // with a Reduce() method). #define EXECUTE_SMPFOR(_seq, _num, _op) \ - if (!_seq) \ + do \ { \ - vtkSMPTools::For(0, _num, _op); \ - } \ - else \ - { \ - _op(0, _num); \ - } + if (!_seq) \ + { \ + vtkSMPTools::For(0, _num, _op); \ + } \ + else \ + { \ + _op(0, _num); \ + } \ + } while (false) #define EXECUTE_REDUCED_SMPFOR(_seq, _num, _op, _nt) \ - if (!_seq) \ + do \ { \ - vtkSMPTools::For(0, _num, _op); \ - } \ - else \ - { \ - _op.Initialize(); \ - _op(0, _num); \ - _op.Reduce(); \ - } \ - _nt = _op.NumThreadsUsed; + if (!_seq) \ + { \ + vtkSMPTools::For(0, _num, _op); \ + } \ + else \ + { \ + _op.Initialize(); \ + _op(0, _num); \ + _op.Reduce(); \ + } \ + _nt = _op.NumThreadsUsed; \ + } while (false) namespace { @@ -942,7 +948,7 @@ struct ProduceAttributes mergeEdges = extractEdges.Edges; \ } \ } \ - break; + break // Wrapper to handle multiple template types for merged processing template <typename TIds> @@ -1258,7 +1264,7 @@ vtkMTimeType vtkContour3DLinearGrid::GetMTime() case VTK_SCALAR_type: \ ProcessFastPath<_type>(numCells, inPts, cellIter, (_type*)sPtr, value, stree, outPts, \ newPolys, this->SequentialProcessing, this->NumberOfThreadsUsed, totalPts, totalTris); \ - break; + break //------------------------------------------------------------------------------ // Specialized contouring filter to handle unstructured grids with 3D linear diff --git a/Filters/Core/vtkEdgeSubdivisionCriterion.cxx b/Filters/Core/vtkEdgeSubdivisionCriterion.cxx index 481af6a7df5c346ede595d7284ac450401302ad4..f8f41848e0728dc3fd0d175c486f0469c351e483 100644 --- a/Filters/Core/vtkEdgeSubdivisionCriterion.cxx +++ b/Filters/Core/vtkEdgeSubdivisionCriterion.cxx @@ -121,14 +121,17 @@ bool vtkEdgeSubdivisionCriterion::ViewDependentEval(const double* p0, double* p1 Transform->MultiplyPoint(p2t, p2t); int p0Code = 0, p2Code = 0; #define ENDPOINT_CODE(code, pt) \ - if (pt[0] > pt[3]) \ - code += 1; \ - else if (pt[0] < -pt[3]) \ - code += 2; \ - if (pt[1] > pt[3]) \ - code += 4; \ - else if (pt[1] < -pt[3]) \ - code += 8; + do \ + { \ + if (pt[0] > pt[3]) \ + code += 1; \ + else if (pt[0] < -pt[3]) \ + code += 2; \ + if (pt[1] > pt[3]) \ + code += 4; \ + else if (pt[1] < -pt[3]) \ + code += 8; \ + } while (false) ENDPOINT_CODE(p0Code, p0t); ENDPOINT_CODE(p2Code, p2t); diff --git a/Filters/Core/vtkGridSynchronizedTemplates3D.cxx b/Filters/Core/vtkGridSynchronizedTemplates3D.cxx index b76af60e9d5610fcf8d471518db1e6279c254eb6..d174c344f15d4eecbbb05221871d53085658e11c 100644 --- a/Filters/Core/vtkGridSynchronizedTemplates3D.cxx +++ b/Filters/Core/vtkGridSynchronizedTemplates3D.cxx @@ -321,35 +321,38 @@ void ComputeGridPointGradient( //------------------------------------------------------------------------------ #define VTK_CSP3PA(i2, j2, k2, s, p, grad, norm) \ - if (NeedGradients) \ + do \ { \ - if (!g0) \ + if (NeedGradients) \ { \ - ComputeGridPointGradient(i, j, k, inExt, incY, incZ, s0, p0, n0); \ - g0 = 1; \ + if (!g0) \ + { \ + ComputeGridPointGradient(i, j, k, inExt, incY, incZ, s0, p0, n0); \ + g0 = 1; \ + } \ + ComputeGridPointGradient(i2, j2, k2, inExt, incY, incZ, s, p, n1); \ + for (jj = 0; jj < 3; jj++) \ + { \ + grad[jj] = n0[jj] + t * (n1[jj] - n0[jj]); \ + } \ + if (ComputeGradients) \ + { \ + newGradients->InsertNextTuple(grad); \ + } \ + if (ComputeNormals) \ + { \ + norm[0] = -grad[0]; \ + norm[1] = -grad[1]; \ + norm[2] = -grad[2]; \ + vtkMath::Normalize(norm); \ + newNormals->InsertNextTuple(norm); \ + } \ } \ - ComputeGridPointGradient(i2, j2, k2, inExt, incY, incZ, s, p, n1); \ - for (jj = 0; jj < 3; jj++) \ + if (ComputeScalars) \ { \ - grad[jj] = n0[jj] + t * (n1[jj] - n0[jj]); \ + newScalars->InsertNextTuple(&value); \ } \ - if (ComputeGradients) \ - { \ - newGradients->InsertNextTuple(grad); \ - } \ - if (ComputeNormals) \ - { \ - norm[0] = -grad[0]; \ - norm[1] = -grad[1]; \ - norm[2] = -grad[2]; \ - vtkMath::Normalize(norm); \ - newNormals->InsertNextTuple(norm); \ - } \ - } \ - if (ComputeScalars) \ - { \ - newScalars->InsertNextTuple(&value); \ - } + } while (false) namespace { diff --git a/Filters/Core/vtkRectilinearSynchronizedTemplates.cxx b/Filters/Core/vtkRectilinearSynchronizedTemplates.cxx index e99d186b2a450763ac7a484d92249598cb0668fa..4df69533d1445a2c32f48abd2ec1afe9c62700c1 100644 --- a/Filters/Core/vtkRectilinearSynchronizedTemplates.cxx +++ b/Filters/Core/vtkRectilinearSynchronizedTemplates.cxx @@ -212,37 +212,40 @@ void vtkRSTComputePointGradient( //------------------------------------------------------------------------------ #define VTK_RECT_CSP3PA(i2, j2, k2, s) \ - if (NeedGradients) \ + do \ { \ - if (!g0) \ + if (NeedGradients) \ { \ - self->ComputeSpacing(data, i, j, k, exExt, spacing); \ - vtkRSTComputePointGradient(i, j, k, s0, inExt, xInc, yInc, zInc, spacing, n0); \ - g0 = 1; \ + if (!g0) \ + { \ + self->ComputeSpacing(data, i, j, k, exExt, spacing); \ + vtkRSTComputePointGradient(i, j, k, s0, inExt, xInc, yInc, zInc, spacing, n0); \ + g0 = 1; \ + } \ + self->ComputeSpacing(data, i2, j2, k2, exExt, spacing); \ + vtkRSTComputePointGradient(i2, j2, k2, s, inExt, xInc, yInc, zInc, spacing, n1); \ + for (jj = 0; jj < 3; jj++) \ + { \ + n[jj] = n0[jj] + t * (n1[jj] - n0[jj]); \ + } \ + if (ComputeGradients) \ + { \ + newGradients->InsertNextTuple(n); \ + } \ + if (ComputeNormals) \ + { \ + vtkMath::Normalize(n); \ + n[0] = -n[0]; \ + n[1] = -n[1]; \ + n[2] = -n[2]; \ + newNormals->InsertNextTuple(n); \ + } \ } \ - self->ComputeSpacing(data, i2, j2, k2, exExt, spacing); \ - vtkRSTComputePointGradient(i2, j2, k2, s, inExt, xInc, yInc, zInc, spacing, n1); \ - for (jj = 0; jj < 3; jj++) \ + if (ComputeScalars) \ { \ - n[jj] = n0[jj] + t * (n1[jj] - n0[jj]); \ + newScalars->InsertNextTuple(&value); \ } \ - if (ComputeGradients) \ - { \ - newGradients->InsertNextTuple(n); \ - } \ - if (ComputeNormals) \ - { \ - vtkMath::Normalize(n); \ - n[0] = -n[0]; \ - n[1] = -n[1]; \ - n[2] = -n[2]; \ - newNormals->InsertNextTuple(n); \ - } \ - } \ - if (ComputeScalars) \ - { \ - newScalars->InsertNextTuple(&value); \ - } + } while (false) //------------------------------------------------------------------------------ // diff --git a/Filters/Core/vtkSynchronizedTemplates3D.cxx b/Filters/Core/vtkSynchronizedTemplates3D.cxx index 21d45c334df43f09a697bc454d17d57d511bec73..f4afd75f55bf620abdd432f2bb3632f5caf17865 100644 --- a/Filters/Core/vtkSynchronizedTemplates3D.cxx +++ b/Filters/Core/vtkSynchronizedTemplates3D.cxx @@ -212,35 +212,38 @@ void vtkSTComputePointGradient(int i, int j, int k, T* s, int* inExt, vtkIdType //------------------------------------------------------------------------------ #define VTK_CSP3PA(i2, j2, k2, s) \ - if (NeedGradients) \ + do \ { \ - if (!g0) \ + if (NeedGradients) \ { \ - vtkSTComputePointGradient(i, j, k, s0, inExt, xInc, yInc, zInc, spacing, n0); \ - g0 = 1; \ + if (!g0) \ + { \ + vtkSTComputePointGradient(i, j, k, s0, inExt, xInc, yInc, zInc, spacing, n0); \ + g0 = 1; \ + } \ + vtkSTComputePointGradient(i2, j2, k2, s, inExt, xInc, yInc, zInc, spacing, n1); \ + for (jj = 0; jj < 3; jj++) \ + { \ + n[jj] = n0[jj] + t * (n1[jj] - n0[jj]); \ + } \ + if (ComputeGradients) \ + { \ + newGradients->InsertNextTuple(n); \ + } \ + if (ComputeNormals) \ + { \ + vtkMath::Normalize(n); \ + n[0] = -n[0]; \ + n[1] = -n[1]; \ + n[2] = -n[2]; \ + newNormals->InsertNextTuple(n); \ + } \ } \ - vtkSTComputePointGradient(i2, j2, k2, s, inExt, xInc, yInc, zInc, spacing, n1); \ - for (jj = 0; jj < 3; jj++) \ + if (ComputeScalars) \ { \ - n[jj] = n0[jj] + t * (n1[jj] - n0[jj]); \ + newScalars->InsertNextTuple(&value); \ } \ - if (ComputeGradients) \ - { \ - newGradients->InsertNextTuple(n); \ - } \ - if (ComputeNormals) \ - { \ - vtkMath::Normalize(n); \ - n[0] = -n[0]; \ - n[1] = -n[1]; \ - n[2] = -n[2]; \ - newNormals->InsertNextTuple(n); \ - } \ - } \ - if (ComputeScalars) \ - { \ - newScalars->InsertNextTuple(&value); \ - } + } while (false) //------------------------------------------------------------------------------ // diff --git a/Filters/Core/vtkTransposeTable.cxx b/Filters/Core/vtkTransposeTable.cxx index 7f3a93b1503c4e80ec75843d71652320053e658a..80ce3d90023097c2da7ad6f5de1f6af13bf168da 100644 --- a/Filters/Core/vtkTransposeTable.cxx +++ b/Filters/Core/vtkTransposeTable.cxx @@ -179,7 +179,7 @@ bool vtkTransposeTableInternal::TransposeTable(vtkTable* inTable, vtkTable* outT vtkErrorWithObjectMacro(this->Parent, << "Unable to transpose column " << c); \ return false; \ } \ - break; + break switch (column->GetDataType()) { diff --git a/Filters/Core/vtkUnstructuredGridQuadricDecimation.cxx b/Filters/Core/vtkUnstructuredGridQuadricDecimation.cxx index 5103e0b30a7deec6367a95bedeb87e43a27494e0..291bddf3e5564b22c2d374b1a5a6841fd34496d4 100644 --- a/Filters/Core/vtkUnstructuredGridQuadricDecimation.cxx +++ b/Filters/Core/vtkUnstructuredGridQuadricDecimation.cxx @@ -164,7 +164,7 @@ public: // ============================================================================= // Symmetric 4x4 Matrix class // Storing lower half -#define SM4op(i, OP) result.values[i] = values[i] OP m.values[i]; +#define SM4op(i, OP) result.values[i] = values[i] OP m.values[i] class vtkUnstructuredGridQuadricDecimationSymMat4 { diff --git a/Filters/Extraction/Testing/Cxx/TestExtractDataArraysOverTime.cxx b/Filters/Extraction/Testing/Cxx/TestExtractDataArraysOverTime.cxx index 99d23dc1ddfa3bc9f1c71b47edf6e4d54e8f0eda..60bbb2460ce19ef283ab15e6d1f2c6e2769db31c 100644 --- a/Filters/Extraction/Testing/Cxx/TestExtractDataArraysOverTime.cxx +++ b/Filters/Extraction/Testing/Cxx/TestExtractDataArraysOverTime.cxx @@ -26,11 +26,14 @@ #include "vtkTestUtilities.h" #define expect(x, msg) \ - if (!(x)) \ + do \ { \ - cerr << __LINE__ << ": " msg << endl; \ - return false; \ - } + if (!(x)) \ + { \ + cerr << __LINE__ << ": " msg << endl; \ + return false; \ + } \ + } while (false) namespace { diff --git a/Filters/Extraction/Testing/Cxx/TestExtractSelectedArraysOverTime.cxx b/Filters/Extraction/Testing/Cxx/TestExtractSelectedArraysOverTime.cxx index e2f6a2639f68a052863ad937ba19fed395612253..b332d9d82daa98227747fcc2a63b74e95203842a 100644 --- a/Filters/Extraction/Testing/Cxx/TestExtractSelectedArraysOverTime.cxx +++ b/Filters/Extraction/Testing/Cxx/TestExtractSelectedArraysOverTime.cxx @@ -26,11 +26,14 @@ #include "vtkTestUtilities.h" #define expect(x, msg) \ - if (!(x)) \ + do \ { \ - cerr << __LINE__ << ": " msg << endl; \ - return false; \ - } + if (!(x)) \ + { \ + cerr << __LINE__ << ": " msg << endl; \ + return false; \ + } \ + } while (false) namespace { diff --git a/Filters/FlowPaths/Testing/Cxx/TestAMRInterpolatedVelocityField.cxx b/Filters/FlowPaths/Testing/Cxx/TestAMRInterpolatedVelocityField.cxx index 3744e7d92a147eca93443903c98f4934ab5a5407..253d68791295ed9274f864702ff1b6f87f31dd4d 100644 --- a/Filters/FlowPaths/Testing/Cxx/TestAMRInterpolatedVelocityField.cxx +++ b/Filters/FlowPaths/Testing/Cxx/TestAMRInterpolatedVelocityField.cxx @@ -21,11 +21,14 @@ #include <vtkNew.h> #include <vtkOverlappingAMR.h> #define RETURNONFALSE(b) \ - if (!(b)) \ + do \ { \ - vtkAlgorithm::SetDefaultExecutivePrototype(nullptr); \ - return EXIT_FAILURE; \ - } + if (!(b)) \ + { \ + vtkAlgorithm::SetDefaultExecutivePrototype(nullptr); \ + return EXIT_FAILURE; \ + } \ + } while (false) int TestAMRInterpolatedVelocityField(int, char*[]) { diff --git a/Filters/FlowPaths/Testing/Cxx/TestParticleTracers.cxx b/Filters/FlowPaths/Testing/Cxx/TestParticleTracers.cxx index fe1cf8ae247b46f4a98535d3346915c946893d16..4655704694a98068140e39ce5e9fd506ca316b15 100644 --- a/Filters/FlowPaths/Testing/Cxx/TestParticleTracers.cxx +++ b/Filters/FlowPaths/Testing/Cxx/TestParticleTracers.cxx @@ -228,11 +228,14 @@ private: vtkStandardNewMacro(TestTimeSource); #define EXPECT(a, msg) \ - if (!(a)) \ + do \ { \ - cerr << "Line " << __LINE__ << ":" << msg << endl; \ - return EXIT_FAILURE; \ - } + if (!(a)) \ + { \ + cerr << "Line " << __LINE__ << ":" << msg << endl; \ + return EXIT_FAILURE; \ + } \ + } while (false) int TestParticlePathFilter() { diff --git a/Filters/General/Testing/Cxx/ArrayExtractFactoredArray.cxx b/Filters/General/Testing/Cxx/ArrayExtractFactoredArray.cxx index 7f59300141d181d6d747157533e03aee35376789..fe160167fdd37b6cb5db56158ff72a9133250cc4 100644 --- a/Filters/General/Testing/Cxx/ArrayExtractFactoredArray.cxx +++ b/Filters/General/Testing/Cxx/ArrayExtractFactoredArray.cxx @@ -29,10 +29,11 @@ #include <stdexcept> #define test_expression(expression) \ + do \ { \ if (!(expression)) \ throw std::runtime_error("Expression failed: " #expression); \ - } + } while (false) int ArrayExtractFactoredArray(int vtkNotUsed(argc), char* vtkNotUsed(argv)[]) { diff --git a/Filters/General/Testing/Cxx/ArrayMatricizeArray.cxx b/Filters/General/Testing/Cxx/ArrayMatricizeArray.cxx index 25fcebccbb80e7a8bc81af6b3f9602b3fa4d3575..9c10921a9ea9f90b5883e11dddc8a7bb09e7e39d 100644 --- a/Filters/General/Testing/Cxx/ArrayMatricizeArray.cxx +++ b/Filters/General/Testing/Cxx/ArrayMatricizeArray.cxx @@ -29,10 +29,11 @@ #include <stdexcept> #define test_expression(expression) \ + do \ { \ if (!(expression)) \ throw std::runtime_error("Expression failed: " #expression); \ - } + } while (false) int ArrayMatricizeArray(int vtkNotUsed(argc), char* vtkNotUsed(argv)[]) { diff --git a/Filters/General/Testing/Cxx/ArrayNormalizeMatrixVectors.cxx b/Filters/General/Testing/Cxx/ArrayNormalizeMatrixVectors.cxx index 4f3ff834b47a3673e8bacb6069470528de373ca2..c1e15bde5e4b2d9aa48b4a9cc2b816c2526315d9 100644 --- a/Filters/General/Testing/Cxx/ArrayNormalizeMatrixVectors.cxx +++ b/Filters/General/Testing/Cxx/ArrayNormalizeMatrixVectors.cxx @@ -31,10 +31,11 @@ #include <stdexcept> #define test_expression(expression) \ + do \ { \ if (!(expression)) \ throw std::runtime_error("Expression failed: " #expression); \ - } + } while (false) static bool close_enough(const double lhs, const double rhs) { diff --git a/Filters/General/Testing/Cxx/TestCellValidator.cxx b/Filters/General/Testing/Cxx/TestCellValidator.cxx index 2c4208cb9458ba789f31af2de17e3a1009b0d09b..f859a158e8cb22c2a11452e60facc06e9c2b175e 100644 --- a/Filters/General/Testing/Cxx/TestCellValidator.cxx +++ b/Filters/General/Testing/Cxx/TestCellValidator.cxx @@ -207,13 +207,16 @@ int TestCellValidator(int, char*[]) vtkCellValidator::State state; #define CheckCell(cellPtr) \ - state = vtkCellValidator::Check(cellPtr, FLT_EPSILON); \ - if (state != vtkCellValidator::State::Valid) \ + do \ { \ - cellPtr->Print(std::cout); \ - vtkCellValidator::PrintState(state, std::cout, vtkIndent(0)); \ - return EXIT_FAILURE; \ - } + state = vtkCellValidator::Check(cellPtr, FLT_EPSILON); \ + if (state != vtkCellValidator::State::Valid) \ + { \ + cellPtr->Print(std::cout); \ + vtkCellValidator::PrintState(state, std::cout, vtkIndent(0)); \ + return EXIT_FAILURE; \ + } \ + } while (false) CheckCell(emptyCell); CheckCell(vertex); diff --git a/Filters/General/Testing/Cxx/TestCountFaces.cxx b/Filters/General/Testing/Cxx/TestCountFaces.cxx index 63354f9494559f96819b3f84b0ae781f6c70d188..a26773e9e15828098175ebdf0e1a97e89477c236 100644 --- a/Filters/General/Testing/Cxx/TestCountFaces.cxx +++ b/Filters/General/Testing/Cxx/TestCountFaces.cxx @@ -113,6 +113,7 @@ int TestCountFaces(int, char*[]) } #define TEST_FACES(idx, expected) \ + do \ { \ vtkIdType numFaces = faces->GetTypedComponent(idx, 0); \ if (numFaces != (expected)) \ @@ -121,7 +122,7 @@ int TestCountFaces(int, char*[]) << " faces, but found " << numFaces << "\n"; \ return EXIT_FAILURE; \ } \ - } + } while (false) int idx = 0; // VTK_VERTEX = 0 diff --git a/Filters/General/Testing/Cxx/TestCountVertices.cxx b/Filters/General/Testing/Cxx/TestCountVertices.cxx index aefc7ba3e853fb1c1e96f10071f4d8bfd3af003c..fc91b7c5ff30f5380c527cfd4570f444371a8479 100644 --- a/Filters/General/Testing/Cxx/TestCountVertices.cxx +++ b/Filters/General/Testing/Cxx/TestCountVertices.cxx @@ -113,6 +113,7 @@ int TestCountVertices(int, char*[]) } #define TEST_VERTICES(idx, expected) \ + do \ { \ vtkIdType numVerts = verts->GetTypedComponent(idx, 0); \ if (numVerts != (expected)) \ @@ -121,7 +122,7 @@ int TestCountVertices(int, char*[]) << " vertices, but found " << numVerts << "\n"; \ return EXIT_FAILURE; \ } \ - } + } while (false) int idx = 0; // VTK_VERTEX = 1 diff --git a/Filters/General/Testing/Cxx/TestReflectionFilter.cxx b/Filters/General/Testing/Cxx/TestReflectionFilter.cxx index 89368855ab7603e93337fed681ed6a186f593034..6436c6dfc8d07e13a58532c63646f5d6be970390 100644 --- a/Filters/General/Testing/Cxx/TestReflectionFilter.cxx +++ b/Filters/General/Testing/Cxx/TestReflectionFilter.cxx @@ -27,11 +27,14 @@ #include <iostream> #define AssertMacro(b, cell) \ - if (!(b)) \ + do \ { \ - std::cerr << "Failed to reflect " << cell << std::endl; \ - return EXIT_FAILURE; \ - } + if (!(b)) \ + { \ + std::cerr << "Failed to reflect " << cell << std::endl; \ + return EXIT_FAILURE; \ + } \ + } while (false) int TestReflectionFilter(int, char*[]) { diff --git a/Filters/General/Testing/Cxx/TestTableSplitColumnComponents.cxx b/Filters/General/Testing/Cxx/TestTableSplitColumnComponents.cxx index 82ef3ed4c31370c3632485deefb9b0ea626adfdc..8e183b8be02017c35d1bc0b38277fb315665eaf0 100644 --- a/Filters/General/Testing/Cxx/TestTableSplitColumnComponents.cxx +++ b/Filters/General/Testing/Cxx/TestTableSplitColumnComponents.cxx @@ -22,15 +22,18 @@ #include "vtkTable.h" #define GET_ARRAYS(arrays, out) \ - for (int cc = 0; cc < 10; ++cc) \ + do \ { \ - arrays[cc] = vtkArrayDownCast<vtkIntArray>(out->GetColumn(cc)); \ - if (arrays[cc] == nullptr) \ + for (int cc = 0; cc < 10; ++cc) \ { \ - vtkGenericWarningMacro(<< cc << ": one of the output arrays was zero - type change?"); \ - return EXIT_FAILURE; \ + arrays[cc] = vtkArrayDownCast<vtkIntArray>(out->GetColumn(cc)); \ + if (arrays[cc] == nullptr) \ + { \ + vtkGenericWarningMacro(<< cc << ": one of the output arrays was zero - type change?"); \ + return EXIT_FAILURE; \ + } \ } \ - } + } while (false) int TestTableSplitColumnComponents(int, char*[]) { diff --git a/Filters/General/vtkOBBTree.cxx b/Filters/General/vtkOBBTree.cxx index 95fa2104f4a732a59e10c00b22a28569ae4b88eb..f60ffb325ba11e0e695ef3138f41918d30ac8e3d 100644 --- a/Filters/General/vtkOBBTree.cxx +++ b/Filters/General/vtkOBBTree.cxx @@ -32,6 +32,7 @@ vtkStandardNewMacro(vtkOBBTree); //------------------------------------------------------------------------------ #define vtkCELLTRIANGLES(CELLPTIDS, TYPE, IDX, PTID0, PTID1, PTID2) \ + do \ { \ switch (TYPE) \ { \ @@ -50,7 +51,7 @@ vtkStandardNewMacro(vtkOBBTree); default: \ PTID0 = PTID1 = PTID2 = -1; \ } \ - } + } while (false) //------------------------------------------------------------------------------ vtkOBBNode::vtkOBBNode() diff --git a/Filters/Geometry/Testing/Cxx/TestMappedUnstructuredGrid.cxx b/Filters/Geometry/Testing/Cxx/TestMappedUnstructuredGrid.cxx index 6d90af5eaf26ac32d4ec8fd08baa681c3ef0cf0d..5815aaba11f81a91b01f77d2919467b8c8a25f3e 100644 --- a/Filters/Geometry/Testing/Cxx/TestMappedUnstructuredGrid.cxx +++ b/Filters/Geometry/Testing/Cxx/TestMappedUnstructuredGrid.cxx @@ -19,11 +19,14 @@ #include "vtkUnstructuredGridBase.h" #define vtk_assert(x) \ - if (!(x)) \ + do \ { \ - cerr << "On line " << __LINE__ << " ERROR: Condition FAILED!! : " << #x << endl; \ - return EXIT_FAILURE; \ - } + if (!(x)) \ + { \ + cerr << "On line " << __LINE__ << " ERROR: Condition FAILED!! : " << #x << endl; \ + return EXIT_FAILURE; \ + } \ + } while (false) int TestMappedUnstructuredGrid(int vtkNotUsed(argc), char* vtkNotUsed(argv)[]) { diff --git a/Filters/Parallel/Testing/Cxx/TestPExtractDataArraysOverTime.cxx b/Filters/Parallel/Testing/Cxx/TestPExtractDataArraysOverTime.cxx index 4e48504f5b0bbeeda853ff7c264ebaba2ad36844..374685b4989d3d664ffb5416960e889f7adedb95 100644 --- a/Filters/Parallel/Testing/Cxx/TestPExtractDataArraysOverTime.cxx +++ b/Filters/Parallel/Testing/Cxx/TestPExtractDataArraysOverTime.cxx @@ -31,11 +31,14 @@ #include <string> #define expect(x, msg) \ - if (!(x)) \ + do \ { \ - cerr << "rank=" << rank << ", line=" << __LINE__ << ": " msg << endl; \ - return false; \ - } + if (!(x)) \ + { \ + cerr << "rank=" << rank << ", line=" << __LINE__ << ": " msg << endl; \ + return false; \ + } \ + } while (false) namespace { diff --git a/Filters/Parallel/vtkPKdTree.cxx b/Filters/Parallel/vtkPKdTree.cxx index ce18864397cc0d81f01ebb86e9434b6497abf7e4..046d41fe1fc220f47c6cc62e06a5ac6b0f80ce61 100644 --- a/Filters/Parallel/vtkPKdTree.cxx +++ b/Filters/Parallel/vtkPKdTree.cxx @@ -108,20 +108,25 @@ const int vtkPKdTree::RoundRobinAssignment = 3; list = nullptr; \ } while (false) #define FreeObject(item) \ - if (item) \ + do \ { \ - item->Delete(); \ - item = nullptr; \ - } + if (item) \ + { \ + item->Delete(); \ + item = nullptr; \ + } \ + } while (false) #define VTKERROR(s) \ + do \ { \ vtkErrorMacro(<< "(process " << this->MyId << ") " << s); \ - } + } while (false) #define VTKWARNING(s) \ + do \ { \ vtkWarningMacro(<< "(process " << this->MyId << ") " << s); \ - } + } while (false) vtkPKdTree::vtkPKdTree() { @@ -287,6 +292,7 @@ void vtkPKdTree::AllCheckParameters() } #define BoundsToMinMax(bounds, min, max) \ + do \ { \ min[0] = bounds[0]; \ min[1] = bounds[2]; \ @@ -294,8 +300,9 @@ void vtkPKdTree::AllCheckParameters() max[0] = bounds[1]; \ max[1] = bounds[3]; \ max[2] = bounds[5]; \ - } + } while (false) #define MinMaxToBounds(bounds, min, max) \ + do \ { \ bounds[0] = min[0]; \ bounds[2] = min[1]; \ @@ -303,8 +310,9 @@ void vtkPKdTree::AllCheckParameters() bounds[1] = max[0]; \ bounds[3] = max[1]; \ bounds[5] = max[2]; \ - } + } while (false) #define BoundsToMinMaxUpdate(bounds, min, max) \ + do \ { \ min[0] = (bounds[0] < min[0] ? bounds[0] : min[0]); \ min[1] = (bounds[2] < min[1] ? bounds[2] : min[1]); \ @@ -312,7 +320,7 @@ void vtkPKdTree::AllCheckParameters() max[0] = (bounds[1] > max[0] ? bounds[1] : max[0]); \ max[1] = (bounds[3] > max[1] ? bounds[3] : max[1]); \ max[2] = (bounds[5] > max[2] ? bounds[5] : max[2]); \ - } + } while (false) bool vtkPKdTree::VolumeBounds(double* volBounds) { @@ -617,6 +625,7 @@ typedef struct vtkNodeInfo_ } * vtkNodeInfo; #define ENQUEUE(a, b, c, d) \ + do \ { \ vtkNodeInfo rec = new struct vtkNodeInfo_; \ rec->kd = a; \ @@ -624,7 +633,7 @@ typedef struct vtkNodeInfo_ rec->level = c; \ rec->tag = d; \ Queue.push(rec); \ - } + } while (false) int vtkPKdTree::BreadthFirstDivide(double* volBounds) { diff --git a/Filters/ParallelFlowPaths/Testing/Cxx/TestPParticleTracers.cxx b/Filters/ParallelFlowPaths/Testing/Cxx/TestPParticleTracers.cxx index 08e4eb31b75c21e4b6bab90c9f902ddf41a6d173..b9b171dc0ef64733aaf404c15441fc2b6acb87e0 100644 --- a/Filters/ParallelFlowPaths/Testing/Cxx/TestPParticleTracers.cxx +++ b/Filters/ParallelFlowPaths/Testing/Cxx/TestPParticleTracers.cxx @@ -32,13 +32,16 @@ #include <vector> #define EXPECT(expected, actual, msg, so) \ - if (!(expected == actual)) \ + do \ { \ - vtkGenericWarningMacro(<< msg << " Expecting a value of " << expected \ - << " but getting a value of " << actual << " for static option of " \ - << so); \ - return EXIT_FAILURE; \ - } + if (!(expected == actual)) \ + { \ + vtkGenericWarningMacro(<< msg << " Expecting a value of " << expected \ + << " but getting a value of " << actual << " for static option of " \ + << so); \ + return EXIT_FAILURE; \ + } \ + } while (false) class TestTimeSource : public vtkAlgorithm { diff --git a/Filters/Programmable/Testing/Cxx/TestProgrammableFilter.cxx b/Filters/Programmable/Testing/Cxx/TestProgrammableFilter.cxx index 8402324a22426afaff093a9bfb1857cb8359e209..9bf42558c99b6e3ffb56e8d3f0bf35f607450cfd 100644 --- a/Filters/Programmable/Testing/Cxx/TestProgrammableFilter.cxx +++ b/Filters/Programmable/Testing/Cxx/TestProgrammableFilter.cxx @@ -54,6 +54,7 @@ EXECUTE_METHOD(Table); EXECUTE_METHOD(HyperTreeGrid); #define TEST_PROGRAMMABLE_FILTER_B(_intype, _type) \ + do \ { \ vtkNew<vtk##_intype> inData; \ vtkNew<vtkProgrammableFilter> ps; \ @@ -66,7 +67,7 @@ EXECUTE_METHOD(HyperTreeGrid); std::cerr << "Filter output type is not of type " #_type "!" << std::endl; \ return EXIT_FAILURE; \ } \ - } + } while (false) #define TEST_PROGRAMMABLE_FILTER_A(_type) TEST_PROGRAMMABLE_FILTER_B(_type, _type) diff --git a/Filters/Sources/Testing/Cxx/TestProgrammableSource.cxx b/Filters/Sources/Testing/Cxx/TestProgrammableSource.cxx index 923110f7f99b5d7f9f9295d06b4f85325a3e6f4c..ebc8634f346fee4a9f1f8a43214dde809a240973 100644 --- a/Filters/Sources/Testing/Cxx/TestProgrammableSource.cxx +++ b/Filters/Sources/Testing/Cxx/TestProgrammableSource.cxx @@ -44,6 +44,7 @@ EXECUTE_METHOD(Molecule); EXECUTE_METHOD(Table); #define TEST_PROGRAMMABLE_SOURCE(_type) \ + do \ { \ vtkNew<vtkProgrammableSource> ps; \ ps->SetExecuteMethod(&_type##ExecuteMethod, ps.Get()); \ @@ -54,7 +55,7 @@ EXECUTE_METHOD(Table); std::cerr << "Source output type is not of type " #_type "!" << std::endl; \ return EXIT_FAILURE; \ } \ - } + } while (false) int TestProgrammableSource(int vtkNotUsed(argc), char* vtkNotUsed(argv)[]) { diff --git a/IO/AMR/Testing/Cxx/TestAMReXGridReaderNodalMultiFab.cxx b/IO/AMR/Testing/Cxx/TestAMReXGridReaderNodalMultiFab.cxx index c156a17d59327a8093a7311b53325cdccbea1220..32bc6c521b6d6ef9a1fa987a3d2270535f5b8b83 100644 --- a/IO/AMR/Testing/Cxx/TestAMReXGridReaderNodalMultiFab.cxx +++ b/IO/AMR/Testing/Cxx/TestAMReXGridReaderNodalMultiFab.cxx @@ -26,11 +26,14 @@ #include "vtkUniformGrid.h" #define ensure(x, msg) \ - if (!(x)) \ + do \ { \ - cerr << "FAILED: " << msg << endl; \ - return EXIT_FAILURE; \ - } + if (!(x)) \ + { \ + cerr << "FAILED: " << msg << endl; \ + return EXIT_FAILURE; \ + } \ + } while (false) int Validate(vtkOverlappingAMR* mb) { diff --git a/IO/AMR/Testing/Cxx/TestAMReXParticlesReader.cxx b/IO/AMR/Testing/Cxx/TestAMReXParticlesReader.cxx index 4fda6a4cb754a6036312f6ed635cb838274e8a12..f49ead1757c14ee0fa849c61768c75f83649ca5d 100644 --- a/IO/AMR/Testing/Cxx/TestAMReXParticlesReader.cxx +++ b/IO/AMR/Testing/Cxx/TestAMReXParticlesReader.cxx @@ -23,11 +23,14 @@ #include "vtkTestUtilities.h" #define ensure(x, msg) \ - if (!(x)) \ + do \ { \ - cerr << "FAILED: " << msg << endl; \ - return EXIT_FAILURE; \ - } + if (!(x)) \ + { \ + cerr << "FAILED: " << msg << endl; \ + return EXIT_FAILURE; \ + } \ + } while (false) int Validate(vtkMultiBlockDataSet* mb) { diff --git a/IO/CGNS/Testing/Cxx/TestCGNSNoFlowSolutionPointers.cxx b/IO/CGNS/Testing/Cxx/TestCGNSNoFlowSolutionPointers.cxx index 405f45e78f260dfd659bbbf3ce4ddec2763227de..ee59f2235e34261bde63b5fc3b4a8f9c4a819882 100644 --- a/IO/CGNS/Testing/Cxx/TestCGNSNoFlowSolutionPointers.cxx +++ b/IO/CGNS/Testing/Cxx/TestCGNSNoFlowSolutionPointers.cxx @@ -23,11 +23,14 @@ #include "vtkTestUtilities.h" #define vtk_assert(x) \ - if (!(x)) \ + do \ { \ - cerr << "On line " << __LINE__ << " ERROR: Condition FAILED!! : " << #x << endl; \ - return EXIT_FAILURE; \ - } + if (!(x)) \ + { \ + cerr << "On line " << __LINE__ << " ERROR: Condition FAILED!! : " << #x << endl; \ + return EXIT_FAILURE; \ + } \ + } while (false) int TestCGNSNoFlowSolutionPointers(int argc, char* argv[]) { diff --git a/IO/CGNS/Testing/Cxx/TestCGNSReader.cxx b/IO/CGNS/Testing/Cxx/TestCGNSReader.cxx index 7ffcd3444dc62442deb730dc0192bd9fd2889f75..53a08bcf5d03e66269032f51c36020a436286896 100644 --- a/IO/CGNS/Testing/Cxx/TestCGNSReader.cxx +++ b/IO/CGNS/Testing/Cxx/TestCGNSReader.cxx @@ -23,11 +23,14 @@ #include "vtkUnstructuredGrid.h" #define vtk_assert(x) \ - if (!(x)) \ + do \ { \ - cerr << "On line " << __LINE__ << " ERROR: Condition FAILED!! : " << #x << endl; \ - return EXIT_FAILURE; \ - } + if (!(x)) \ + { \ + cerr << "On line " << __LINE__ << " ERROR: Condition FAILED!! : " << #x << endl; \ + return EXIT_FAILURE; \ + } \ + } while (false) int TestOutput(vtkMultiBlockDataSet* mb, int nCells, VTKCellType type) { diff --git a/IO/CGNS/Testing/Cxx/TestCGNSReaderMeshCaching.cxx b/IO/CGNS/Testing/Cxx/TestCGNSReaderMeshCaching.cxx index b536c151aba81a2f870d79feaf9b455f34e77e8c..22390b67031481ca56bc8dd8dd3ee002c9642832 100644 --- a/IO/CGNS/Testing/Cxx/TestCGNSReaderMeshCaching.cxx +++ b/IO/CGNS/Testing/Cxx/TestCGNSReaderMeshCaching.cxx @@ -27,11 +27,14 @@ #include <string> #define vtk_assert(x) \ - if (!(x)) \ + do \ { \ - cerr << "On line " << __LINE__ << " ERROR: Condition FAILED!! : " << #x << endl; \ - return EXIT_FAILURE; \ - } + if (!(x)) \ + { \ + cerr << "On line " << __LINE__ << " ERROR: Condition FAILED!! : " << #x << endl; \ + return EXIT_FAILURE; \ + } \ + } while (false) int TestCGNSReaderMeshCaching(int argc, char* argv[]) { diff --git a/IO/CGNS/Testing/Cxx/TestCGNSUnsteadyFields.cxx b/IO/CGNS/Testing/Cxx/TestCGNSUnsteadyFields.cxx index 8e619b3f9814eb5ebe95559a96e5ccc29f14082a..0ffdb620101167804295ae4dd0249aa0408da4fd 100644 --- a/IO/CGNS/Testing/Cxx/TestCGNSUnsteadyFields.cxx +++ b/IO/CGNS/Testing/Cxx/TestCGNSUnsteadyFields.cxx @@ -24,11 +24,14 @@ #include <cmath> #define vtk_assert(x) \ - if (!(x)) \ + do \ { \ - cerr << "On line " << __LINE__ << " ERROR: Condition FAILED!! : " << #x << endl; \ - return EXIT_FAILURE; \ - } + if (!(x)) \ + { \ + cerr << "On line " << __LINE__ << " ERROR: Condition FAILED!! : " << #x << endl; \ + return EXIT_FAILURE; \ + } \ + } while (false) int TestField(vtkMultiBlockDataSet* mb, double value) { diff --git a/IO/CGNS/Testing/Cxx/TestCGNSUnsteadyGrid.cxx b/IO/CGNS/Testing/Cxx/TestCGNSUnsteadyGrid.cxx index 9054ddf6c2a4e86c8bf2808dba514c1ce3aee19f..cd094ea668811654e620ff31871667e5478078a3 100644 --- a/IO/CGNS/Testing/Cxx/TestCGNSUnsteadyGrid.cxx +++ b/IO/CGNS/Testing/Cxx/TestCGNSUnsteadyGrid.cxx @@ -23,11 +23,14 @@ #include <cmath> #define vtk_assert(x) \ - if (!(x)) \ + do \ { \ - cerr << "On line " << __LINE__ << " ERROR: Condition FAILED!! : " << #x << endl; \ - return EXIT_FAILURE; \ - } + if (!(x)) \ + { \ + cerr << "On line " << __LINE__ << " ERROR: Condition FAILED!! : " << #x << endl; \ + return EXIT_FAILURE; \ + } \ + } while (false) int TestOutput(vtkMultiBlockDataSet* mb, double size) { diff --git a/IO/CGNS/Testing/Cxx/TestReadCGNSSolution.cxx b/IO/CGNS/Testing/Cxx/TestReadCGNSSolution.cxx index 414aa60bdfd3149a4a4087a98ab41e0f5c1b6f2c..fbe4d07eae2b9f68bc5ec0c11402146d082ad9d7 100644 --- a/IO/CGNS/Testing/Cxx/TestReadCGNSSolution.cxx +++ b/IO/CGNS/Testing/Cxx/TestReadCGNSSolution.cxx @@ -26,11 +26,14 @@ #include <string> #define vtk_assert(x) \ - if (!(x)) \ + do \ { \ - cerr << "On line " << __LINE__ << " ERROR: Condition FAILED!! : " << #x << endl; \ - return EXIT_FAILURE; \ - } + if (!(x)) \ + { \ + cerr << "On line " << __LINE__ << " ERROR: Condition FAILED!! : " << #x << endl; \ + return EXIT_FAILURE; \ + } \ + } while (false) int TestOutput(vtkMultiBlockDataSet* mb, int nCells, VTKCellType type); diff --git a/IO/CGNS/vtkCGNSReader.cxx b/IO/CGNS/vtkCGNSReader.cxx index 80e83035d098bcf13d8aeaf747bc9f3c4fdd268f..ef87bce09df4e32f247c394424ff0426d95bb344 100644 --- a/IO/CGNS/vtkCGNSReader.cxx +++ b/IO/CGNS/vtkCGNSReader.cxx @@ -138,12 +138,15 @@ public: }; #define CGIOErrorSafe(x) \ - if (x != CG_OK) \ + do \ { \ - char message[81]; \ - cgio_error_message(message); \ - throw CGIOError(message); \ - } + if (x != CG_OK) \ + { \ + char message[81]; \ + cgio_error_message(message); \ + throw CGIOError(message); \ + } \ + } while (false) //------------------------------------------------------------------------------ /** diff --git a/IO/Core/Testing/Cxx/TestArrayDenormalized.cxx b/IO/Core/Testing/Cxx/TestArrayDenormalized.cxx index 9fa2886af49815850b49e62fbf7c096fdbe98927..ed8646349766cd552f638ec2de2a225a91fc7715 100644 --- a/IO/Core/Testing/Cxx/TestArrayDenormalized.cxx +++ b/IO/Core/Testing/Cxx/TestArrayDenormalized.cxx @@ -29,6 +29,7 @@ #include <stdexcept> #define test_expression(expression) \ + do \ { \ if (!(expression)) \ { \ @@ -36,7 +37,7 @@ buffer << "Expression failed at line " << __LINE__ << ": " << #expression; \ throw std::runtime_error(buffer.str()); \ } \ - } + } while (false) // This test ensures that we handle denormalized floating-point numbers gracefully, // by truncating them to zero. Otherwise, iostreams will refuse to load denormalized diff --git a/IO/Core/Testing/Cxx/TestArraySerialization.cxx b/IO/Core/Testing/Cxx/TestArraySerialization.cxx index 80d76d0cc55a73b48aa20a7ed033d8aacbc30314..122e3bc5a322893072c3a6c5d58376d0148f8ffd 100644 --- a/IO/Core/Testing/Cxx/TestArraySerialization.cxx +++ b/IO/Core/Testing/Cxx/TestArraySerialization.cxx @@ -32,6 +32,7 @@ #include <stdexcept> #define test_expression(expression) \ + do \ { \ if (!(expression)) \ { \ @@ -39,7 +40,7 @@ buffer << "Expression failed at line " << __LINE__ << ": " << #expression; \ throw std::runtime_error(buffer.str()); \ } \ - } + } while (false) int TestArraySerialization(int vtkNotUsed(argc), char* vtkNotUsed(argv)[]) { diff --git a/IO/Exodus/Testing/Cxx/TestMultiBlockExodusWrite.cxx b/IO/Exodus/Testing/Cxx/TestMultiBlockExodusWrite.cxx index 2c5294a64f6c64a5fdad40c7e8cdd96b178d1637..22b3638235b712d62e065f09da075efe7fb37e7e 100644 --- a/IO/Exodus/Testing/Cxx/TestMultiBlockExodusWrite.cxx +++ b/IO/Exodus/Testing/Cxx/TestMultiBlockExodusWrite.cxx @@ -19,7 +19,7 @@ #include "vtkWindowToImageFilter.h" #include "vtkSmartPointer.h" -#define VTK_CREATE(type, name) vtkSmartPointer<type> name = vtkSmartPointer<type>::New(); +#define VTK_CREATE(type, name) vtkSmartPointer<type> name = vtkSmartPointer<type>::New() int TestMultiBlockExodusWrite(int argc, char* argv[]) { diff --git a/IO/Exodus/vtkExodusIIReader.cxx b/IO/Exodus/vtkExodusIIReader.cxx index de8531c7273fad7e5abf493d10968ff8c5097670..374b4a3ba5e2debafab2ce34e17196ce0f7962b3 100644 --- a/IO/Exodus/vtkExodusIIReader.cxx +++ b/IO/Exodus/vtkExodusIIReader.cxx @@ -76,11 +76,14 @@ #undef VTK_DBG_GLOM #define VTK_EXO_FUNC(funcall, errmsg) \ - if ((funcall) < 0) \ + do \ { \ - vtkErrorMacro(errmsg); \ - return 1; \ - } + if ((funcall) < 0) \ + { \ + vtkErrorMacro(errmsg); \ + return 1; \ + } \ + } while (false) // ------------------------------------------------------------------- CONSTANTS static int obj_types[] = { EX_EDGE_BLOCK, EX_FACE_BLOCK, EX_ELEM_BLOCK, EX_NODE_SET, EX_EDGE_SET, diff --git a/IO/Exodus/vtkModelMetadata.cxx b/IO/Exodus/vtkModelMetadata.cxx index db8eed88c9e8f2c039780c2d236558a5ac6f1302..6712547a5d635332d96d18f9fea72fcbf4406875 100644 --- a/IO/Exodus/vtkModelMetadata.cxx +++ b/IO/Exodus/vtkModelMetadata.cxx @@ -50,21 +50,25 @@ public: #undef FREELIST #define FREE(x) \ + do \ { \ delete[] x; \ x = nullptr; \ - } + } while (false) #define FREELIST(x, len) \ - if (x && (len)) \ + do \ { \ - for (i = 0; i < (len); i++) \ + if (x && (len)) \ { \ - delete[] x[i]; \ + for (i = 0; i < (len); i++) \ + { \ + delete[] x[i]; \ + } \ + delete[] x; \ + x = nullptr; \ } \ - delete[] x; \ - x = nullptr; \ - } + } while (false) void vtkModelMetadata::InitializeAllMetadata() { diff --git a/IO/Export/Testing/Cxx/UnitTestRIB.cxx b/IO/Export/Testing/Cxx/UnitTestRIB.cxx index 84514be7cd59d632c8225696e7e6e73105955357..0a950fe6a0c2308d98065ca554c66d9c82f03721 100644 --- a/IO/Export/Testing/Cxx/UnitTestRIB.cxx +++ b/IO/Export/Testing/Cxx/UnitTestRIB.cxx @@ -33,14 +33,17 @@ #include <sstream> #define TEST_SET_GET_VALUE(variable, command) \ - if ((variable) != (command)) \ + do \ { \ - std::cout << "Error in " << #command << std::endl; \ - std::cout << " In " __FILE__ ", line " << __LINE__ << std::endl; \ - std::cout << "Expected |" << (variable) << "|" << std::endl; \ - std::cout << "but got |" << (command) << "|" << std::endl; \ - status += 1; \ - } + if ((variable) != (command)) \ + { \ + std::cout << "Error in " << #command << std::endl; \ + std::cout << " In " __FILE__ ", line " << __LINE__ << std::endl; \ + std::cout << "Expected |" << (variable) << "|" << std::endl; \ + std::cout << "but got |" << (command) << "|" << std::endl; \ + status += 1; \ + } \ + } while (false) static int TestRIBProperty(); static int TestRIBLight(); diff --git a/IO/Export/vtkIVExporter.cxx b/IO/Export/vtkIVExporter.cxx index 32866967771db0b62eeb1c4dcb99a708c2cd12fe..d86b2434a31af91962f6be7f0c77538775f79b8d 100644 --- a/IO/Export/vtkIVExporter.cxx +++ b/IO/Export/vtkIVExporter.cxx @@ -50,17 +50,19 @@ vtkIVExporter::~vtkIVExporter() static char indent[256]; static int indent_now = 0; #define VTK_INDENT_MORE \ + do \ { \ indent[indent_now] = ' '; \ indent_now += 4; \ indent[indent_now] = 0; \ - } + } while (false) #define VTK_INDENT_LESS \ + do \ { \ indent[indent_now] = ' '; \ indent_now -= 4; \ indent[indent_now] = 0; \ - } + } while (false) void vtkIVExporter::WriteData() { diff --git a/IO/Export/vtkOOGLExporter.cxx b/IO/Export/vtkOOGLExporter.cxx index 137013117d715236a06e321ecc0920be5c232c4c..05bb953858b54ac21efc3f1ec71ab3660f2df761 100644 --- a/IO/Export/vtkOOGLExporter.cxx +++ b/IO/Export/vtkOOGLExporter.cxx @@ -51,17 +51,19 @@ static char indent[256]; static int indent_now = 0; #define VTK_INDENT_MORE \ + do \ { \ indent[indent_now] = ' '; \ indent_now += 4; \ indent[indent_now] = 0; \ - } + } while (false) #define VTK_INDENT_LESS \ + do \ { \ indent[indent_now] = ' '; \ indent_now -= 4; \ indent[indent_now] = 0; \ - } + } while (false) void vtkOOGLExporter::WriteData() { diff --git a/IO/Geometry/Testing/Cxx/TestOBJReaderRelative.cxx b/IO/Geometry/Testing/Cxx/TestOBJReaderRelative.cxx index 0c9c11c01e81756693a821fb98d86564bcb83cd9..174a66b2ef5315250a8ec3467f12ce34cbcdbaa3 100644 --- a/IO/Geometry/Testing/Cxx/TestOBJReaderRelative.cxx +++ b/IO/Geometry/Testing/Cxx/TestOBJReaderRelative.cxx @@ -64,30 +64,42 @@ int TestOBJReaderRelative(int argc, char* argv[]) vtkPolyData* data_abs = reader_abs->GetOutput(); #define CHECK(obj, method) \ - if (obj##_rel->method != obj##_abs->method) \ + do \ { \ - cerr << "Error: different values for " #obj "->" #method << endl; \ - retVal = 1; \ - } + if (obj##_rel->method != obj##_abs->method) \ + { \ + cerr << "Error: different values for " #obj "->" #method << endl; \ + retVal = 1; \ + } \ + } while (false) #define CHECK_ARRAY(obj, idx) \ - if (obj##_rel[idx] != obj##_abs[idx]) \ + do \ { \ - cerr << "Error: different values for " #obj "[" << (idx) << "]" << endl; \ - retVal = 1; \ - } + if (obj##_rel[idx] != obj##_abs[idx]) \ + { \ + cerr << "Error: different values for " #obj "[" << (idx) << "]" << endl; \ + retVal = 1; \ + } \ + } while (false) #define CHECK_SCALAR(obj) \ - if (obj##_rel != obj##_abs) \ + do \ { \ - cerr << "Error: different values for " #obj << endl; \ - retVal = 1; \ - } + if (obj##_rel != obj##_abs) \ + { \ + cerr << "Error: different values for " #obj << endl; \ + retVal = 1; \ + } \ + } while (false) #define CHECK_ARRAY_EXISTS(array) \ - if (!(array)) \ + do \ { \ - cerr << "Array does not exist." << endl; \ - retVal = 1; \ - } + if (!(array)) \ + { \ + cerr << "Array does not exist." << endl; \ + retVal = 1; \ + } \ + } while (false) CHECK(data, GetNumberOfVerts()); CHECK(data, GetNumberOfLines()); diff --git a/IO/IOSS/Testing/Cxx/TestIOSSAttributes.cxx b/IO/IOSS/Testing/Cxx/TestIOSSAttributes.cxx index c992c6a40de540d8f41c7f07a81db331e28ca645..c334946bff927d39c87d5163f60efd1abee622ca 100644 --- a/IO/IOSS/Testing/Cxx/TestIOSSAttributes.cxx +++ b/IO/IOSS/Testing/Cxx/TestIOSSAttributes.cxx @@ -36,15 +36,18 @@ static std::string GetFileName(int argc, char* argv[], const char* fnameC) } #define VERIFY(x, y) \ - if ((x) == false) \ + do \ { \ - vtkLogF(ERROR, "%s -- failed!", (y)); \ - return EXIT_FAILURE; \ - } \ - else \ - { \ - vtkLogF(1, "%s -- success", (y)); \ - } + if ((x) == false) \ + { \ + vtkLogF(ERROR, "%s -- failed!", (y)); \ + return EXIT_FAILURE; \ + } \ + else \ + { \ + vtkLogF(1, "%s -- success", (y)); \ + } \ + } while (false) int TestIOSSAttributes(int argc, char* argv[]) { diff --git a/IO/IOSS/Testing/Cxx/TestIOSSNoElementBlocks.cxx b/IO/IOSS/Testing/Cxx/TestIOSSNoElementBlocks.cxx index c0912cbacb354555711350ed38ced6bfb4ea1b76..9cff71060e9f0e5b480586764fb0803af88b60b1 100644 --- a/IO/IOSS/Testing/Cxx/TestIOSSNoElementBlocks.cxx +++ b/IO/IOSS/Testing/Cxx/TestIOSSNoElementBlocks.cxx @@ -39,15 +39,18 @@ static std::string GetFileName(int argc, char* argv[], const char* fnameC) } #define VERIFY(x, y) \ - if ((x) == false) \ + do \ { \ - vtkLogF(ERROR, "%s -- failed!", (y)); \ - return EXIT_FAILURE; \ - } \ - else \ - { \ - vtkLogF(1, "%s -- success", (y)); \ - } + if ((x) == false) \ + { \ + vtkLogF(ERROR, "%s -- failed!", (y)); \ + return EXIT_FAILURE; \ + } \ + else \ + { \ + vtkLogF(1, "%s -- success", (y)); \ + } \ + } while (false) int TestIOSSNoElementBlocks(int argc, char* argv[]) { diff --git a/IO/Image/vtkImageImport.cxx b/IO/Image/vtkImageImport.cxx index e55110878f2a8974980583fb2e56c4ba5938794b..95907c70aa81783caa9c26658cf9db82a1d48ec7 100644 --- a/IO/Image/vtkImageImport.cxx +++ b/IO/Image/vtkImageImport.cxx @@ -30,18 +30,21 @@ vtkStandardNewMacro(vtkImageImport); #define tryCatchMacro(invocation, messagePrepend) \ - try \ + do \ { \ - invocation; \ - } \ - catch (std::exception & _e) \ - { \ - vtkErrorMacro(<< messagePrepend << _e.what()); \ - } \ - catch (...) \ - { \ - vtkErrorMacro(<< "Unknown exception."); \ - } + try \ + { \ + invocation; \ + } \ + catch (std::exception & _e) \ + { \ + vtkErrorMacro(<< messagePrepend << _e.what()); \ + } \ + catch (...) \ + { \ + vtkErrorMacro(<< "Unknown exception."); \ + } \ + } while (false) //------------------------------------------------------------------------------ vtkImageImport::vtkImageImport() diff --git a/IO/LSDyna/vtkLSDynaReader.cxx b/IO/LSDyna/vtkLSDynaReader.cxx index dc1a5d69349bb74bf05ebdd9a3de947a88e7734b..a24c795b8dcee9487bf92ef6da7556d5399cbd0e 100644 --- a/IO/LSDyna/vtkLSDynaReader.cxx +++ b/IO/LSDyna/vtkLSDynaReader.cxx @@ -2923,12 +2923,15 @@ int vtkLSDynaReader::ReadSPHState(vtkIdType vtkNotUsed(step)) p->Fam.SkipWords(p->SPHStateOffset); #define VTK_LS_SPHARRAY(cond, celltype, arrayname, numComps) \ - if ((cond) && this->GetCellArrayStatus(celltype, arrayname)) \ + do \ { \ - this->Parts->AddProperty(celltype, arrayname, startPos, numComps); \ - } \ - if (cond) \ - startPos += (numComps); + if ((cond) && this->GetCellArrayStatus(celltype, arrayname)) \ + { \ + this->Parts->AddProperty(celltype, arrayname, startPos, numComps); \ + } \ + if (cond) \ + startPos += (numComps); \ + } while (false) // Smooth Particle ======================================================== @@ -3107,31 +3110,34 @@ void vtkLSDynaReader::ResetPartInfo() int arbitraryMaterials = p->Dict["NSORT"] < 0 ? 1 : 0; #define VTK_LSDYNA_PARTLABEL(dict, fmt) \ - N = p->Dict[dict]; \ - for (i = 0; i < N; ++i, ++mat) \ + do \ { \ - if (arbitraryMaterials) \ + N = p->Dict[dict]; \ + for (i = 0; i < N; ++i, ++mat) \ { \ - if (mat < static_cast<int>(p->MaterialsOrdered.size())) \ + if (arbitraryMaterials) \ { \ - realMat = p->MaterialsOrdered[mat - 1]; \ + if (mat < static_cast<int>(p->MaterialsOrdered.size())) \ + { \ + realMat = p->MaterialsOrdered[mat - 1]; \ + } \ + else \ + { \ + realMat = mat; \ + } \ + snprintf(partLabel, sizeof(partLabel), fmt " (Matl%d)", mat, realMat); \ } \ else \ { \ realMat = mat; \ + snprintf(partLabel, sizeof(partLabel), fmt, mat); \ } \ - snprintf(partLabel, sizeof(partLabel), fmt " (Matl%d)", mat, realMat); \ + p->PartNames.emplace_back(partLabel); \ + p->PartIds.emplace_back(realMat); \ + p->PartMaterials.emplace_back(mat); \ + p->PartStatus.emplace_back(1); \ } \ - else \ - { \ - realMat = mat; \ - snprintf(partLabel, sizeof(partLabel), fmt, mat); \ - } \ - p->PartNames.emplace_back(partLabel); \ - p->PartIds.emplace_back(realMat); \ - p->PartMaterials.emplace_back(mat); \ - p->PartStatus.emplace_back(1); \ - } + } while (false) VTK_LSDYNA_PARTLABEL("NUMMAT8", "Part%d"); // was "PartSolid%d VTK_LSDYNA_PARTLABEL("NUMMATT", "Part%d"); // was "PartThickShell%d diff --git a/IO/Legacy/Testing/Cxx/TestLegacyCompositeDataReaderWriter.cxx b/IO/Legacy/Testing/Cxx/TestLegacyCompositeDataReaderWriter.cxx index a183a80a82bbd6e5903e4b3a5d51a0cf5d3ed63b..b9b4028df99b6aaf7b9e8240cb5386a9819d2c29 100644 --- a/IO/Legacy/Testing/Cxx/TestLegacyCompositeDataReaderWriter.cxx +++ b/IO/Legacy/Testing/Cxx/TestLegacyCompositeDataReaderWriter.cxx @@ -23,11 +23,14 @@ #define TEST_FAILED 1 #define vtk_assert(x) \ - if (!(x)) \ + do \ { \ - cerr << "ERROR: Condition FAILED!! : " << #x << endl; \ - return TEST_FAILED; \ - } + if (!(x)) \ + { \ + cerr << "ERROR: Condition FAILED!! : " << #x << endl; \ + return TEST_FAILED; \ + } \ + } while (false) int Validate(vtkOverlappingAMR* input, vtkOverlappingAMR* result) { diff --git a/IO/Legacy/Testing/Cxx/TestLegacyMappedUnstructuredGrid.cxx b/IO/Legacy/Testing/Cxx/TestLegacyMappedUnstructuredGrid.cxx index e4d38b12add61c9e6e4019d6b89bb6a417f87970..6f5721140fad1942a5d790b50440153202d9b153 100644 --- a/IO/Legacy/Testing/Cxx/TestLegacyMappedUnstructuredGrid.cxx +++ b/IO/Legacy/Testing/Cxx/TestLegacyMappedUnstructuredGrid.cxx @@ -23,11 +23,14 @@ #include "vtkUnstructuredGridBase.h" #define vtk_assert(x) \ - if (!(x)) \ + do \ { \ - cerr << "On line " << __LINE__ << " ERROR: Condition FAILED!! : " << #x << endl; \ - return EXIT_FAILURE; \ - } + if (!(x)) \ + { \ + cerr << "On line " << __LINE__ << " ERROR: Condition FAILED!! : " << #x << endl; \ + return EXIT_FAILURE; \ + } \ + } while (false) int TestLegacyMappedUnstructuredGrid(int argc, char* argv[]) { diff --git a/IO/MINC/vtkMINCImageReader.cxx b/IO/MINC/vtkMINCImageReader.cxx index 546f619760bb2cc22bec632afdd6fea1bb7022ef..e5fd6d79b425b13af98eef67d43e5bb6310ede90 100644 --- a/IO/MINC/vtkMINCImageReader.cxx +++ b/IO/MINC/vtkMINCImageReader.cxx @@ -318,6 +318,7 @@ int vtkMINCImageReader::CloseNetCDFFile(int ncid) //------------------------------------------------------------------------------ // this is a macro so the vtkErrorMacro will report a useful line number #define vtkMINCImageReaderFailAndClose(ncid, status) \ + do \ { \ if ((status) != NC_NOERR) \ { \ @@ -326,7 +327,7 @@ int vtkMINCImageReader::CloseNetCDFFile(int ncid) << nc_strerror(status)); \ } \ nc_close(ncid); \ - } + } while (false) //------------------------------------------------------------------------------ // Function for getting VTK dimension index from the dimension name. diff --git a/IO/MINC/vtkMINCImageWriter.cxx b/IO/MINC/vtkMINCImageWriter.cxx index 5bac7bcf1858a176531e8e6e9c7a223ee58d14cc..37edd4fde4135950537598b0e8a9ad02740e3c97 100644 --- a/IO/MINC/vtkMINCImageWriter.cxx +++ b/IO/MINC/vtkMINCImageWriter.cxx @@ -213,6 +213,7 @@ int vtkMINCImageWriter::CloseNetCDFFile(int ncid) //------------------------------------------------------------------------------ // this is a macro so the vtkErrorMacro will report a useful line number #define vtkMINCImageWriterFailAndClose(ncid, status) \ + do \ { \ if ((status) != NC_NOERR) \ { \ @@ -220,7 +221,7 @@ int vtkMINCImageWriter::CloseNetCDFFile(int ncid) << nc_strerror(status)); \ } \ nc_close(ncid); \ - } + } while (false) //------------------------------------------------------------------------------ // Function for getting VTK dimension index from file name. @@ -492,16 +493,22 @@ nc_type vtkMINCImageWriterConvertVTKTypeToMINCType(int dataType, int& mincsigned // text attributes. As of VTK 7.1, it does not. The attribute length // should be the string length, not the string length "plus one". #define vtkMINCImageWriterPutAttributeTextMacro(name, text) \ - if (status == NC_NOERR) \ + do \ { \ - status = nc_put_att_text(ncid, varid, name, strlen(text), text); \ - } + if (status == NC_NOERR) \ + { \ + status = nc_put_att_text(ncid, varid, name, strlen(text), text); \ + } \ + } while (false) #define vtkMINCImageWriterPutAttributeDoubleMacro(name, count, ptr) \ - if (status == NC_NOERR) \ + do \ { \ - status = nc_put_att_double(ncid, varid, name, NC_DOUBLE, count, ptr); \ - } + if (status == NC_NOERR) \ + { \ + status = nc_put_att_double(ncid, varid, name, NC_DOUBLE, count, ptr); \ + } \ + } while (false) //------------------------------------------------------------------------------ // Allowed dimension variable names diff --git a/IO/MPIImage/vtkMPIImageReader.cxx b/IO/MPIImage/vtkMPIImageReader.cxx index 550207e93b551b4daa5c4868e7fc3bdd161c9537..ffa097d263a419d7336bf6040a878a0f6a2479f3 100644 --- a/IO/MPIImage/vtkMPIImageReader.cxx +++ b/IO/MPIImage/vtkMPIImageReader.cxx @@ -57,6 +57,7 @@ // Reporting errors is more important with file I/O because, unlike network I/O, // they usually don't terminate the program. #define MPICall(funcall) \ + do \ { \ int __my_result = funcall; \ if (__my_result != MPI_SUCCESS) \ @@ -69,7 +70,7 @@ << endl \ << errormsg); \ } \ - } + } while (false) #endif // VTK_USE_MPI_IO diff --git a/IO/MPIImage/vtkPNrrdReader.cxx b/IO/MPIImage/vtkPNrrdReader.cxx index edbe98c214788b1264fda257b6a5f3260c67ccb0..6488d90ee153bd53d53b872beb9c253f3d106c7f 100644 --- a/IO/MPIImage/vtkPNrrdReader.cxx +++ b/IO/MPIImage/vtkPNrrdReader.cxx @@ -72,6 +72,7 @@ // Reporting errors is more important with file I/O because, unlike network I/O, // they usually don't terminate the program. #define MPICall(funcall) \ + do \ { \ int __my_result = funcall; \ if (__my_result != MPI_SUCCESS) \ @@ -84,7 +85,7 @@ << endl \ << errormsg); \ } \ - } + } while (false) #endif // VTK_USE_MPI_IO //------------------------------------------------------------------------------ diff --git a/IO/MPIParallel/vtkPWindBladeReader.cxx b/IO/MPIParallel/vtkPWindBladeReader.cxx index 41a0c9df8e66df09080d6604d418480ad011e9d6..861d96fa63505778e32d4a8d1633f7a7f78d3cb1 100644 --- a/IO/MPIParallel/vtkPWindBladeReader.cxx +++ b/IO/MPIParallel/vtkPWindBladeReader.cxx @@ -36,6 +36,7 @@ vtkStandardNewMacro(vtkPWindBladeReader); // Reporting errors is more important with file I/O because, unlike network I/O, // they usually don't terminate the program. #define MPICall(funcall) \ + do \ { \ int __my_result = funcall; \ if (__my_result != MPI_SUCCESS) \ @@ -48,7 +49,7 @@ vtkStandardNewMacro(vtkPWindBladeReader); << endl \ << errormsg); \ } \ - } + } while (false) class PWindBladeReaderInternal { diff --git a/IO/NetCDF/vtkMPASReader.cxx b/IO/NetCDF/vtkMPASReader.cxx index 2c699307cfbbd1a48fb72d93797cd98379ac5197..d7f0e2d65a27d3b77ed8f12bf5e93643e3d82d56 100644 --- a/IO/NetCDF/vtkMPASReader.cxx +++ b/IO/NetCDF/vtkMPASReader.cxx @@ -109,13 +109,16 @@ PURPOSE. See the above copyright notice for more information. vtkTemplateMacroCase(VTK_SIGNED_CHAR, signed char, call) /* ncbyte */ #define vtkNcDispatch(type, call) \ - switch (type) \ + do \ { \ - vtkNcTemplateMacro(call); \ - default: \ - vtkErrorMacro(<< "Unsupported data type: " << (type)); \ - abort(); \ - } + switch (type) \ + { \ + vtkNcTemplateMacro(call); \ + default: \ + vtkErrorMacro(<< "Unsupported data type: " << (type)); \ + abort(); \ + } \ + } while (false) namespace { @@ -868,22 +871,28 @@ int vtkMPASReader::Internal::nc_att_id(const char* name, bool msg_on_err) const //------------------------------------------------------------------------------ #define CHECK_DIM(name, out) \ - if ((out = this->Internals->nc_dim_id(name)) == -1) \ + do \ { \ - vtkErrorMacro(<< "Cannot find dimension: " << name << endl); \ - return 0; \ - } + if ((out = this->Internals->nc_dim_id(name)) == -1) \ + { \ + vtkErrorMacro(<< "Cannot find dimension: " << name << endl); \ + return 0; \ + } \ + } while (false) //------------------------------------------------------------------------------ // Macro to check if the named NetCDF variable exists //------------------------------------------------------------------------------ #define CHECK_VAR(name, out) \ - if ((out = this->Internals->nc_var_id(name)) == -1) \ + do \ { \ - vtkErrorMacro(<< "Cannot find variable: " << name << endl); \ - return 0; \ - } + if ((out = this->Internals->nc_var_id(name)) == -1) \ + { \ + vtkErrorMacro(<< "Cannot find variable: " << name << endl); \ + return 0; \ + } \ + } while (false) //------------------------------------------------------------------------------ // Function to convert cartesian coordinates to spherical, for use in diff --git a/IO/NetCDF/vtkNetCDFCFReader.cxx b/IO/NetCDF/vtkNetCDFCFReader.cxx index 031171d770ceb0a929eea927086e9f29fa9fad3a..ae5f42e1e61c7241bcb70621a68180d9d9262b15 100644 --- a/IO/NetCDF/vtkNetCDFCFReader.cxx +++ b/IO/NetCDF/vtkNetCDFCFReader.cxx @@ -54,6 +54,7 @@ #include "vtk_netcdf.h" #define CALL_NETCDF_GENERIC(call, on_error) \ + do \ { \ int errorcode = call; \ if (errorcode != NC_NOERR) \ @@ -61,7 +62,7 @@ const char* errorstring = nc_strerror(errorcode); \ on_error; \ } \ - } + } while (false) #define CALL_NETCDF(call) \ CALL_NETCDF_GENERIC(call, vtkErrorMacro(<< "netCDF Error: " << errorstring); return 0) diff --git a/IO/NetCDF/vtkNetCDFPOPReader.cxx b/IO/NetCDF/vtkNetCDFPOPReader.cxx index 82fe7ab35a344633352a11790c7f4a309b82e212..9407d2b863053d519bc1f1caa2516d4da3b78504 100644 --- a/IO/NetCDF/vtkNetCDFPOPReader.cxx +++ b/IO/NetCDF/vtkNetCDFPOPReader.cxx @@ -33,6 +33,7 @@ vtkStandardNewMacro(vtkNetCDFPOPReader); //============================================================================ #define CALL_NETCDF(call) \ + do \ { \ int errorcode = call; \ if (errorcode != NC_NOERR) \ @@ -40,7 +41,7 @@ vtkStandardNewMacro(vtkNetCDFPOPReader); vtkErrorMacro(<< "netCDF Error: " << nc_strerror(errorcode)); \ return 0; \ } \ - } + } while (false) //============================================================================ class vtkNetCDFPOPReaderInternal diff --git a/IO/NetCDF/vtkNetCDFReader.cxx b/IO/NetCDF/vtkNetCDFReader.cxx index e55dcb8b2c79cd93d3a72a529f8de2fbaf4f9632..9a9656dd544f7e98b9f209b1dea3a56f3dd2f2e1 100644 --- a/IO/NetCDF/vtkNetCDFReader.cxx +++ b/IO/NetCDF/vtkNetCDFReader.cxx @@ -52,6 +52,7 @@ #include "vtk_netcdf.h" #define CALL_NETCDF(call) \ + do \ { \ int errorcode = call; \ if (errorcode != NC_NOERR) \ @@ -59,7 +60,7 @@ vtkErrorMacro(<< "netCDF Error: " << nc_strerror(errorcode)); \ return 0; \ } \ - } + } while (false) #include <cctype> diff --git a/IO/NetCDF/vtkSLACParticleReader.cxx b/IO/NetCDF/vtkSLACParticleReader.cxx index 5f983eef6fcfcda60ae57cf789b6aaab65b6fee0..66ebe6fa5306acfd6d1085527ed6f88ae5b4b230 100644 --- a/IO/NetCDF/vtkSLACParticleReader.cxx +++ b/IO/NetCDF/vtkSLACParticleReader.cxx @@ -46,6 +46,7 @@ //============================================================================= #define CALL_NETCDF(call) \ + do \ { \ int errorcode = call; \ if (errorcode != NC_NOERR) \ @@ -53,14 +54,15 @@ vtkErrorMacro(<< "netCDF Error: " << nc_strerror(errorcode)); \ return 0; \ } \ - } + } while (false) #define WRAP_NETCDF(call) \ + do \ { \ int errorcode = call; \ if (errorcode != NC_NOERR) \ return errorcode; \ - } + } while (false) #ifdef VTK_USE_64BIT_IDS #ifdef NC_INT64 diff --git a/IO/NetCDF/vtkSLACReader.cxx b/IO/NetCDF/vtkSLACReader.cxx index 0bdefb2f15db5ff129649b84cb62753cb7a52e2b..9b31dd0f68265228823dbb466687ac09f0248657 100644 --- a/IO/NetCDF/vtkSLACReader.cxx +++ b/IO/NetCDF/vtkSLACReader.cxx @@ -58,6 +58,7 @@ //============================================================================= #define CALL_NETCDF(call) \ + do \ { \ int errorcode = call; \ if (errorcode != NC_NOERR) \ @@ -65,14 +66,15 @@ vtkErrorMacro(<< "netCDF Error: " << nc_strerror(errorcode)); \ return 0; \ } \ - } + } while (false) #define WRAP_NETCDF(call) \ + do \ { \ int errorcode = call; \ if (errorcode != NC_NOERR) \ return errorcode; \ - } + } while (false) //------------------------------------------------------------------------------ #ifdef VTK_USE_64BIT_IDS diff --git a/IO/Parallel/vtkPImageWriter.cxx b/IO/Parallel/vtkPImageWriter.cxx index 03727c4964501a86d0214e24d0da90a4b0aba069..2bbed5e1fd5f43373c99ae51ee9802efdbf98423 100644 --- a/IO/Parallel/vtkPImageWriter.cxx +++ b/IO/Parallel/vtkPImageWriter.cxx @@ -23,16 +23,19 @@ #include "vtksys/FStream.hxx" #define vtkPIWCloseFile \ - if (file && fileOpenedHere) \ + do \ { \ - this->WriteFileTrailer(file, cache); \ - vtksys::ofstream* ofile = dynamic_cast<vtksys::ofstream*>(file); \ - if (ofile) \ + if (file && fileOpenedHere) \ { \ - ofile->close(); \ + this->WriteFileTrailer(file, cache); \ + vtksys::ofstream* ofile = dynamic_cast<vtksys::ofstream*>(file); \ + if (ofile) \ + { \ + ofile->close(); \ + } \ + delete file; \ } \ - delete file; \ - } + } while (false) vtkStandardNewMacro(vtkPImageWriter); diff --git a/IO/ParallelExodus/Testing/Cxx/TestExodusImplicitArrays.cxx b/IO/ParallelExodus/Testing/Cxx/TestExodusImplicitArrays.cxx index 06c92a3bd2ceb7dad0c138409bdb5244d970fa73..b764742561f81700a3710100de944544b497404e 100644 --- a/IO/ParallelExodus/Testing/Cxx/TestExodusImplicitArrays.cxx +++ b/IO/ParallelExodus/Testing/Cxx/TestExodusImplicitArrays.cxx @@ -11,7 +11,7 @@ #include <vtkTestUtilities.h> #include <vtkTesting.h> -#define VTK_CREATE(type, name) vtkSmartPointer<type> name = vtkSmartPointer<type>::New(); +#define VTK_CREATE(type, name) vtkSmartPointer<type> name = vtkSmartPointer<type>::New() int TestExodusImplicitArrays(int argc, char* argv[]) { diff --git a/IO/ParallelNetCDF/vtkPNetCDFPOPReader.cxx b/IO/ParallelNetCDF/vtkPNetCDFPOPReader.cxx index 87a66823ef2d5fd83a3531d8e31f8fb09a316b86..bfdd7f8fa247903207022dd114b0db26d0d68612 100644 --- a/IO/ParallelNetCDF/vtkPNetCDFPOPReader.cxx +++ b/IO/ParallelNetCDF/vtkPNetCDFPOPReader.cxx @@ -42,6 +42,7 @@ vtkStandardNewMacro(vtkPNetCDFPOPReader); //============================================================================ #define CALL_NETCDF(call) \ + do \ { \ int errorcode = call; \ if (errorcode != NC_NOERR) \ @@ -49,7 +50,7 @@ vtkStandardNewMacro(vtkPNetCDFPOPReader); vtkErrorMacro(<< "netCDF Error: " << nc_strerror(errorcode)); \ return 0; \ } \ - } + } while (false) //============================================================================ class vtkPNetCDFPOPReaderInternal diff --git a/IO/XML/Testing/Cxx/TestAMRXMLIO.cxx b/IO/XML/Testing/Cxx/TestAMRXMLIO.cxx index c5af79343d658c082c9558546267598f8a09e7f9..027a75fdd0f48a18fe41f8d9634ccfb0037490e4 100644 --- a/IO/XML/Testing/Cxx/TestAMRXMLIO.cxx +++ b/IO/XML/Testing/Cxx/TestAMRXMLIO.cxx @@ -17,11 +17,14 @@ namespace { #define vtk_assert(x) \ - if (!(x)) \ + do \ { \ - cerr << "ERROR: Condition FAILED!! : " << #x << endl; \ - return false; \ - } + if (!(x)) \ + { \ + cerr << "ERROR: Condition FAILED!! : " << #x << endl; \ + return false; \ + } \ + } while (false) bool Validate(vtkOverlappingAMR* input, vtkOverlappingAMR* result) { diff --git a/Imaging/Fourier/vtkImageFourierFilter.h b/Imaging/Fourier/vtkImageFourierFilter.h index 9e72262bd2ea8baf9c9c390b6a0f236a0452d3d8..d9d39aa3a36d5cfdaf64e625c4391ca237b01bf5 100644 --- a/Imaging/Fourier/vtkImageFourierFilter.h +++ b/Imaging/Fourier/vtkImageFourierFilter.h @@ -40,30 +40,52 @@ struct vtkImageComplex_t using vtkImageComplex = struct vtkImageComplex_t; #define vtkImageComplexEuclidSet(C, R, I) \ - (C).Real = (R); \ - (C).Imag = (I) + do \ + { \ + (C).Real = (R); \ + (C).Imag = (I); \ + } while (false) #define vtkImageComplexPolarSet(C, M, P) \ - (C).Real = (M)*cos(P); \ - (C).Imag = (M)*sin(P) + do \ + { \ + (C).Real = (M)*cos(P); \ + (C).Imag = (M)*sin(P); \ + } while (false) -#define vtkImageComplexPrint(C) printf("(%.3f, %.3f)", (C).Real, (C).Imag) +#define vtkImageComplexPrint(C) \ + do \ + { \ + printf("(%.3f, %.3f)", (C).Real, (C).Imag); \ + } while (false) #define vtkImageComplexScale(cOut, S, cIn) \ - (cOut).Real = (cIn).Real * (S); \ - (cOut).Imag = (cIn).Imag * (S) + do \ + { \ + (cOut).Real = (cIn).Real * (S); \ + (cOut).Imag = (cIn).Imag * (S); \ + } while (false) #define vtkImageComplexConjugate(cIn, cOut) \ - (cOut).Imag = (cIn).Imag * -1.0; \ - (cOut).Real = (cIn).Real + do \ + { \ + (cOut).Imag = (cIn).Imag * -1.0; \ + (cOut).Real = (cIn).Real; \ + } while (false) #define vtkImageComplexAdd(C1, C2, cOut) \ - (cOut).Real = (C1).Real + (C2).Real; \ - (cOut).Imag = (C1).Imag + (C2).Imag + do \ + { \ + (cOut).Real = (C1).Real + (C2).Real; \ + (cOut).Imag = (C1).Imag + (C2).Imag; \ + } while (false) #define vtkImageComplexSubtract(C1, C2, cOut) \ - (cOut).Real = (C1).Real - (C2).Real; \ - (cOut).Imag = (C1).Imag - (C2).Imag + do \ + { \ + (cOut).Real = (C1).Real - (C2).Real; \ + (cOut).Imag = (C1).Imag - (C2).Imag; \ + } while (false) #define vtkImageComplexMultiply(C1, C2, cOut) \ { \ diff --git a/Infovis/Boost/Testing/Cxx/TestVariantSerialization.cxx b/Infovis/Boost/Testing/Cxx/TestVariantSerialization.cxx index 48833a7797514998d8f7a3a534f1b5f7e253dd76..cfca9f81a6ef392c155b34deb9bf6984562b8fed 100644 --- a/Infovis/Boost/Testing/Cxx/TestVariantSerialization.cxx +++ b/Infovis/Boost/Testing/Cxx/TestVariantSerialization.cxx @@ -94,12 +94,15 @@ int TestVariantSerialization(int vtkNotUsed(argc), char* vtkNotUsed(argv)[]) } #define VTK_VARIANT_ARRAY_DATA_CHECK(Index, Function, Kind) \ - if (sourceArray->GetValue(Index).Function() != sinkArray->GetValue(Index).Function()) \ + do \ { \ - cerr << Kind << " mismatch: \"" << sourceArray->GetValue(Index).Function() << "\" vs. \"" \ - << sinkArray->GetValue(Index).Function() << "\".\n"; \ - ++errors; \ - } + if (sourceArray->GetValue(Index).Function() != sinkArray->GetValue(Index).Function()) \ + { \ + cerr << Kind << " mismatch: \"" << sourceArray->GetValue(Index).Function() << "\" vs. \"" \ + << sinkArray->GetValue(Index).Function() << "\".\n"; \ + ++errors; \ + } \ + } while (false) VTK_VARIANT_ARRAY_DATA_CHECK(0, ToChar, "Character"); VTK_VARIANT_ARRAY_DATA_CHECK(1, ToFloat, "Float"); diff --git a/Infovis/BoostGraphAlgorithms/Testing/Cxx/BoostArrayRandomSparseArraySource.cxx b/Infovis/BoostGraphAlgorithms/Testing/Cxx/BoostArrayRandomSparseArraySource.cxx index e25d130418f9934a7929b39f44a5de28a6e0aa68..8ef31a4c52cfa051ec2c514f5efe6b345a3055bc 100644 --- a/Infovis/BoostGraphAlgorithms/Testing/Cxx/BoostArrayRandomSparseArraySource.cxx +++ b/Infovis/BoostGraphAlgorithms/Testing/Cxx/BoostArrayRandomSparseArraySource.cxx @@ -30,10 +30,11 @@ #include <stdexcept> #define test_expression(expression) \ + do \ { \ if (!(expression)) \ throw std::runtime_error("Expression failed: " #expression); \ - } + } while (false) static bool close_enough(const double lhs, const double rhs) { diff --git a/Infovis/Core/Testing/Cxx/ArrayDotProductSimilarity.cxx b/Infovis/Core/Testing/Cxx/ArrayDotProductSimilarity.cxx index 65366379fa48202730f9b842067c3e3790b31613..1fa849fb3dda171a1ac9c0e6d53e9f3f145b6aff 100644 --- a/Infovis/Core/Testing/Cxx/ArrayDotProductSimilarity.cxx +++ b/Infovis/Core/Testing/Cxx/ArrayDotProductSimilarity.cxx @@ -31,10 +31,11 @@ #include <stdexcept> #define test_expression(expression) \ + do \ { \ if (!(expression)) \ throw std::runtime_error("Expression failed: " #expression); \ - } + } while (false) #if 0 static bool close_enough(const double lhs, const double rhs) diff --git a/Infovis/Core/Testing/Cxx/ArraySparseArrayToTable.cxx b/Infovis/Core/Testing/Cxx/ArraySparseArrayToTable.cxx index e6006f31a79c48f954906f51f9b7476e6ac0e07b..3c3e93b88eb131d3fbb900835c07a8ef56a5f16e 100644 --- a/Infovis/Core/Testing/Cxx/ArraySparseArrayToTable.cxx +++ b/Infovis/Core/Testing/Cxx/ArraySparseArrayToTable.cxx @@ -30,10 +30,11 @@ #include <stdexcept> #define test_expression(expression) \ + do \ { \ if (!(expression)) \ throw std::runtime_error("Expression failed: " #expression); \ - } + } while (false) int ArraySparseArrayToTable(int vtkNotUsed(argc), char* vtkNotUsed(argv)[]) { diff --git a/Infovis/Core/Testing/Cxx/ArrayTableToSparseArray.cxx b/Infovis/Core/Testing/Cxx/ArrayTableToSparseArray.cxx index cf8078f4f72c2559e11d786a07d0c5b88da7ed1b..9998e39ce1d0b90f62b295040302316b0af72912 100644 --- a/Infovis/Core/Testing/Cxx/ArrayTableToSparseArray.cxx +++ b/Infovis/Core/Testing/Cxx/ArrayTableToSparseArray.cxx @@ -32,10 +32,11 @@ #include <stdexcept> #define test_expression(expression) \ + do \ { \ if (!(expression)) \ throw std::runtime_error("Expression failed: " #expression); \ - } + } while (false) int ArrayTableToSparseArray(int vtkNotUsed(argc), char* vtkNotUsed(argv)[]) { diff --git a/Infovis/Core/Testing/Cxx/ArrayToTable.cxx b/Infovis/Core/Testing/Cxx/ArrayToTable.cxx index a648a0e72fcd774b8dcdf94a4ebe6eaa1ab6a97e..8716e1eebba28221c1a81d59fa4266a04470874a 100644 --- a/Infovis/Core/Testing/Cxx/ArrayToTable.cxx +++ b/Infovis/Core/Testing/Cxx/ArrayToTable.cxx @@ -31,10 +31,11 @@ #include <stdexcept> #define test_expression(expression) \ + do \ { \ if (!(expression)) \ throw std::runtime_error("Expression failed: " #expression); \ - } + } while (false) int ArrayToTable(int vtkNotUsed(argc), char* vtkNotUsed(argv)[]) { diff --git a/Infovis/Core/Testing/Cxx/ArrayTransposeMatrix.cxx b/Infovis/Core/Testing/Cxx/ArrayTransposeMatrix.cxx index 249a44072091875cd14efb0e7ebde1b18e4deba4..cce1829af8f246687e26fb9120a0d98c9ee068ec 100644 --- a/Infovis/Core/Testing/Cxx/ArrayTransposeMatrix.cxx +++ b/Infovis/Core/Testing/Cxx/ArrayTransposeMatrix.cxx @@ -29,10 +29,11 @@ #include <stdexcept> #define test_expression(expression) \ + do \ { \ if (!(expression)) \ throw std::runtime_error("Expression failed: " #expression); \ - } + } while (false) int ArrayTransposeMatrix(int vtkNotUsed(argc), char* vtkNotUsed(argv)[]) { diff --git a/Infovis/Core/Testing/Cxx/TestArrayNorm.cxx b/Infovis/Core/Testing/Cxx/TestArrayNorm.cxx index fce6c1a0d620375442260b4c64080c89fec96eab..e47c00da45df4f122e21d134a61280ed2133ed0d 100644 --- a/Infovis/Core/Testing/Cxx/TestArrayNorm.cxx +++ b/Infovis/Core/Testing/Cxx/TestArrayNorm.cxx @@ -32,10 +32,11 @@ #include <stdexcept> #define test_expression(expression) \ + do \ { \ if (!(expression)) \ throw std::runtime_error("Expression failed: " #expression); \ - } + } while (false) static bool close_enough(const double lhs, const double rhs) { diff --git a/Infovis/Core/Testing/Cxx/TestTableToArray.cxx b/Infovis/Core/Testing/Cxx/TestTableToArray.cxx index d73c963734cce5d5d0f5c3629100c7455e150598..bfad3cb6a3d25a67239659aaf74e4cbd3b5f0f2f 100644 --- a/Infovis/Core/Testing/Cxx/TestTableToArray.cxx +++ b/Infovis/Core/Testing/Cxx/TestTableToArray.cxx @@ -34,10 +34,11 @@ #define VTK_CREATE(type, name) vtkSmartPointer<type> name = vtkSmartPointer<type>::New() #define test_expression(expression) \ + do \ { \ if (!(expression)) \ throw std::runtime_error("Expression failed: " #expression); \ - } + } while (false) int TestTableToArray(int vtkNotUsed(argc), char* vtkNotUsed(argv)[]) { diff --git a/Infovis/Core/Testing/Cxx/UnitTestWordCloud.cxx b/Infovis/Core/Testing/Cxx/UnitTestWordCloud.cxx index 6ce71a7801370d06ce51970bc43add0f2213aa73..a630f383ed1e6ae5cec6d7c26c4d54faa840f0b0 100644 --- a/Infovis/Core/Testing/Cxx/UnitTestWordCloud.cxx +++ b/Infovis/Core/Testing/Cxx/UnitTestWordCloud.cxx @@ -135,6 +135,7 @@ int UnitTestWordCloud(int argc, char* argv[]) // Check modified times for containers #define CHECK_CONTAINER_MTIMES(name) \ + do \ { \ auto name = wordCloud->Get##name(); \ auto mtime = wordCloud->GetMTime(); \ @@ -153,7 +154,7 @@ int UnitTestWordCloud(int argc, char* argv[]) std::cout << "\n Modify time is bad for " #name; \ status2++; \ } \ - } + } while (false) std::cout << "Testing Container MTimes..."; auto status2 = 0; diff --git a/Interaction/Widgets/Testing/Cxx/WidgetTestingMacros.h b/Interaction/Widgets/Testing/Cxx/WidgetTestingMacros.h index 731256f9b8333e57d069395eec8ea8bff18be0d9..67735c213f0506d1e4294f4741b6cb8a9adb188b 100644 --- a/Interaction/Widgets/Testing/Cxx/WidgetTestingMacros.h +++ b/Interaction/Widgets/Testing/Cxx/WidgetTestingMacros.h @@ -574,7 +574,7 @@ object->SetPlaceFactor(0.5); \ object->SetHandleSize(0.05); \ std::cout << "Done basic rep methods" << std::endl; \ - EXERCISE_BASIC_PROP_METHODS(className, object); + EXERCISE_BASIC_PROP_METHODS(className, object) /// test vtkAngleRepresentation methods #define EXERCISE_BASIC_ANGLE_REPRESENTATION_METHODS(className, object) \ diff --git a/Interaction/Widgets/vtkBoxRepresentation.cxx b/Interaction/Widgets/vtkBoxRepresentation.cxx index 9dd7f22384d683a44e21def5aaaa9c9645b1870e..f70b7af016cbeec0449a56265cb990cd874e48d8 100644 --- a/Interaction/Widgets/vtkBoxRepresentation.cxx +++ b/Interaction/Widgets/vtkBoxRepresentation.cxx @@ -1591,9 +1591,12 @@ vtkTypeBool vtkBoxRepresentation::HasTranslucentPolygonalGeometry() } #define VTK_AVERAGE(a, b, c) \ - c[0] = (a[0] + b[0]) / 2.0; \ - c[1] = (a[1] + b[1]) / 2.0; \ - c[2] = (a[2] + b[2]) / 2.0; + do \ + { \ + c[0] = (a[0] + b[0]) / 2.0; \ + c[1] = (a[1] + b[1]) / 2.0; \ + c[2] = (a[2] + b[2]) / 2.0; \ + } while (false) //------------------------------------------------------------------------------ void vtkBoxRepresentation::PositionHandles() diff --git a/Interaction/Widgets/vtkBoxWidget.cxx b/Interaction/Widgets/vtkBoxWidget.cxx index 835897e48ebfb999d02b770ec05e7a39b970efac..3d6d2d77ae097f274bf3f9603473a15ef00e4769 100644 --- a/Interaction/Widgets/vtkBoxWidget.cxx +++ b/Interaction/Widgets/vtkBoxWidget.cxx @@ -420,9 +420,12 @@ void vtkBoxWidget::PrintSelf(ostream& os, vtkIndent indent) } #define VTK_AVERAGE(a, b, c) \ - c[0] = (a[0] + b[0]) / 2.0; \ - c[1] = (a[1] + b[1]) / 2.0; \ - c[2] = (a[2] + b[2]) / 2.0; + do \ + { \ + c[0] = (a[0] + b[0]) / 2.0; \ + c[1] = (a[1] + b[1]) / 2.0; \ + c[2] = (a[2] + b[2]) / 2.0; \ + } while (false) void vtkBoxWidget::PositionHandles() { diff --git a/Interaction/Widgets/vtkResliceCursorActor.cxx b/Interaction/Widgets/vtkResliceCursorActor.cxx index 763512cd816824c7edf068e8161452c75e4879a7..bac387cfb5c0531fce23dbe641d91a50acbc51fb 100644 --- a/Interaction/Widgets/vtkResliceCursorActor.cxx +++ b/Interaction/Widgets/vtkResliceCursorActor.cxx @@ -313,15 +313,18 @@ vtkActor* vtkResliceCursorActor::GetCenterlineActor(int axis) //------------------------------------------------------------------------------ // Prints an object if it exists. #define vtkPrintMemberObjectMacro(obj, os, indent) \ - os << (indent) << #obj << ": "; \ - if (this->obj) \ + do \ { \ - os << this->obj << "\n"; \ - } \ - else \ - { \ - os << "(null)\n"; \ - } + os << (indent) << #obj << ": "; \ + if (this->obj) \ + { \ + os << this->obj << "\n"; \ + } \ + else \ + { \ + os << "(null)\n"; \ + } \ + } while (false) //------------------------------------------------------------------------------ void vtkResliceCursorActor::PrintSelf(ostream& os, vtkIndent indent) diff --git a/Interaction/Widgets/vtkResliceCursorRepresentation.cxx b/Interaction/Widgets/vtkResliceCursorRepresentation.cxx index c6dfd50a9fda9c03ae4727f6d0a3584e9ab4823d..861bcc8d403f33ddae58c872ab684545d899223e 100644 --- a/Interaction/Widgets/vtkResliceCursorRepresentation.cxx +++ b/Interaction/Widgets/vtkResliceCursorRepresentation.cxx @@ -940,15 +940,18 @@ void vtkResliceCursorRepresentation::GenerateText() //------------------------------------------------------------------------------ // Prints an object if it exists. #define vtkPrintMemberObjectMacro(obj, os, indent) \ - os << indent << #obj << ": "; \ - if (this->obj) \ + do \ { \ - os << this->obj << "\n"; \ - } \ - else \ - { \ - os << "(null)\n"; \ - } + os << indent << #obj << ": "; \ + if (this->obj) \ + { \ + os << this->obj << "\n"; \ + } \ + else \ + { \ + os << "(null)\n"; \ + } \ + } while (false) //------------------------------------------------------------------------------ void vtkResliceCursorRepresentation::PrintSelf(ostream& os, vtkIndent indent) diff --git a/Interaction/Widgets/vtkTensorRepresentation.cxx b/Interaction/Widgets/vtkTensorRepresentation.cxx index 562a18af67554fd3a22fad34887b4cae8d290007..248d562b524c60bb16ab2de0ee252babb417b8d4 100644 --- a/Interaction/Widgets/vtkTensorRepresentation.cxx +++ b/Interaction/Widgets/vtkTensorRepresentation.cxx @@ -1713,9 +1713,12 @@ vtkTypeBool vtkTensorRepresentation::HasTranslucentPolygonalGeometry() } #define VTK_AVERAGE(a, b, c) \ - c[0] = (a[0] + b[0]) / 2.0; \ - c[1] = (a[1] + b[1]) / 2.0; \ - c[2] = (a[2] + b[2]) / 2.0; + do \ + { \ + c[0] = (a[0] + b[0]) / 2.0; \ + c[1] = (a[1] + b[1]) / 2.0; \ + c[2] = (a[2] + b[2]) / 2.0; \ + } while (false) //------------------------------------------------------------------------------ // Position the handles based on the current positions of the eight corner points diff --git a/Parallel/Core/vtkCommunicator.cxx b/Parallel/Core/vtkCommunicator.cxx index 235df9485c22093d58dd9a6b6c99441e921f8cc0..3947599c807c99ed11ddde2a5cfc924d4372a863 100644 --- a/Parallel/Core/vtkCommunicator.cxx +++ b/Parallel/Core/vtkCommunicator.cxx @@ -1529,7 +1529,7 @@ int vtkCommunicator::ReduceVoidArray(const void* sendBuffer, void* recvBuffer, v #define OP_CASE(id, opclass) \ case id: \ opClass = new vtkCommunicator##opclass##Class; \ - break; + break vtkCommunicator::Operation* opClass = nullptr; diff --git a/Parallel/Core/vtkSocketCommunicator.cxx b/Parallel/Core/vtkSocketCommunicator.cxx index c9bae7549351d0d8d938657a7caa362e685c4a92..1ce206f749737e87670aff56880e6e7eefb07da5 100644 --- a/Parallel/Core/vtkSocketCommunicator.cxx +++ b/Parallel/Core/vtkSocketCommunicator.cxx @@ -75,10 +75,13 @@ public: }; #define vtkSocketCommunicatorErrorMacro(msg) \ - if (this->ReportErrors) \ + do \ { \ - vtkErrorMacro(msg); \ - } + if (this->ReportErrors) \ + { \ + vtkErrorMacro(msg); \ + } \ + } while (false) // The handshake checks that the client and server are using the same // version of this source file. It first compares a fixed integer diff --git a/Parallel/MPI/Testing/Cxx/ExerciseMultiProcessController.cxx b/Parallel/MPI/Testing/Cxx/ExerciseMultiProcessController.cxx index a4c6f1d546cdf1ce70c8d016667670dbb22a1b9c..304b3d11a78c3f76dc2e459124e2a20ed806d940 100644 --- a/Parallel/MPI/Testing/Cxx/ExerciseMultiProcessController.cxx +++ b/Parallel/MPI/Testing/Cxx/ExerciseMultiProcessController.cxx @@ -46,7 +46,11 @@ #include <vector> // Update progress only on root node. -#define COUT(msg) vtkLogIf(INFO, controller->GetLocalProcessId() == 0, "" msg); +#define COUT(msg) \ + do \ + { \ + vtkLogIf(INFO, controller->GetLocalProcessId() == 0, "" msg); \ + } while (false) //============================================================================= // A simple structure for passing data in and out of the parallel function. diff --git a/Rendering/Annotation/vtkScalarBarActor.cxx b/Rendering/Annotation/vtkScalarBarActor.cxx index 163ad65477de2af80b4dfdaa07939a7fb25c8842..1bd969ebce091405c78cf9b0a167f4204066f94c 100644 --- a/Rendering/Annotation/vtkScalarBarActor.cxx +++ b/Rendering/Annotation/vtkScalarBarActor.cxx @@ -2194,25 +2194,28 @@ int vtkScalarBarActor::PlaceAnnotationsVertically(double barX, double barY, } #define VTK_ANN_VLAYOUT(j, dir, delt) \ - ctr = this->P->AnnotationAnchors[j]; \ - ll[0] = lpts->InsertNextPoint(xl0, ctr, 0.); \ - this->P->AnnotationLabels[j]->GetSize(this->P->Viewport, tsz); \ - hh = (tsz[1] + pad) / 2.; /* label half-height, incl. padding */ \ - if (((dir) < 0 && ctr + hh > dnCum) || ((dir) > 0 && ctr - hh < upCum)) \ - ctr = (delt) + (dir)*hh; \ - this->P->AnnotationLabels[j]->GetTextProperty()->SetJustification( \ - this->TextPosition == PrecedeScalarBar ? VTK_TEXT_LEFT : VTK_TEXT_RIGHT); \ - this->P->AnnotationLabels[j]->GetTextProperty()->SetVerticalJustificationToCentered(); \ - this->P->AnnotationLabels[j]->SetPosition(barX + \ - (this->TextPosition == PrecedeScalarBar ? 1 : -1) * (pad + this->AnnotationLeaderPadding), \ - ctr); \ - ll[1] = lpts->InsertNextPoint(xl1, ctr, 0.); \ - llines->InsertNextCell(2, ll); \ - llcolors->InsertNextTypedTuple(this->P->AnnotationColors[j].GetData()); \ - if (upCum < ctr + hh) \ - upCum = ctr + hh; \ - if (dnCum > ctr - hh) \ - dnCum = ctr - hh; + do \ + { \ + ctr = this->P->AnnotationAnchors[j]; \ + ll[0] = lpts->InsertNextPoint(xl0, ctr, 0.); \ + this->P->AnnotationLabels[j]->GetSize(this->P->Viewport, tsz); \ + hh = (tsz[1] + pad) / 2.; /* label half-height, incl. padding */ \ + if (((dir) < 0 && ctr + hh > dnCum) || ((dir) > 0 && ctr - hh < upCum)) \ + ctr = (delt) + (dir)*hh; \ + this->P->AnnotationLabels[j]->GetTextProperty()->SetJustification( \ + this->TextPosition == PrecedeScalarBar ? VTK_TEXT_LEFT : VTK_TEXT_RIGHT); \ + this->P->AnnotationLabels[j]->GetTextProperty()->SetVerticalJustificationToCentered(); \ + this->P->AnnotationLabels[j]->SetPosition(barX + \ + (this->TextPosition == PrecedeScalarBar ? 1 : -1) * (pad + this->AnnotationLeaderPadding), \ + ctr); \ + ll[1] = lpts->InsertNextPoint(xl1, ctr, 0.); \ + llines->InsertNextCell(2, ll); \ + llcolors->InsertNextTypedTuple(this->P->AnnotationColors[j].GetData()); \ + if (upCum < ctr + hh) \ + upCum = ctr + hh; \ + if (dnCum > ctr - hh) \ + dnCum = ctr - hh; \ + } while (false) int numNotes = static_cast<int>(this->P->AnnotationLabels.size()); vtkPoints* lpts = vtkPoints::New(); @@ -2551,12 +2554,15 @@ int vtkScalarBarActor::PlaceAnnotationsHorizontally( } #define VTK_ANN_HLAYOUT(j, placer) \ - this->P->AnnotationLabels[j]->GetTextProperty()->SetJustification( \ - (placer).Places[j].Justification); \ - this->P->AnnotationLabels[j]->GetTextProperty()->SetVerticalJustification( \ - (placer).Dir > 0 ? VTK_TEXT_BOTTOM : VTK_TEXT_TOP); \ - this->P->AnnotationLabels[j]->SetPosition((placer).Places[j].Anchor); \ - (placer).AddBrokenLeader(j, lpts, llines, llcolors, this->P->AnnotationColors[j]); + do \ + { \ + this->P->AnnotationLabels[j]->GetTextProperty()->SetJustification( \ + (placer).Places[j].Justification); \ + this->P->AnnotationLabels[j]->GetTextProperty()->SetVerticalJustification( \ + (placer).Dir > 0 ? VTK_TEXT_BOTTOM : VTK_TEXT_TOP); \ + this->P->AnnotationLabels[j]->SetPosition((placer).Places[j].Anchor); \ + (placer).AddBrokenLeader(j, lpts, llines, llcolors, this->P->AnnotationColors[j]); \ + } while (false) int numNotes = static_cast<int>(this->P->AnnotationLabels.size()); bool precede = this->TextPosition == vtkScalarBarActor::PrecedeScalarBar; diff --git a/Rendering/Core/Testing/Cxx/TestCompositeDataDisplayAttributes.cxx b/Rendering/Core/Testing/Cxx/TestCompositeDataDisplayAttributes.cxx index 780a478563efea8b6b81eaf5e94c77ddf78b70b7..93eb580c6964871410688bcd092d838a2f97d639 100644 --- a/Rendering/Core/Testing/Cxx/TestCompositeDataDisplayAttributes.cxx +++ b/Rendering/Core/Testing/Cxx/TestCompositeDataDisplayAttributes.cxx @@ -21,11 +21,15 @@ #include "vtkXMLMultiBlockDataReader.h" #define Verify(x) \ - if (!(x)) \ + do \ { \ - vtkLogF(ERROR, "check failed for " #x); \ - return EXIT_FAILURE; \ - } + if (!(x)) \ + { \ + vtkLogF(ERROR, "check failed for " #x); \ + return EXIT_FAILURE; \ + } \ + } while (false) + int TestCompositeDataDisplayAttributes(int argc, char* argv[]) { char* fname = vtkTestUtilities::ExpandDataFileName(argc, argv, "Data/mb_with_pieces.vtm"); diff --git a/Rendering/Matplotlib/vtkMatplotlibMathTextUtilities.cxx b/Rendering/Matplotlib/vtkMatplotlibMathTextUtilities.cxx index 438a8ff7735afec2009b23eefc3bbceff4f54a29..56abf7f180bc7de10effba4cb75d242b1f93c521 100644 --- a/Rendering/Matplotlib/vtkMatplotlibMathTextUtilities.cxx +++ b/Rendering/Matplotlib/vtkMatplotlibMathTextUtilities.cxx @@ -57,10 +57,13 @@ vtkMatplotlibMathTextUtilities::Availability vtkMatplotlibMathTextUtilities::MPL // is defined in the environment. Use vtkGenericWarningMacro to allow this to // work in release mode builds. #define vtkMplStartUpDebugMacro(x) \ - if (debug) \ + do \ { \ - vtkGenericWarningMacro(x); \ - } + if (debug) \ + { \ + vtkGenericWarningMacro(x); \ + } \ + } while (false) vtkObjectFactoryNewMacro(vtkMatplotlibMathTextUtilities); diff --git a/Rendering/OpenGL2/vtkDualDepthPeelingPass.cxx b/Rendering/OpenGL2/vtkDualDepthPeelingPass.cxx index ed37932bceed664b5bd8eaf49b2a36906c9dcdea..491a4929a65a0f0e690e2d1adee05182fe75421b 100644 --- a/Rendering/OpenGL2/vtkDualDepthPeelingPass.cxx +++ b/Rendering/OpenGL2/vtkDualDepthPeelingPass.cxx @@ -64,7 +64,7 @@ using RenderEvent = vtkRenderTimerLog::ScopedEventLogger; -#define TIME_FUNCTION(functionName) VTK_SCOPED_RENDER_EVENT(#functionName, this->Timer); +#define TIME_FUNCTION(functionName) VTK_SCOPED_RENDER_EVENT(#functionName, this->Timer) vtkStandardNewMacro(vtkDualDepthPeelingPass); vtkCxxSetObjectMacro(vtkDualDepthPeelingPass, VolumetricPass, vtkRenderPass); diff --git a/Rendering/OpenGL2/vtkOpenGLImageMapper.cxx b/Rendering/OpenGL2/vtkOpenGLImageMapper.cxx index ba1408bd1b354292fa18d49837dd59b591fbc733..1f0e511ba5d8bc8cd40435445a3edd022e39f001 100644 --- a/Rendering/OpenGL2/vtkOpenGLImageMapper.cxx +++ b/Rendering/OpenGL2/vtkOpenGLImageMapper.cxx @@ -99,6 +99,7 @@ void vtkOpenGLImageMapper::ReleaseGraphicsResources(vtkWindow* renWin) // be predefined to the same type as y #define vtkClampToUnsignedChar(x, y) \ + do \ { \ val = (y); \ if (val < 0) \ @@ -110,7 +111,7 @@ void vtkOpenGLImageMapper::ReleaseGraphicsResources(vtkWindow* renWin) val = 255; \ } \ (x) = static_cast<unsigned char>(val); \ - } + } while (false) /* should do proper rounding, as follows: * * XXX(ben.boeckel): This is not proper rounding. This will round the value @@ -122,6 +123,7 @@ void vtkOpenGLImageMapper::ReleaseGraphicsResources(vtkWindow* renWin) // the bit-shift must be done after the comparison to zero // because bit-shift is undefined behaviour for negative numbers #define vtkClampIntToUnsignedChar(x, y, shift) \ + do \ { \ val = (y); \ if (val < 0) \ @@ -134,7 +136,7 @@ void vtkOpenGLImageMapper::ReleaseGraphicsResources(vtkWindow* renWin) val = 255; \ } \ (x) = static_cast<unsigned char>(val); \ - } + } while (false) // pad an integer to a multiply of four, for OpenGL inline int vtkPadToFour(int n) diff --git a/Rendering/Volume/vtkFixedPointVolumeRayCastMapper.cxx b/Rendering/Volume/vtkFixedPointVolumeRayCastMapper.cxx index 8839e9178d962db95099297aa4d3b53333d0863c..75c9acc4f1ee1cdb31511f9607533d697f14b0ba 100644 --- a/Rendering/Volume/vtkFixedPointVolumeRayCastMapper.cxx +++ b/Rendering/Volume/vtkFixedPointVolumeRayCastMapper.cxx @@ -52,21 +52,27 @@ vtkStandardNewMacro(vtkFixedPointVolumeRayCastMapper); vtkCxxSetObjectMacro(vtkFixedPointVolumeRayCastMapper, RayCastImage, vtkFixedPointRayCastImage); #define vtkVRCMultiplyPointMacro(A, B, M) \ - B[0] = A[0] * M[0] + A[1] * M[1] + A[2] * M[2] + M[3]; \ - B[1] = A[0] * M[4] + A[1] * M[5] + A[2] * M[6] + M[7]; \ - B[2] = A[0] * M[8] + A[1] * M[9] + A[2] * M[10] + M[11]; \ - B[3] = A[0] * M[12] + A[1] * M[13] + A[2] * M[14] + M[15]; \ - if (B[3] != 1.0) \ + do \ { \ - B[0] /= B[3]; \ - B[1] /= B[3]; \ - B[2] /= B[3]; \ - } + B[0] = A[0] * M[0] + A[1] * M[1] + A[2] * M[2] + M[3]; \ + B[1] = A[0] * M[4] + A[1] * M[5] + A[2] * M[6] + M[7]; \ + B[2] = A[0] * M[8] + A[1] * M[9] + A[2] * M[10] + M[11]; \ + B[3] = A[0] * M[12] + A[1] * M[13] + A[2] * M[14] + M[15]; \ + if (B[3] != 1.0) \ + { \ + B[0] /= B[3]; \ + B[1] /= B[3]; \ + B[2] /= B[3]; \ + } \ + } while (false) #define vtkVRCMultiplyNormalMacro(A, B, M) \ - B[0] = A[0] * M[0] + A[1] * M[4] + A[2] * M[8]; \ - B[1] = A[0] * M[1] + A[1] * M[5] + A[2] * M[9]; \ - B[2] = A[0] * M[2] + A[1] * M[6] + A[2] * M[10] + do \ + { \ + B[0] = A[0] * M[0] + A[1] * M[4] + A[2] * M[8]; \ + B[1] = A[0] * M[1] + A[1] * M[5] + A[2] * M[9]; \ + B[2] = A[0] * M[2] + A[1] * M[6] + A[2] * M[10]; \ + } while (false) //------------------------------------------------------------------------------ template <class T> diff --git a/Rendering/Volume/vtkUnstructuredGridVolumeRayCastMapper.cxx b/Rendering/Volume/vtkUnstructuredGridVolumeRayCastMapper.cxx index fe9ceeaa4206700c3e6b892657f75407381bc447..78500ea3d7b809a957771465695af490826c8f83 100644 --- a/Rendering/Volume/vtkUnstructuredGridVolumeRayCastMapper.cxx +++ b/Rendering/Volume/vtkUnstructuredGridVolumeRayCastMapper.cxx @@ -220,14 +220,17 @@ void vtkUnstructuredGridVolumeRayCastMapper::Render(vtkRenderer* ren, vtkVolume* { #define ESTABLISH_INTEGRATOR(classname) \ - if (!this->RealRayIntegrator || (!this->RealRayIntegrator->IsA(#classname))) \ + do \ { \ - if (this->RealRayIntegrator) \ - this->RealRayIntegrator->UnRegister(this); \ - this->RealRayIntegrator = classname::New(); \ - this->RealRayIntegrator->Register(this); \ - this->RealRayIntegrator->Delete(); \ - } + if (!this->RealRayIntegrator || (!this->RealRayIntegrator->IsA(#classname))) \ + { \ + if (this->RealRayIntegrator) \ + this->RealRayIntegrator->UnRegister(this); \ + this->RealRayIntegrator = classname::New(); \ + this->RealRayIntegrator->Register(this); \ + this->RealRayIntegrator->Delete(); \ + } \ + } while (false) if (this->CellScalars) { diff --git a/Rendering/Volume/vtkUnstructuredGridVolumeZSweepMapper.cxx b/Rendering/Volume/vtkUnstructuredGridVolumeZSweepMapper.cxx index 01293fb83c00ad6ec89c8618432539be3ee94a86..49eaffce83a593a08617a1c6879b3da8a91e82f6 100644 --- a/Rendering/Volume/vtkUnstructuredGridVolumeZSweepMapper.cxx +++ b/Rendering/Volume/vtkUnstructuredGridVolumeZSweepMapper.cxx @@ -2523,14 +2523,17 @@ void vtkUnstructuredGridVolumeZSweepMapper::SetMaxPixelListSize(int size) //------------------------------------------------------------------------------ #define ESTABLISH_INTEGRATOR(classname) \ - if (!this->RealRayIntegrator || (!this->RealRayIntegrator->IsA(#classname))) \ + do \ { \ - if (this->RealRayIntegrator) \ - this->RealRayIntegrator->UnRegister(this); \ - this->RealRayIntegrator = classname::New(); \ - this->RealRayIntegrator->Register(this); \ - this->RealRayIntegrator->Delete(); \ - } + if (!this->RealRayIntegrator || (!this->RealRayIntegrator->IsA(#classname))) \ + { \ + if (this->RealRayIntegrator) \ + this->RealRayIntegrator->UnRegister(this); \ + this->RealRayIntegrator = classname::New(); \ + this->RealRayIntegrator->Register(this); \ + this->RealRayIntegrator->Delete(); \ + } \ + } while (false) //------------------------------------------------------------------------------ // Description: diff --git a/Rendering/VolumeOpenGL2/vtkOpenGLProjectedTetrahedraMapper.cxx b/Rendering/VolumeOpenGL2/vtkOpenGLProjectedTetrahedraMapper.cxx index fa50151d7de949be25493278f81ad971b8dba664..0be3d4e83d3578719fdd880ac2b227315c414717 100644 --- a/Rendering/VolumeOpenGL2/vtkOpenGLProjectedTetrahedraMapper.cxx +++ b/Rendering/VolumeOpenGL2/vtkOpenGLProjectedTetrahedraMapper.cxx @@ -824,9 +824,12 @@ void vtkOpenGLProjectedTetrahedraMapper::ProjectTetrahedra( } #define VEC3SUB(Z, X, Y) \ - (Z)[0] = (X)[0] - (Y)[0]; \ - (Z)[1] = (X)[1] - (Y)[1]; \ - (Z)[2] = (X)[2] - (Y)[2]; + do \ + { \ + (Z)[0] = (X)[0] - (Y)[0]; \ + (Z)[1] = (X)[1] - (Y)[1]; \ + (Z)[2] = (X)[2] - (Y)[2]; \ + } while (false) #define P1 (tet_points + 3 * segment1[0]) #define P2 (tet_points + 3 * segment1[1]) #define P3 (tet_points + 3 * segment2[0])