diff options
author | Massimo Gengarelli <gengarel@cs.unibo.it> | 2012-04-19 21:33:11 +0200 |
---|---|---|
committer | Keith Winstein <keithw@mit.edu> | 2012-04-29 02:24:31 -0400 |
commit | 49fc21c8a3537d661ee3607777b532e3ce5103b9 (patch) | |
tree | 93de0a1909abb9cfb374dfce17232c73acf7f7be | |
parent | fb6d07e566c8d4769507e1cdbea61e9a888f0fcd (diff) |
Catch by const reference (remove Eclipse warnings)
(closes #245)
-rw-r--r-- | src/frontend/mosh-client.cc | 6 | ||||
-rw-r--r-- | src/frontend/mosh-server.cc | 12 | ||||
-rw-r--r-- | src/network/network.cc | 4 | ||||
-rw-r--r-- | src/tests/encrypt-decrypt.cc | 4 |
4 files changed, 13 insertions, 13 deletions
diff --git a/src/frontend/mosh-client.cc b/src/frontend/mosh-client.cc index 2c1709c..fa5114b 100644 --- a/src/frontend/mosh-client.cc +++ b/src/frontend/mosh-client.cc @@ -124,13 +124,13 @@ int main( int argc, char *argv[] ) } client.shutdown(); - } catch ( Network::NetworkException e ) { + } catch ( const Network::NetworkException& e ) { fprintf( stderr, "Network exception: %s: %s\r\n", e.function.c_str(), strerror( e.the_errno ) ); - } catch ( Crypto::CryptoException e ) { + } catch ( const Crypto::CryptoException& e ) { fprintf( stderr, "Crypto exception: %s\r\n", e.text.c_str() ); - } catch ( std::string s ) { + } catch ( const std::string& s ) { fprintf( stderr, "Error: %s\r\n", s.c_str() ); } diff --git a/src/frontend/mosh-server.cc b/src/frontend/mosh-server.cc index 200535e..6e35eb8 100644 --- a/src/frontend/mosh-server.cc +++ b/src/frontend/mosh-server.cc @@ -277,11 +277,11 @@ int main( int argc, char *argv[] ) try { return run_server( desired_ip, desired_port, command_path, command_argv, colors, verbose, with_motd ); - } catch ( Network::NetworkException e ) { + } catch ( const Network::NetworkException& e ) { fprintf( stderr, "Network exception: %s: %s\n", e.function.c_str(), strerror( e.the_errno ) ); return 1; - } catch ( Crypto::CryptoException e ) { + } catch ( const Crypto::CryptoException& e ) { fprintf( stderr, "Crypto exception: %s\n", e.text.c_str() ); return 1; @@ -436,10 +436,10 @@ int run_server( const char *desired_ip, const char *desired_port, try { serve( master, terminal, *network ); - } catch ( Network::NetworkException e ) { + } catch ( const Network::NetworkException& e ) { fprintf( stderr, "Network exception: %s: %s\n", e.function.c_str(), strerror( e.the_errno ) ); - } catch ( Crypto::CryptoException e ) { + } catch ( const Crypto::CryptoException& e ) { fprintf( stderr, "Crypto exception: %s\n", e.text.c_str() ); } @@ -689,10 +689,10 @@ void serve( int host_fd, Terminal::Complete &terminal, ServerConnection &network } network.tick(); - } catch ( Network::NetworkException e ) { + } catch ( const Network::NetworkException& e ) { fprintf( stderr, "%s: %s\n", e.function.c_str(), strerror( e.the_errno ) ); spin(); - } catch ( Crypto::CryptoException e ) { + } catch ( const Crypto::CryptoException& e ) { if ( e.fatal ) { throw; } else { diff --git a/src/network/network.cc b/src/network/network.cc index 7dfe225..095b188 100644 --- a/src/network/network.cc +++ b/src/network/network.cc @@ -172,7 +172,7 @@ Connection::Connection( const char *desired_ip, const char *desired_port ) /* se if ( desired_ip_addr != INADDR_ANY ) { try { if ( try_bind( sock, desired_ip_addr, desired_port_no ) ) { return; } - } catch ( NetworkException e ) { + } catch ( const NetworkException& e ) { struct in_addr sin_addr; sin_addr.s_addr = desired_ip_addr; fprintf( stderr, "Error binding to IP %s: %s: %s\n", @@ -184,7 +184,7 @@ Connection::Connection( const char *desired_ip, const char *desired_port ) /* se /* now try any local interface */ try { if ( try_bind( sock, INADDR_ANY, desired_port_no ) ) { return; } - } catch ( NetworkException e ) { + } catch ( const NetworkException& e ) { fprintf( stderr, "Error binding to any interface: %s: %s\n", e.function.c_str(), strerror( e.the_errno ) ); throw; /* this time it's fatal */ diff --git a/src/tests/encrypt-decrypt.cc b/src/tests/encrypt-decrypt.cc index 6a74e38..c88bdfb 100644 --- a/src/tests/encrypt-decrypt.cc +++ b/src/tests/encrypt-decrypt.cc @@ -58,7 +58,7 @@ void test_bad_decrypt( Session &decryption_session ) { bool got_exn = false; try { decryption_session.decrypt( bad_ct ); - } catch ( CryptoException e ) { + } catch ( const CryptoException& e ) { got_exn = true; /* The "bad decrypt" exception needs to be non-fatal, otherwise we are @@ -128,7 +128,7 @@ int main( int argc, char *argv[] ) { for ( size_t i=0; i<NUM_SESSIONS; i++ ) { try { test_one_session(); - } catch ( CryptoException e ) { + } catch ( const CryptoException& e ) { fprintf( stderr, "Crypto exception: %s\r\n", e.text.c_str() ); fatal_assert( false ); |