Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Catch by const reference (remove Eclipse warnings)

(closes #245)
  • Loading branch information...
commit 49fc21c8a3537d661ee3607777b532e3ce5103b9 1 parent fb6d07e
Massimo Gengarelli authored keithw committed
View
6 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() );
}
View
12 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 {
View
4 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 */
View
4 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 );
Please sign in to comment.
Something went wrong with that request. Please try again.