From e53bd0e61a96a7320c099ed4a9695d0def4bdd01 Mon Sep 17 00:00:00 2001 From: Gordon Sim Date: Tue, 28 Aug 2012 13:16:59 +0000 Subject: NO-JIRA: Remove const qualifier from encode buffer (can't encode into if it is const, and impls const cast it anyway) git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk@1378125 13f79535-47bb-0310-9956-ffa450edef68 --- qpid/cpp/src/qpid/amqp_0_10/Connection.cpp | 4 ++-- qpid/cpp/src/qpid/amqp_0_10/Connection.h | 2 +- qpid/cpp/src/qpid/broker/SecureConnection.cpp | 2 +- qpid/cpp/src/qpid/broker/SecureConnection.h | 2 +- qpid/cpp/src/qpid/client/TCPConnector.cpp | 4 ++-- qpid/cpp/src/qpid/client/TCPConnector.h | 2 +- qpid/cpp/src/qpid/sys/Codec.h | 2 +- qpid/cpp/src/qpid/sys/cyrus/CyrusSecurityLayer.cpp | 6 +++--- qpid/cpp/src/qpid/sys/cyrus/CyrusSecurityLayer.h | 2 +- 9 files changed, 13 insertions(+), 13 deletions(-) (limited to 'qpid') diff --git a/qpid/cpp/src/qpid/amqp_0_10/Connection.cpp b/qpid/cpp/src/qpid/amqp_0_10/Connection.cpp index ceeaadf70c..8cb675202e 100644 --- a/qpid/cpp/src/qpid/amqp_0_10/Connection.cpp +++ b/qpid/cpp/src/qpid/amqp_0_10/Connection.cpp @@ -74,14 +74,14 @@ bool Connection::isClosed() const { return pushClosed && popClosed; } -size_t Connection::encode(const char* buffer, size_t size) { +size_t Connection::encode(char* buffer, size_t size) { { // Swap frameQueue data into workQueue to avoid holding lock while we encode. Mutex::ScopedLock l(frameQueueLock); if (popClosed) return 0; // Can't pop any more frames. assert(workQueue.empty()); workQueue.swap(frameQueue); } - framing::Buffer out(const_cast(buffer), size); + framing::Buffer out(buffer, size); if (!isClient && !initialized) { framing::ProtocolInitiation pi(getVersion()); pi.encode(out); diff --git a/qpid/cpp/src/qpid/amqp_0_10/Connection.h b/qpid/cpp/src/qpid/amqp_0_10/Connection.h index 995d824796..4a08ee51fd 100644 --- a/qpid/cpp/src/qpid/amqp_0_10/Connection.h +++ b/qpid/cpp/src/qpid/amqp_0_10/Connection.h @@ -61,7 +61,7 @@ class Connection : public sys::ConnectionCodec, QPID_BROKER_EXTERN Connection(sys::OutputControl&, const std::string& id, bool isClient); QPID_BROKER_EXTERN void setInputHandler(std::auto_ptr c); size_t decode(const char* buffer, size_t size); - size_t encode(const char* buffer, size_t size); + size_t encode(char* buffer, size_t size); bool isClosed() const; bool canEncode(); void abort(); diff --git a/qpid/cpp/src/qpid/broker/SecureConnection.cpp b/qpid/cpp/src/qpid/broker/SecureConnection.cpp index 5c1ebf3e8b..59ac9ef132 100644 --- a/qpid/cpp/src/qpid/broker/SecureConnection.cpp +++ b/qpid/cpp/src/qpid/broker/SecureConnection.cpp @@ -43,7 +43,7 @@ size_t SecureConnection::decode(const char* buffer, size_t size) } } -size_t SecureConnection::encode(const char* buffer, size_t size) +size_t SecureConnection::encode(char* buffer, size_t size) { if (secured) { return securityLayer->encode(buffer, size); diff --git a/qpid/cpp/src/qpid/broker/SecureConnection.h b/qpid/cpp/src/qpid/broker/SecureConnection.h index 1547faae1e..632087350e 100644 --- a/qpid/cpp/src/qpid/broker/SecureConnection.h +++ b/qpid/cpp/src/qpid/broker/SecureConnection.h @@ -43,7 +43,7 @@ class SecureConnection : public qpid::sys::ConnectionCodec public: SecureConnection(); size_t decode(const char* buffer, size_t size); - size_t encode(const char* buffer, size_t size); + size_t encode(char* buffer, size_t size); bool canEncode(); void closed(); bool isClosed() const; diff --git a/qpid/cpp/src/qpid/client/TCPConnector.cpp b/qpid/cpp/src/qpid/client/TCPConnector.cpp index a5c6465bad..a14acb214c 100644 --- a/qpid/cpp/src/qpid/client/TCPConnector.cpp +++ b/qpid/cpp/src/qpid/client/TCPConnector.cpp @@ -245,9 +245,9 @@ bool TCPConnector::canEncode() } // Called in IO thread. -size_t TCPConnector::encode(const char* buffer, size_t size) +size_t TCPConnector::encode(char* buffer, size_t size) { - framing::Buffer out(const_cast(buffer), size); + framing::Buffer out(buffer, size); size_t bytesWritten(0); { Mutex::ScopedLock l(lock); diff --git a/qpid/cpp/src/qpid/client/TCPConnector.h b/qpid/cpp/src/qpid/client/TCPConnector.h index c0bc26028d..5e1a3856e6 100644 --- a/qpid/cpp/src/qpid/client/TCPConnector.h +++ b/qpid/cpp/src/qpid/client/TCPConnector.h @@ -90,7 +90,7 @@ class TCPConnector : public Connector, public sys::Codec const qpid::sys::SecuritySettings* getSecuritySettings() { return 0; } size_t decode(const char* buffer, size_t size); - size_t encode(const char* buffer, size_t size); + size_t encode(char* buffer, size_t size); bool canEncode(); protected: diff --git a/qpid/cpp/src/qpid/sys/Codec.h b/qpid/cpp/src/qpid/sys/Codec.h index ace721fbcc..e398403e47 100644 --- a/qpid/cpp/src/qpid/sys/Codec.h +++ b/qpid/cpp/src/qpid/sys/Codec.h @@ -42,7 +42,7 @@ class Codec /** Encode into buffer, return number of bytes encoded */ - virtual std::size_t encode(const char* buffer, std::size_t size) = 0; + virtual std::size_t encode(char* buffer, std::size_t size) = 0; /** Return true if we have data to encode */ virtual bool canEncode() = 0; diff --git a/qpid/cpp/src/qpid/sys/cyrus/CyrusSecurityLayer.cpp b/qpid/cpp/src/qpid/sys/cyrus/CyrusSecurityLayer.cpp index 29b91f3e7a..a4d291ebab 100644 --- a/qpid/cpp/src/qpid/sys/cyrus/CyrusSecurityLayer.cpp +++ b/qpid/cpp/src/qpid/sys/cyrus/CyrusSecurityLayer.cpp @@ -68,7 +68,7 @@ size_t CyrusSecurityLayer::decode(const char* input, size_t size) return size; } -size_t CyrusSecurityLayer::encode(const char* buffer, size_t size) +size_t CyrusSecurityLayer::encode(char* buffer, size_t size) { size_t processed = 0;//records how many bytes have been written to buffer do { @@ -92,12 +92,12 @@ size_t CyrusSecurityLayer::encode(const char* buffer, size_t size) //can't fit all encrypted data in the buffer we've //been given, copy in what we can and hold on to the //rest until the next call - ::memcpy(const_cast(buffer + processed), encrypted, remaining); + ::memcpy(buffer + processed, encrypted, remaining); processed += remaining; encrypted += remaining; encryptedSize -= remaining; } else { - ::memcpy(const_cast(buffer + processed), encrypted, encryptedSize); + ::memcpy(buffer + processed, encrypted, encryptedSize); processed += encryptedSize; encrypted = 0; encryptedSize = 0; diff --git a/qpid/cpp/src/qpid/sys/cyrus/CyrusSecurityLayer.h b/qpid/cpp/src/qpid/sys/cyrus/CyrusSecurityLayer.h index 1645cf1a58..7f108248ee 100644 --- a/qpid/cpp/src/qpid/sys/cyrus/CyrusSecurityLayer.h +++ b/qpid/cpp/src/qpid/sys/cyrus/CyrusSecurityLayer.h @@ -39,7 +39,7 @@ class CyrusSecurityLayer : public qpid::sys::SecurityLayer public: CyrusSecurityLayer(sasl_conn_t*, uint16_t maxFrameSize); size_t decode(const char* buffer, size_t size); - size_t encode(const char* buffer, size_t size); + size_t encode(char* buffer, size_t size); bool canEncode(); void init(qpid::sys::Codec*); private: -- cgit v1.2.1