Skip to content

Commit

Permalink
Fix use of variable names that shadow function parameters. references X…
Browse files Browse the repository at this point in the history
  • Loading branch information
zaphoyd committed Feb 2, 2014
1 parent 5f3b92c commit bb21e3c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 18 deletions.
2 changes: 2 additions & 0 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,13 @@ else:
if env['CXX'].startswith('g++'):
#env.Append(CCFLAGS = ['-Wconversion'])
env.Append(CCFLAGS = ['-Wcast-align'])
env.Append(CCFLAGS = ['-Wshadow'])
elif env['CXX'].startswith('clang++'):
#env.Append(CCFLAGS = ['-Wcast-align'])
#env.Append(CCFLAGS = ['-Wglobal-constructors'])
#env.Append(CCFLAGS = ['-Wconversion'])
env.Append(CCFLAGS = ['-Wno-padded'])
env.Append(CCFLAGS = ['-Wshadow'])

# Wpadded
# Wsign-conversion
Expand Down
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ HEAD
- Bug: Fix a crash when parsing empty HTTP headers. Thank you Thingol for reporting.
- Bug: Fix a crash following use of the `stop_listening` function. Thank you Thingol for
reporting.
- Bug: Fix use of variable names that shadow function parameters. The library should
compile cleanly with -Wshadow now. Thank you giszo for reporting. #318
- Compatibility: Fix compile time conflict with Visual Studio's MIN/MAX macros. Thank you
Robin Rowe for reporting.

Expand Down
6 changes: 3 additions & 3 deletions examples/broadcast_server/broadcast_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ class broadcast_server {
lock.unlock();

if (a.type == SUBSCRIBE) {
unique_lock<mutex> lock(m_connection_lock);
unique_lock<mutex> con_lock(m_connection_lock);
m_connections.insert(a.hdl);
} else if (a.type == UNSUBSCRIBE) {
unique_lock<mutex> lock(m_connection_lock);
unique_lock<mutex> con_lock(m_connection_lock);
m_connections.erase(a.hdl);
} else if (a.type == MESSAGE) {
unique_lock<mutex> lock(m_connection_lock);
unique_lock<mutex> con_lock(m_connection_lock);

con_list::iterator it;
for (it = m_connections.begin(); it != m_connections.end(); ++it) {
Expand Down
29 changes: 14 additions & 15 deletions websocketpp/impl/connection_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -849,7 +849,7 @@ void connection<config>::send_http_response_error() {
// All exit paths for this function need to call send_http_response() or submit
// a new read request with this function as the handler.
template <typename config>
void connection<config>::handle_read_frame(const lib::error_code& ec,
void connection<config>::handle_read_frame(lib::error_code const & ec,
size_t bytes_transferred)
{
//m_alog.write(log::alevel::devel,"connection handle_read_frame");
Expand Down Expand Up @@ -909,24 +909,24 @@ void connection<config>::handle_read_frame(const lib::error_code& ec,
m_alog.write(log::alevel::devel,s.str());
}

lib::error_code ec;
lib::error_code consume_ec;

p += m_processor->consume(
reinterpret_cast<uint8_t*>(m_buf)+p,
bytes_transferred-p,
ec
consume_ec
);

if (m_alog.static_test(log::alevel::devel)) {
std::stringstream s;
s << "bytes left after consume: " << bytes_transferred-p;
m_alog.write(log::alevel::devel,s.str());
}
if (ec) {
m_elog.write(log::elevel::rerror,"consume error: "+ec.message());
if (consume_ec) {
m_elog.write(log::elevel::rerror,"consume error: "+consume_ec.message());

if (config::drop_on_protocol_error) {
this->terminate(ec);
this->terminate(consume_ec);
return;
} else {
lib::error_code close_ec;
Expand Down Expand Up @@ -1354,7 +1354,7 @@ void connection<config>::handle_send_http_request(const lib::error_code& ec) {
}

template <typename config>
void connection<config>::handle_read_http_response(const lib::error_code& ec,
void connection<config>::handle_read_http_response(lib::error_code const & ec,
size_t bytes_transferred)
{
m_alog.write(log::alevel::devel,"handle_read_http_response");
Expand Down Expand Up @@ -1389,16 +1389,16 @@ void connection<config>::handle_read_http_response(const lib::error_code& ec,
m_handshake_timer.reset();
}

lib::error_code ec = m_processor->validate_server_handshake_response(
lib::error_code validate_ec = m_processor->validate_server_handshake_response(
m_request,
m_response
);
if (ec) {
if (validate_ec) {
m_elog.write(log::elevel::rerror,
std::string("Server handshake response was invalid: ")+
ec.message()
validate_ec.message()
);
this->terminate(ec);
this->terminate(validate_ec);
return;
}

Expand Down Expand Up @@ -1714,8 +1714,7 @@ const std::vector<int>& connection<config>::get_supported_versions() const
}

template <typename config>
void connection<config>::process_control_frame(typename
config::message_type::ptr msg)
void connection<config>::process_control_frame(typename config::message_type::ptr msg)
{
m_alog.write(log::alevel::devel,"process_control_frame");

Expand Down Expand Up @@ -1762,7 +1761,7 @@ void connection<config>::process_control_frame(typename

m_remote_close_code = close::extract_code(msg->get_payload(),ec);
if (ec) {
std::stringstream s;
s.str("");
if (config::drop_on_protocol_error) {
s << "Received invalid close code " << m_remote_close_code
<< " dropping connection per config.";
Expand Down Expand Up @@ -1802,7 +1801,7 @@ void connection<config>::process_control_frame(typename
}

if (m_state == session::state::open) {
std::stringstream s;
s.str("");
s << "Received close frame with code " << m_remote_close_code
<< " and reason " << m_remote_close_reason;
m_alog.write(log::alevel::devel,s.str());
Expand Down

0 comments on commit bb21e3c

Please sign in to comment.