From 09940a5c0bdbd0a293a1053d38cdbc9b9d495169 Mon Sep 17 00:00:00 2001 From: Peter Thorson Date: Sun, 2 Feb 2014 13:12:52 -0600 Subject: [PATCH] Corrects more obscure shadowed variables cases --- .../broadcast_server/broadcast_server.cpp | 6 +++--- websocketpp/connection.hpp | 4 ++-- websocketpp/endpoint.hpp | 8 ++++---- websocketpp/error.hpp | 6 +++--- websocketpp/http/impl/request.hpp | 18 ++++++++--------- websocketpp/http/impl/response.hpp | 20 +++++++++---------- websocketpp/impl/connection_impl.hpp | 16 +++++++-------- websocketpp/roles/server_endpoint.hpp | 3 +-- websocketpp/uri.hpp | 16 +++++++-------- 9 files changed, 48 insertions(+), 49 deletions(-) diff --git a/examples/broadcast_server/broadcast_server.cpp b/examples/broadcast_server/broadcast_server.cpp index 6ca9bcbb04..29c18b6aa0 100644 --- a/examples/broadcast_server/broadcast_server.cpp +++ b/examples/broadcast_server/broadcast_server.cpp @@ -142,13 +142,13 @@ private: int main() { try { - broadcast_server server; + broadcast_server server_instance; // Start a thread to run the processing loop - thread t(bind(&broadcast_server::process_messages,&server)); + thread t(bind(&broadcast_server::process_messages,&server_instance)); // Run the asio loop with the main thread - server.run(9002); + server_instance.run(9002); t.join(); diff --git a/websocketpp/connection.hpp b/websocketpp/connection.hpp index f555cfaabe..dc15c1317b 100644 --- a/websocketpp/connection.hpp +++ b/websocketpp/connection.hpp @@ -279,9 +279,9 @@ private: }; public: - explicit connection(bool is_server, std::string const & ua, alog_type& alog, + explicit connection(bool p_is_server, std::string const & ua, alog_type& alog, elog_type& elog, rng_type & rng) - : transport_con_type(is_server,alog,elog) + : transport_con_type(p_is_server, alog, elog) , m_handle_read_frame(lib::bind( &type::handle_read_frame, this, diff --git a/websocketpp/endpoint.hpp b/websocketpp/endpoint.hpp index 567ca6b543..35cc50eac0 100644 --- a/websocketpp/endpoint.hpp +++ b/websocketpp/endpoint.hpp @@ -87,21 +87,21 @@ public: typedef lib::shared_ptr hdl_type; - explicit endpoint(bool is_server) + explicit endpoint(bool p_is_server) : m_alog(config::alog_level, &std::cout) , m_elog(config::elog_level, &std::cerr) , m_user_agent(::websocketpp::user_agent) , m_open_handshake_timeout_dur(config::timeout_open_handshake) , m_close_handshake_timeout_dur(config::timeout_close_handshake) , m_pong_timeout_dur(config::timeout_pong) - , m_is_server(is_server) + , m_is_server(p_is_server) { m_alog.set_channels(config::alog_level); m_elog.set_channels(config::elog_level); - m_alog.write(log::alevel::devel,"endpoint constructor"); + m_alog.write(log::alevel::devel, "endpoint constructor"); - transport_type::init_logging(&m_alog,&m_elog); + transport_type::init_logging(&m_alog, &m_elog); } /// Returns the user agent string that this endpoint will use diff --git a/websocketpp/error.hpp b/websocketpp/error.hpp index c9bbc1b4d5..45a345849f 100644 --- a/websocketpp/error.hpp +++ b/websocketpp/error.hpp @@ -216,9 +216,9 @@ namespace websocketpp { class exception : public std::exception { public: - exception(std::string const & msg, - error::value code = error::general) - : m_msg(msg),m_code(code) {} + exception(std::string const & msg, error::value p_code = error::general) + : m_msg(msg), m_code(p_code) {} + ~exception() throw() {} virtual char const * what() const throw() { diff --git a/websocketpp/http/impl/request.hpp b/websocketpp/http/impl/request.hpp index 804a7faff8..19f91d853a 100644 --- a/websocketpp/http/impl/request.hpp +++ b/websocketpp/http/impl/request.hpp @@ -38,15 +38,15 @@ namespace http { namespace parser { inline bool request::parse_complete(std::istream& s) { - std::string request; + std::string req; // get status line - std::getline(s, request); + std::getline(s, req); - if (request[request.size()-1] == '\r') { - request.erase(request.end()-1); + if (req[req.size()-1] == '\r') { + req.erase(req.end()-1); - std::stringstream ss(request); + std::stringstream ss(req); std::string val; ss >> val; @@ -133,12 +133,12 @@ inline size_t request::consume(const char *buf, size_t len) { inline std::string request::raw() { // TODO: validation. Make sure all required fields have been set? - std::stringstream raw; + std::stringstream ret; - raw << m_method << " " << m_uri << " " << get_version() << "\r\n"; - raw << raw_headers() << "\r\n" << m_body; + ret << m_method << " " << m_uri << " " << get_version() << "\r\n"; + ret << raw_headers() << "\r\n" << m_body; - return raw.str(); + return ret.str(); } inline void request::set_method(const std::string& method) { diff --git a/websocketpp/http/impl/response.hpp b/websocketpp/http/impl/response.hpp index bcddd17633..e3a73eb15a 100644 --- a/websocketpp/http/impl/response.hpp +++ b/websocketpp/http/impl/response.hpp @@ -172,15 +172,15 @@ inline size_t response::consume(std::istream & s) { inline bool response::parse_complete(std::istream& s) { // parse a complete header (ie \r\n\r\n MUST be in the input stream) - std::string response; + std::string line; // get status line - std::getline(s, response); + std::getline(s, line); - if (response[response.size()-1] == '\r') { - response.erase(response.end()-1); + if (line[line.size()-1] == '\r') { + line.erase(line.end()-1); - std::stringstream ss(response); + std::stringstream ss(line); std::string str_val; int int_val; char char_val[256]; @@ -201,14 +201,14 @@ inline bool response::parse_complete(std::istream& s) { inline std::string response::raw() const { // TODO: validation. Make sure all required fields have been set? - std::stringstream raw; + std::stringstream ret; - raw << get_version() << " " << m_status_code << " " << m_status_msg; - raw << "\r\n" << raw_headers() << "\r\n"; + ret << get_version() << " " << m_status_code << " " << m_status_msg; + ret << "\r\n" << raw_headers() << "\r\n"; - raw << m_body; + ret << m_body; - return raw.str(); + return ret.str(); } inline void response::set_status(status_code::value code) { diff --git a/websocketpp/impl/connection_impl.hpp b/websocketpp/impl/connection_impl.hpp index b2305396b0..b84d1f4c0f 100644 --- a/websocketpp/impl/connection_impl.hpp +++ b/websocketpp/impl/connection_impl.hpp @@ -1630,7 +1630,7 @@ void connection::handle_write_frame(lib::error_code const & ec) m_alog.write(log::alevel::devel,"connection handle_write_frame"); } - bool terminate = m_current_msg->get_terminal(); + bool terminal = m_current_msg->get_terminal(); m_send_buffer.clear(); m_current_msg.reset(); @@ -1641,7 +1641,7 @@ void connection::handle_write_frame(lib::error_code const & ec) return; } - if (terminate) { + if (terminal) { this->terminate(lib::error_code()); return; } @@ -1735,13 +1735,13 @@ void connection::process_control_frame(typename config::message_type::pt } if (op == frame::opcode::PING) { - bool pong = true; + bool should_reply = true; if (m_ping_handler) { - pong = m_ping_handler(m_connection_hdl, msg->get_payload()); + should_reply = m_ping_handler(m_connection_hdl, msg->get_payload()); } - if (pong) { + if (should_reply) { this->pong(msg->get_payload(),ec); if (ec) { m_elog.write(log::elevel::devel, @@ -1813,7 +1813,7 @@ void connection::process_control_frame(typename config::message_type::pt } } else if (m_state == session::state::closing && !m_was_clean) { // ack of our close - m_alog.write(log::alevel::devel,"Got acknowledgement of close"); + m_alog.write(log::alevel::devel, "Got acknowledgement of close"); m_was_clean = true; @@ -1829,11 +1829,11 @@ void connection::process_control_frame(typename config::message_type::pt } } else { // spurious, ignore - m_elog.write(log::elevel::devel,"Got close frame in wrong state"); + m_elog.write(log::elevel::devel, "Got close frame in wrong state"); } } else { // got an invalid control opcode - m_elog.write(log::elevel::devel,"Got control frame with invalid opcode"); + m_elog.write(log::elevel::devel, "Got control frame with invalid opcode"); // initiate protocol error shutdown } } diff --git a/websocketpp/roles/server_endpoint.hpp b/websocketpp/roles/server_endpoint.hpp index 3bdf91ae30..473903a2e7 100644 --- a/websocketpp/roles/server_endpoint.hpp +++ b/websocketpp/roles/server_endpoint.hpp @@ -69,8 +69,7 @@ public: explicit server() : endpoint_type(true) { - endpoint_type::m_alog.write(log::alevel::devel, - "server constructor"); + endpoint_type::m_alog.write(log::alevel::devel, "server constructor"); } // return an initialized connection_ptr. Call start() on this object to diff --git a/websocketpp/uri.hpp b/websocketpp/uri.hpp index 5471031a86..07ed32ebf2 100644 --- a/websocketpp/uri.hpp +++ b/websocketpp/uri.hpp @@ -47,13 +47,13 @@ static uint16_t const uri_default_secure_port = 443; class uri { public: - explicit uri(std::string const & uri) : m_valid(false) { + explicit uri(std::string const & uri_string) : m_valid(false) { std::string::const_iterator it; std::string::const_iterator temp; int state = 0; - it = uri.begin(); + it = uri_string.begin(); if (std::equal(it,it+6,"wss://")) { m_secure = true; @@ -88,14 +88,14 @@ public: //temp = std::find(it,it2,']'); temp = it; - while (temp != uri.end()) { + while (temp != uri_string.end()) { if (*temp == ']') { break; } ++temp; } - if (temp == uri.end()) { + if (temp == uri_string.end()) { return; } else { // validate IPv6 literal parts @@ -103,7 +103,7 @@ public: m_host.append(it,temp); } it = temp+1; - if (it == uri.end()) { + if (it == uri_string.end()) { state = 2; } else if (*it == '/') { state = 2; @@ -119,7 +119,7 @@ public: // IPv4 or hostname // extract until : or / while (state == 0) { - if (it == uri.end()) { + if (it == uri_string.end()) { state = 2; break; } else if (*it == '/') { @@ -137,7 +137,7 @@ public: // parse port std::string port = ""; while (state == 1) { - if (it == uri.end()) { + if (it == uri_string.end()) { // state is not used after this point presently. // this should be re-enabled if it ever is needed in a future // refactoring @@ -159,7 +159,7 @@ public: } m_resource = "/"; - m_resource.append(it,uri.end()); + m_resource.append(it,uri_string.end()); m_valid = true;