From 8e7f91dea654f85ffd2c572a9698e7c36ad7f11f Mon Sep 17 00:00:00 2001 From: Frank Quinn Date: Wed, 13 Jun 2018 20:03:48 +0100 Subject: [PATCH] Fixed newer compiler warnings and recent mama price test leaks Signed-off-by: Frank Quinn --- mama/c_cpp/src/gunittest/c/iotest.cpp | 2 +- .../c/mamaprice/pricegeneraltests.cpp | 1 - .../c/middleware/middlewareIoTests.cpp | 6 ++--- .../middlewareSubscriptionTests.cpp | 6 ++--- .../c/payload/payloadgeneraltests.cpp | 6 ++--- mama/c_cpp/src/gunittest/c/transporttest.cpp | 2 +- .../c_cpp/src/gunittest/cpp/MamaPriceTest.cpp | 24 +++++++------------ 7 files changed, 20 insertions(+), 27 deletions(-) diff --git a/mama/c_cpp/src/gunittest/c/iotest.cpp b/mama/c_cpp/src/gunittest/c/iotest.cpp index 865515c99..6e3786765 100644 --- a/mama/c_cpp/src/gunittest/c/iotest.cpp +++ b/mama/c_cpp/src/gunittest/c/iotest.cpp @@ -109,7 +109,7 @@ TEST_F (MamaIoTestC, getDescriptor) mamaIo io = NULL; mamaQueue queue = NULL; uint32_t descriptor = 1; - uint32_t testDescriptor = NULL; + uint32_t testDescriptor = 0; mamaIoType ioType = MAMA_IO_READ; ASSERT_EQ (MAMA_STATUS_OK, diff --git a/mama/c_cpp/src/gunittest/c/mamaprice/pricegeneraltests.cpp b/mama/c_cpp/src/gunittest/c/mamaprice/pricegeneraltests.cpp index 516e34dd5..e2f19defd 100644 --- a/mama/c_cpp/src/gunittest/c/mamaprice/pricegeneraltests.cpp +++ b/mama/c_cpp/src/gunittest/c/mamaprice/pricegeneraltests.cpp @@ -880,7 +880,6 @@ TEST_F (MamaPriceTestC, testSetFromStringMamaPriceInvalidPrice) mamaPrice price = NULL; const char* value = "MY PRICE"; - double val; ASSERT_EQ ( MAMA_STATUS_OK, mamaPrice_create(&price) ); diff --git a/mama/c_cpp/src/gunittest/c/middleware/middlewareIoTests.cpp b/mama/c_cpp/src/gunittest/c/middleware/middlewareIoTests.cpp index 879198b17..abdd45719 100644 --- a/mama/c_cpp/src/gunittest/c/middleware/middlewareIoTests.cpp +++ b/mama/c_cpp/src/gunittest/c/middleware/middlewareIoTests.cpp @@ -71,7 +71,7 @@ void MAMACALLTYPE onIo(mamaIo io, mamaIoType ioType, void* closure) TEST_F (MiddlewareIoTests, create) { ioBridge io = NULL; - uint32_t descriptor = NULL; + uint32_t descriptor = 0; mamaIoType ioType = MAMA_IO_READ; mamaIo parent = NULL; void* closure = NULL; @@ -184,7 +184,7 @@ TEST_F (MiddlewareIoTests, getDescriptor) mamaIo parent = NULL; void* closure = NULL; mamaQueue queue = NULL; - uint32_t result = NULL; + uint32_t result = 0; ASSERT_EQ(MAMA_STATUS_OK, mamaQueue_create(&queue, mBridge)); @@ -226,7 +226,7 @@ TEST_F (MiddlewareIoTests, getDescriptorInvalidResult) TEST_F (MiddlewareIoTests, createDestroy) { ioBridge io = NULL; - uint32_t descriptor = NULL; + uint32_t descriptor = 0; mamaIoType ioType = MAMA_IO_READ; mamaIo parent = NULL; void* closure = NULL; diff --git a/mama/c_cpp/src/gunittest/c/middleware/middlewareSubscriptionTests.cpp b/mama/c_cpp/src/gunittest/c/middleware/middlewareSubscriptionTests.cpp index c34aaf556..d243d24d0 100644 --- a/mama/c_cpp/src/gunittest/c/middleware/middlewareSubscriptionTests.cpp +++ b/mama/c_cpp/src/gunittest/c/middleware/middlewareSubscriptionTests.cpp @@ -357,7 +357,7 @@ TEST_F (MiddlewareSubscriptionTests, destroyInvalid) TEST_F (MiddlewareSubscriptionTests, isValid) { - int res = NULL; + int res = 0; ASSERT_EQ(MAMA_STATUS_OK, mamaSubscription_create(parent, queue, &callbacks, source, sourceName, closure)); @@ -375,7 +375,7 @@ TEST_F (MiddlewareSubscriptionTests, isValid) TEST_F (MiddlewareSubscriptionTests, isValidInvalid) { - int res = NULL; + int res = 0; res = mBridge->bridgeMamaSubscriptionIsValid(NULL); @@ -385,7 +385,7 @@ TEST_F (MiddlewareSubscriptionTests, isValidInvalid) TEST_F (MiddlewareSubscriptionTests, hasWildcards) { - int res = NULL; + int res = 0; res = mBridge->bridgeMamaSubscriptionHasWildcards(NULL); diff --git a/mama/c_cpp/src/gunittest/c/payload/payloadgeneraltests.cpp b/mama/c_cpp/src/gunittest/c/payload/payloadgeneraltests.cpp index e5b956be6..ec8c1b2b3 100644 --- a/mama/c_cpp/src/gunittest/c/payload/payloadgeneraltests.cpp +++ b/mama/c_cpp/src/gunittest/c/payload/payloadgeneraltests.cpp @@ -1855,7 +1855,7 @@ TEST_F(PayloadGeneralTests, IterHasNextValid) { msgPayload testPayload = NULL; msgPayloadIter testIter = NULL; - mama_bool_t output = NULL; + mama_bool_t output = 0; result = aBridge->msgPayloadCreate(&testPayload); EXPECT_EQ (MAMA_STATUS_OK, result); @@ -1877,7 +1877,7 @@ TEST_F(PayloadGeneralTests, IterHasNextValid) TEST_F(PayloadGeneralTests, IterHasNextInValidIter) { msgPayload testPayload = NULL; - mama_bool_t output = NULL; + mama_bool_t output = 0; result = aBridge->msgPayloadCreate(&testPayload); EXPECT_EQ (MAMA_STATUS_OK, result); @@ -1896,7 +1896,7 @@ TEST_F(PayloadGeneralTests, IterHasNextInValidPayload) { msgPayload testPayload = NULL; msgPayloadIter testIter = NULL; - mama_bool_t output = NULL; + mama_bool_t output = 0; result = aBridge->msgPayloadCreate(&testPayload); EXPECT_EQ (MAMA_STATUS_OK, result); diff --git a/mama/c_cpp/src/gunittest/c/transporttest.cpp b/mama/c_cpp/src/gunittest/c/transporttest.cpp index 2fd5da92c..6e42fd71e 100644 --- a/mama/c_cpp/src/gunittest/c/transporttest.cpp +++ b/mama/c_cpp/src/gunittest/c/transporttest.cpp @@ -212,7 +212,7 @@ TEST_F (MamaTransportTestC, InvokeQuality) const char* tportName = getTransport(); mamaTransport tport = NULL; int invoke = 1; - int testInvoke = NULL; + int testInvoke = 0; ASSERT_EQ (MAMA_STATUS_OK, mamaTransport_allocate (&tport)); diff --git a/mama/c_cpp/src/gunittest/cpp/MamaPriceTest.cpp b/mama/c_cpp/src/gunittest/cpp/MamaPriceTest.cpp index 76049cc39..b2ab75a3e 100644 --- a/mama/c_cpp/src/gunittest/cpp/MamaPriceTest.cpp +++ b/mama/c_cpp/src/gunittest/cpp/MamaPriceTest.cpp @@ -59,12 +59,10 @@ MamaPriceTest::~MamaPriceTest(void) void MamaPriceTest::SetUp(void) { // Create a new mama price - //ASSERT_EQ(mamaPrice_create(&m_price), MAMA_STATUS_OK); m_price = new MamaPrice(); m_priceDp = new MamaPrice(); // Set the value of the price - //ASSERT_EQ(mamaPrice_setValue(m_price, 4000000000), MAMA_STATUS_OK); m_price->setValue(4000000000); m_priceDp->setValue(1.12345678901234567890); } @@ -74,11 +72,15 @@ void MamaPriceTest::TearDown(void) // Delete the price if(m_price != NULL) { - //ASSERT_EQ(mamaPrice_destroy(m_price), MAMA_STATUS_OK); - delete m_price; - m_price = NULL; + delete m_price; + m_price = NULL; + } + // Delete the extended precision price + if(m_priceDp != NULL) + { + delete m_priceDp; + m_priceDp = NULL; } - ASSERT_TRUE(m_price == NULL); } /* ************************************************************************* */ @@ -533,12 +535,9 @@ TEST_F(MamaPriceTest, SetPrecisionDiv512) TEST_F(MamaPriceTest, SetFromString) { - MamaPrice* m_price; const char* value = "123.45"; double doubleValue = 0.0; - m_price = new MamaPrice(); - m_price->setFromString(value); doubleValue = m_price->getValue(); @@ -548,12 +547,9 @@ TEST_F(MamaPriceTest, SetFromString) TEST_F(MamaPriceTest, SetFromStringLargeValue) { - MamaPrice* m_price; const char* value = "123.456789012345"; double doubleValue = 0.0; - m_price = new MamaPrice(); - m_price->setFromString(value); doubleValue = m_price->getValue(); @@ -563,12 +559,10 @@ TEST_F(MamaPriceTest, SetFromStringLargeValue) TEST_F(MamaPriceTest, SetFromStringInvalidPrice) { - MamaPrice* m_price; const char* value = "MY PRICE"; double doubleValue = 0.0; - m_price = new MamaPrice(); - + m_price->clear(); m_price->setFromString(value); doubleValue = m_price->getValue();