Restore asserts and error handling
A couple of them got improved out of existence.
This commit is contained in:
@@ -298,8 +298,9 @@ void NotificationEngine::apply( Framebuffer &fb ) const
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case -1: /* unprintable character */
|
case -1: /* unprintable character */
|
||||||
default: /* Bogus width, ignore. */
|
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
assert( !"unexpected character width from wcwidth()" );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -335,7 +335,8 @@ bool Connection::try_bind( const char *addr, int port_low, int port_high )
|
|||||||
if ( bind( sock(), &local_addr.sa, local_addr_len ) == 0 ) {
|
if ( bind( sock(), &local_addr.sa, local_addr_len ) == 0 ) {
|
||||||
set_MTU( local_addr.sa.sa_family );
|
set_MTU( local_addr.sa.sa_family );
|
||||||
return true;
|
return true;
|
||||||
} else if ( i == search_high ) { /* last port to search */
|
} // else fallthrough to below code, on last iteration.
|
||||||
|
}
|
||||||
int saved_errno = errno;
|
int saved_errno = errno;
|
||||||
socks.pop_back();
|
socks.pop_back();
|
||||||
char host[ NI_MAXHOST ], serv[ NI_MAXSERV ];
|
char host[ NI_MAXHOST ], serv[ NI_MAXSERV ];
|
||||||
@@ -348,10 +349,6 @@ bool Connection::try_bind( const char *addr, int port_low, int port_high )
|
|||||||
fprintf( stderr, "Failed binding to %s:%s\n",
|
fprintf( stderr, "Failed binding to %s:%s\n",
|
||||||
host, serv );
|
host, serv );
|
||||||
throw NetworkException( "bind", saved_errno );
|
throw NetworkException( "bind", saved_errno );
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Connection::Connection( const char *key_str, const char *ip, const char *port ) /* client */
|
Connection::Connection( const char *key_str, const char *ip, const char *port ) /* client */
|
||||||
@@ -456,7 +453,7 @@ string Connection::recv( void )
|
|||||||
prune_sockets();
|
prune_sockets();
|
||||||
return payload;
|
return payload;
|
||||||
}
|
}
|
||||||
return "";
|
throw NetworkException( "No packet received" );
|
||||||
}
|
}
|
||||||
|
|
||||||
string Connection::recv_one( int sock_to_recv, bool nonblocking )
|
string Connection::recv_one( int sock_to_recv, bool nonblocking )
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ string UserStream::diff_from( const UserStream &existing ) const
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
assert( !"unexpected event type" );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,6 +131,7 @@ const Parser::Action &UserStream::get_action( unsigned int i ) const
|
|||||||
case ResizeType:
|
case ResizeType:
|
||||||
return actions[ i ].resize;
|
return actions[ i ].resize;
|
||||||
default:
|
default:
|
||||||
|
assert( !"unexpected action type" );
|
||||||
static const Parser::Ignore nothing = Parser::Ignore();
|
static const Parser::Ignore nothing = Parser::Ignore();
|
||||||
return nothing;
|
return nothing;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,7 +85,7 @@ namespace Network {
|
|||||||
/* interface for Network::Transport */
|
/* interface for Network::Transport */
|
||||||
void subtract( const UserStream *prefix );
|
void subtract( const UserStream *prefix );
|
||||||
string diff_from( const UserStream &existing ) const;
|
string diff_from( const UserStream &existing ) const;
|
||||||
string init_diff( void ) const { return string(); };
|
string init_diff( void ) const { return diff_from( UserStream() ); };
|
||||||
void apply_string( const string &diff );
|
void apply_string( const string &diff );
|
||||||
bool operator==( const UserStream &x ) const { return actions == x.actions; }
|
bool operator==( const UserStream &x ) const { return actions == x.actions; }
|
||||||
|
|
||||||
|
|||||||
@@ -140,7 +140,9 @@ void Emulator::print( const Parser::Print *act )
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case -1: /* unprintable character */
|
case -1: /* unprintable character */
|
||||||
default: /* bogus width, ignore */
|
break;
|
||||||
|
default:
|
||||||
|
assert( !"unexpected character width from wcwidth()" );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,6 +46,9 @@ string UserInput::input( const Parser::UserByte *act,
|
|||||||
/* We need to look ahead one byte in the SS3 state to see if
|
/* We need to look ahead one byte in the SS3 state to see if
|
||||||
the next byte will be A, B, C, or D (cursor control keys). */
|
the next byte will be A, B, C, or D (cursor control keys). */
|
||||||
|
|
||||||
|
/* This doesn't handle the 8-bit SS3 C1 control, which would be
|
||||||
|
two octets in UTF-8. Fortunately nobody seems to send this. */
|
||||||
|
|
||||||
switch ( state ) {
|
switch ( state ) {
|
||||||
case Ground:
|
case Ground:
|
||||||
if ( act->c == 0x1b ) { /* ESC */
|
if ( act->c == 0x1b ) { /* ESC */
|
||||||
@@ -74,8 +77,8 @@ string UserInput::input( const Parser::UserByte *act,
|
|||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
/* This doesn't handle the 8-bit SS3 C1 control, which would be
|
assert( !"unexpected state" );
|
||||||
two octets in UTF-8. Fortunately nobody seems to send this. */
|
state = Ground;
|
||||||
return string();
|
return string();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user