Catch exceptions by reference
Found by cppcheck. Signed-off-by: Anders Kaseorg <andersk@mit.edu>
This commit is contained in:
committed by
Keith Winstein
parent
5365d6b21d
commit
e2abb8524f
@@ -61,7 +61,7 @@ int main( int argc, char *argv[] )
|
|||||||
fprintf( stderr, "Nonce = %ld\n",
|
fprintf( stderr, "Nonce = %ld\n",
|
||||||
(long)message.nonce.val() );
|
(long)message.nonce.val() );
|
||||||
cout << message.text;
|
cout << message.text;
|
||||||
} catch ( CryptoException e ) {
|
} catch ( const CryptoException &e ) {
|
||||||
cerr << e.text << endl;
|
cerr << e.text << endl;
|
||||||
exit( 1 );
|
exit( 1 );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ int main( int argc, char *argv[] )
|
|||||||
cerr << "Key: " << key.printable_key() << endl;
|
cerr << "Key: " << key.printable_key() << endl;
|
||||||
|
|
||||||
cout << ciphertext;
|
cout << ciphertext;
|
||||||
} catch ( CryptoException e ) {
|
} catch ( const CryptoException &e ) {
|
||||||
cerr << e.text << endl;
|
cerr << e.text << endl;
|
||||||
exit( 1 );
|
exit( 1 );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ int main( int argc, char *argv[] )
|
|||||||
} else {
|
} else {
|
||||||
n = new Transport<UserStream, UserStream>( me, remote, NULL, NULL );
|
n = new Transport<UserStream, UserStream>( me, remote, NULL, NULL );
|
||||||
}
|
}
|
||||||
} catch ( CryptoException e ) {
|
} catch ( const CryptoException &e ) {
|
||||||
fprintf( stderr, "Fatal error: %s\n", e.text.c_str() );
|
fprintf( stderr, "Fatal error: %s\n", e.text.c_str() );
|
||||||
exit( 1 );
|
exit( 1 );
|
||||||
}
|
}
|
||||||
@@ -97,7 +97,7 @@ int main( int argc, char *argv[] )
|
|||||||
last_num = n->get_remote_state_num();
|
last_num = n->get_remote_state_num();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch ( CryptoException e ) {
|
} catch ( const CryptoException &e ) {
|
||||||
fprintf( stderr, "Cryptographic error: %s\n", e.text.c_str() );
|
fprintf( stderr, "Cryptographic error: %s\n", e.text.c_str() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -163,10 +163,10 @@ int main( int argc, char *argv[] )
|
|||||||
if ( network_ready_to_read ) {
|
if ( network_ready_to_read ) {
|
||||||
n->recv();
|
n->recv();
|
||||||
}
|
}
|
||||||
} catch ( NetworkException e ) {
|
} catch ( const NetworkException &e ) {
|
||||||
fprintf( stderr, "%s: %s\r\n", e.function.c_str(), strerror( e.the_errno ) );
|
fprintf( stderr, "%s: %s\r\n", e.function.c_str(), strerror( e.the_errno ) );
|
||||||
break;
|
break;
|
||||||
} catch ( CryptoException e ) {
|
} catch ( const CryptoException &e ) {
|
||||||
fprintf( stderr, "Cryptographic error: %s\n", e.text.c_str() );
|
fprintf( stderr, "Cryptographic error: %s\n", e.text.c_str() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -175,10 +175,10 @@ int main( int argc, char *argv[] )
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
client.main();
|
client.main();
|
||||||
} catch ( Network::NetworkException e ) {
|
} catch ( const Network::NetworkException &e ) {
|
||||||
fprintf( stderr, "Network exception: %s: %s\r\n",
|
fprintf( stderr, "Network exception: %s: %s\r\n",
|
||||||
e.function.c_str(), strerror( e.the_errno ) );
|
e.function.c_str(), strerror( e.the_errno ) );
|
||||||
} catch ( Crypto::CryptoException e ) {
|
} catch ( const Crypto::CryptoException &e ) {
|
||||||
fprintf( stderr, "Crypto exception: %s\r\n",
|
fprintf( stderr, "Crypto exception: %s\r\n",
|
||||||
e.text.c_str() );
|
e.text.c_str() );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -485,7 +485,7 @@ void STMClient::main( void )
|
|||||||
} else {
|
} else {
|
||||||
overlays.get_notification_engine().clear_network_exception();
|
overlays.get_notification_engine().clear_network_exception();
|
||||||
}
|
}
|
||||||
} catch ( Network::NetworkException e ) {
|
} catch ( const Network::NetworkException &e ) {
|
||||||
if ( !network->shutdown_in_progress() ) {
|
if ( !network->shutdown_in_progress() ) {
|
||||||
overlays.get_notification_engine().set_network_exception( e );
|
overlays.get_notification_engine().set_network_exception( e );
|
||||||
}
|
}
|
||||||
@@ -495,7 +495,7 @@ void STMClient::main( void )
|
|||||||
req.tv_nsec = 200000000; /* 0.2 sec */
|
req.tv_nsec = 200000000; /* 0.2 sec */
|
||||||
nanosleep( &req, NULL );
|
nanosleep( &req, NULL );
|
||||||
freeze_timestamp();
|
freeze_timestamp();
|
||||||
} catch ( Crypto::CryptoException e ) {
|
} catch ( const Crypto::CryptoException &e ) {
|
||||||
if ( e.fatal ) {
|
if ( e.fatal ) {
|
||||||
throw;
|
throw;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user