Move var declarations out of switch blocks in Thrift
Summary: Strict G++ compliance
Reviewed By: fett
git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@664958 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/lib/cpp/src/server/TNonblockingServer.cpp b/lib/cpp/src/server/TNonblockingServer.cpp
index 25cd7b5..2fe1bf7 100644
--- a/lib/cpp/src/server/TNonblockingServer.cpp
+++ b/lib/cpp/src/server/TNonblockingServer.cpp
@@ -38,7 +38,8 @@
}
void TConnection::workSocket() {
- int flags;
+ int flags=0, got=0, left=0, sent=0;
+ uint32_t fetch = 0;
switch (socketState_) {
case SOCKET_RECV:
@@ -59,8 +60,8 @@
}
// Read from the socket
- uint32_t fetch = readWant_ - readBufferPos_;
- int got = recv(socket_, readBuffer_ + readBufferPos_, fetch, 0);
+ fetch = readWant_ - readBufferPos_;
+ got = recv(socket_, readBuffer_ + readBufferPos_, fetch, 0);
if (got > 0) {
// Move along in the buffer
@@ -108,8 +109,8 @@
flags |= MSG_NOSIGNAL;
#endif // ifdef MSG_NOSIGNAL
- int left = writeBufferSize_ - writeBufferPos_;
- int sent = send(socket_, writeBuffer_ + writeBufferPos_, left, flags);
+ left = writeBufferSize_ - writeBufferPos_;
+ sent = send(socket_, writeBuffer_ + writeBufferPos_, left, flags);
if (sent <= 0) {
// Blocking errors are okay, just move on
@@ -147,6 +148,9 @@
* to, or finished receiving the data that it needed to.
*/
void TConnection::transition() {
+
+ int sz = 0;
+
// Switch upon the state that we are currently in and move to a new state
switch (appState_) {
@@ -253,7 +257,7 @@
case APP_READ_FRAME_SIZE:
// We just read the request length, deserialize it
- int sz = *(int32_t*)readBuffer_;
+ sz = *(int32_t*)readBuffer_;
sz = (int32_t)ntohl(sz);
if (sz <= 0) {