From d4e87157cf9b2152cd6a46886c8d36bda4acba85 Mon Sep 17 00:00:00 2001 From: mkazhdan Date: Tue, 31 Oct 2023 10:44:21 -0400 Subject: [PATCH] exit with failure --- Src/Array.h | 2 +- Src/MyMiscellany.h | 4 ++-- Src/Socket.h | 12 ++---------- Src/Socket.inl | 12 +++--------- 4 files changed, 8 insertions(+), 22 deletions(-) diff --git a/Src/Array.h b/Src/Array.h index 95d71c4e..6a0cca50 100644 --- a/Src/Array.h +++ b/Src/Array.h @@ -37,7 +37,7 @@ DAMAGE. #ifdef _WIN32 #define ASSERT( x ) { if( !( x ) ) _asm{ int 0x03 } } #else // !_WIN32 -#define ASSERT( x ) { if( !( x ) ) exit(0); } +#define ASSERT( x ) { if( !( x ) ) exit( EXIT_FAILURE ); } #endif // _WIN32 #endif // _WIN64 diff --git a/Src/MyMiscellany.h b/Src/MyMiscellany.h index 17170104..0b83fa97 100644 --- a/Src/MyMiscellany.h +++ b/Src/MyMiscellany.h @@ -195,7 +195,7 @@ namespace MKExceptions void ErrorOut( const char *fileName , int line , const char *functionName , const char *format , Args ... args ) { std::cerr << MakeMessageString( "[ERROR]" , fileName , line , functionName , format , args ... ) << std::endl; - exit( 0 ); + exit( EXIT_FAILURE ); } } #ifndef WARN @@ -324,7 +324,7 @@ inline void SignalHandler( int signal ) { printf( "Signal: %d\n" , signal ); StackTracer::Trace(); - exit( 0 ); + exit( EXIT_FAILURE ); }; diff --git a/Src/Socket.h b/Src/Socket.h index 481297ee..0b25b671 100644 --- a/Src/Socket.h +++ b/Src/Socket.h @@ -88,22 +88,14 @@ template< class C > int socket_receive( Socket& s , Array< C > destination , size_t len ) { if( len>destination.maximum()*sizeof( C ) ) - { - fprintf( stderr , "Size of socket_receive exceeds destination maximum: %zd > %zd\n" , len , destination.maximum()*sizeof( C ) ); - ASSERT( 0 ); - exit( 0 ); - } + ERROR_OUT( "Size of socket_receive exceeds destination maximum: " , len , " > " , destination.maximum()*sizeof( C ) ); return socket_receive( s , (char*)&destination[0] , len ); } template< class C > int socket_send( Socket s , ConstArray< C > source , size_t len ) { if( len>source.maximum()*sizeof( C ) ) - { - fprintf( stderr , "Size of socket_send exceeds source maximum: %zd > %zd\n" , len , source.maximum()*sizeof( C ) ); - ASSERT( 0 ); - exit( 0 ); - } + ERROR_OUT( "Size of socket_send exceeds source maximum: " , len , " > " , source.maximum()*sizeof( C ) ); return socket_send( s , (char*)&source[0] , len ); } #endif // ARRAY_DEBUG diff --git a/Src/Socket.inl b/Src/Socket.inl index aee55835..09c17c58 100644 --- a/Src/Socket.inl +++ b/Src/Socket.inl @@ -86,7 +86,7 @@ void ReceiveOnSocket( Socket& s , Pointer( C ) data , size_t dataSize , const ch va_end( args ); fprintf( stderr , "\n" ); } - exit(0); + exit( EXIT_FAILURE ); } rec+=tmp; } @@ -99,10 +99,7 @@ void SendOnSocket( Socket& s , ConstPointer( C ) data , size_t dataSize , const if( dataSize>data.maximum()*sizeof( C ) ) ERROR_OUT( "Size of socket write exceeds source maximum: " , dataSize , " > " , data.maximum()*sizeof( C ) ); #endif // ARRAY_DEBUG if( socket_send( s , ( ConstPointer( char ) )data , dataSize )<0 ) - { - fprintf( stderr , "socket_send to client failed: %s\n" , LastSocketError()); - exit(0); - } + ERROR_OUT( "socket_send to client failed: " , LastSocketError() ); } template @@ -112,10 +109,7 @@ void SendOnSocket( Socket& s , Pointer( C ) data , size_t dataSize , const char* if( dataSize>data.maximum()*sizeof( C ) ) ERROR_OUT( "Size of socket write exceeds source maximum: " , dataSize , " > " , data.maximum()*sizeof( C ) ); #endif // ARRAY_DEBUG if( socket_send( s , ( ConstPointer( char ) )data , dataSize )<0 ) - { - fprintf( stderr , "socket_send to client failed: %s\n" , LastSocketError()); - exit(0); - } + ERROR_OUT( "socket_send to client failed: " , LastSocketError() ); } inline bool GetHostEndpointAddress( EndpointAddress* address , const char* prefix )