diff --git a/src/frontend/terminaloverlay.cc b/src/frontend/terminaloverlay.cc index 4da5846..4a3dbe5 100644 --- a/src/frontend/terminaloverlay.cc +++ b/src/frontend/terminaloverlay.cc @@ -298,8 +298,9 @@ void NotificationEngine::apply( Framebuffer &fb ) const } break; case -1: /* unprintable character */ - default: /* Bogus width, ignore. */ break; + default: + assert( !"unexpected character width from wcwidth()" ); } } } diff --git a/src/network/network.cc b/src/network/network.cc index 7b1d8fa..922bde7 100644 --- a/src/network/network.cc +++ b/src/network/network.cc @@ -335,23 +335,20 @@ bool Connection::try_bind( const char *addr, int port_low, int port_high ) if ( bind( sock(), &local_addr.sa, local_addr_len ) == 0 ) { set_MTU( local_addr.sa.sa_family ); return true; - } else if ( i == search_high ) { /* last port to search */ - int saved_errno = errno; - socks.pop_back(); - char host[ NI_MAXHOST ], serv[ NI_MAXSERV ]; - int errcode = getnameinfo( &local_addr.sa, local_addr_len, - host, sizeof( host ), serv, sizeof( serv ), - NI_DGRAM | NI_NUMERICHOST | NI_NUMERICSERV ); - if ( errcode != 0 ) { - throw NetworkException( std::string( "bind: getnameinfo: " ) + gai_strerror( errcode ), 0 ); - } - fprintf( stderr, "Failed binding to %s:%s\n", - host, serv ); - throw NetworkException( "bind", saved_errno ); - } + } // else fallthrough to below code, on last iteration. } - - return false; + int saved_errno = errno; + socks.pop_back(); + char host[ NI_MAXHOST ], serv[ NI_MAXSERV ]; + int errcode = getnameinfo( &local_addr.sa, local_addr_len, + host, sizeof( host ), serv, sizeof( serv ), + NI_DGRAM | NI_NUMERICHOST | NI_NUMERICSERV ); + if ( errcode != 0 ) { + throw NetworkException( std::string( "bind: getnameinfo: " ) + gai_strerror( errcode ), 0 ); + } + fprintf( stderr, "Failed binding to %s:%s\n", + host, serv ); + throw NetworkException( "bind", saved_errno ); } Connection::Connection( const char *key_str, const char *ip, const char *port ) /* client */ @@ -456,7 +453,7 @@ string Connection::recv( void ) prune_sockets(); return payload; } - return ""; + throw NetworkException( "No packet received" ); } string Connection::recv_one( int sock_to_recv, bool nonblocking ) diff --git a/src/statesync/user.cc b/src/statesync/user.cc index 93f61b3..9ea29c1 100644 --- a/src/statesync/user.cc +++ b/src/statesync/user.cc @@ -95,6 +95,7 @@ string UserStream::diff_from( const UserStream &existing ) const } break; default: + assert( !"unexpected event type" ); break; } @@ -130,6 +131,7 @@ const Parser::Action &UserStream::get_action( unsigned int i ) const case ResizeType: return actions[ i ].resize; default: + assert( !"unexpected action type" ); static const Parser::Ignore nothing = Parser::Ignore(); return nothing; } diff --git a/src/statesync/user.h b/src/statesync/user.h index e9e21e0..fbf2728 100644 --- a/src/statesync/user.h +++ b/src/statesync/user.h @@ -85,7 +85,7 @@ namespace Network { /* interface for Network::Transport */ void subtract( const UserStream *prefix ); 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 ); bool operator==( const UserStream &x ) const { return actions == x.actions; } diff --git a/src/terminal/terminal.cc b/src/terminal/terminal.cc index 91fa9f6..057b3d0 100644 --- a/src/terminal/terminal.cc +++ b/src/terminal/terminal.cc @@ -140,7 +140,9 @@ void Emulator::print( const Parser::Print *act ) } break; case -1: /* unprintable character */ - default: /* bogus width, ignore */ + break; + default: + assert( !"unexpected character width from wcwidth()" ); break; } } diff --git a/src/terminal/terminaluserinput.cc b/src/terminal/terminaluserinput.cc index 3f3142f..4161334 100644 --- a/src/terminal/terminaluserinput.cc +++ b/src/terminal/terminaluserinput.cc @@ -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 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 ) { case Ground: if ( act->c == 0x1b ) { /* ESC */ @@ -74,8 +77,8 @@ string UserInput::input( const Parser::UserByte *act, } default: - /* This doesn't handle the 8-bit SS3 C1 control, which would be - two octets in UTF-8. Fortunately nobody seems to send this. */ + assert( !"unexpected state" ); + state = Ground; return string(); } }