From 722425e4d5db1e01f2d4ff2e46d03e1187da8407 Mon Sep 17 00:00:00 2001 From: Alan Conway Date: Mon, 15 Jan 2007 13:58:07 +0000 Subject: 2006-12-08 Jim Meyering Ensure that AccumulatedAck.range is not used uninitialized. * lib/broker/AccumulatedAck.h (AccumulatedAck): Make this a class, rather than a struct. (AccumulatedAck::AccumulatedAck): Add a constructor to require initialization of the "range" member. * lib/broker/BrokerChannel.cpp (Channel) [accumulatedAck]: Initialize. * tests/TxAckTest.cpp (TxAckTest) [acked]: Likewise. * tests/AccumulatedAckTest.cpp (testCovers): Initialize local. (testUpdateAndConsolidate): Likewise. git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@496317 13f79535-47bb-0310-9956-ffa450edef68 --- cpp/lib/broker/AccumulatedAck.h | 4 +++- cpp/lib/broker/BrokerChannel.cpp | 1 + cpp/tests/AccumulatedAckTest.cpp | 6 ++---- cpp/tests/TxAckTest.cpp | 2 +- 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/cpp/lib/broker/AccumulatedAck.h b/cpp/lib/broker/AccumulatedAck.h index 055c8ea3e0..c472f7f3ea 100644 --- a/cpp/lib/broker/AccumulatedAck.h +++ b/cpp/lib/broker/AccumulatedAck.h @@ -31,7 +31,8 @@ namespace qpid { * Keeps an accumulated record of acked messages (by delivery * tag). */ - struct AccumulatedAck{ + class AccumulatedAck { + public: /** * If not zero, then everything up to this value has been * acked. @@ -43,6 +44,7 @@ namespace qpid { */ std::list individual; + AccumulatedAck(u_int64_t r) : range(r) {} void update(u_int64_t tag, bool multiple); void consolidate(); void clear(); diff --git a/cpp/lib/broker/BrokerChannel.cpp b/cpp/lib/broker/BrokerChannel.cpp index f569872770..65aa50d3ac 100644 --- a/cpp/lib/broker/BrokerChannel.cpp +++ b/cpp/lib/broker/BrokerChannel.cpp @@ -40,6 +40,7 @@ Channel::Channel(qpid::framing::ProtocolVersion& _version, OutputHandler* _out, prefetchCount(0), framesize(_framesize), tagGenerator("sgen"), + accumulatedAck(0), store(_store), messageBuilder(this, _store, _stagingThreshold), version(_version){ diff --git a/cpp/tests/AccumulatedAckTest.cpp b/cpp/tests/AccumulatedAckTest.cpp index bfd9358422..a2ee3df752 100644 --- a/cpp/tests/AccumulatedAckTest.cpp +++ b/cpp/tests/AccumulatedAckTest.cpp @@ -36,8 +36,7 @@ class AccumulatedAckTest : public CppUnit::TestCase public: void testCovers() { - AccumulatedAck ack; - ack.range = 5; + AccumulatedAck ack(5); ack.individual.push_back(7); ack.individual.push_back(9); @@ -56,8 +55,7 @@ class AccumulatedAckTest : public CppUnit::TestCase void testUpdateAndConsolidate() { - AccumulatedAck ack; - ack.clear(); + AccumulatedAck ack(0); ack.update(1, false); ack.update(3, false); ack.update(10, false); diff --git a/cpp/tests/TxAckTest.cpp b/cpp/tests/TxAckTest.cpp index 0ffe984ded..7d5b8a838a 100644 --- a/cpp/tests/TxAckTest.cpp +++ b/cpp/tests/TxAckTest.cpp @@ -66,7 +66,7 @@ class TxAckTest : public CppUnit::TestCase public: - TxAckTest() : queue(new Queue("my_queue", false, &store, 0)), op(acked, deliveries, &xid) + TxAckTest() : acked(0), queue(new Queue("my_queue", false, &store, 0)), op(acked, deliveries, &xid) { for(int i = 0; i < 10; i++){ Message::shared_ptr msg(new Message(0, "exchange", "routing_key", false, false)); -- cgit v1.2.1