Skip to content

Commit

Permalink
exit with failure
Browse files Browse the repository at this point in the history
  • Loading branch information
mkazhdan committed Oct 31, 2023
1 parent aff7459 commit d4e8715
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 22 deletions.
2 changes: 1 addition & 1 deletion Src/Array.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions Src/MyMiscellany.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -324,7 +324,7 @@ inline void SignalHandler( int signal )
{
printf( "Signal: %d\n" , signal );
StackTracer::Trace();
exit( 0 );
exit( EXIT_FAILURE );
};


Expand Down
12 changes: 2 additions & 10 deletions Src/Socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 3 additions & 9 deletions Src/Socket.inl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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<class C>
Expand All @@ -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 )
Expand Down

0 comments on commit d4e8715

Please sign in to comment.