Skip to content

Commit

Permalink
fixup! clang-format Mosh
Browse files Browse the repository at this point in the history
  • Loading branch information
bbarenblat committed Aug 8, 2023
1 parent 990469a commit 886c540
Show file tree
Hide file tree
Showing 31 changed files with 109 additions and 375 deletions.
14 changes: 3 additions & 11 deletions src/crypto/crypto.cc
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,7 @@ uint64_t Crypto::unique( void )
return rv;
}

AlignedBuffer::AlignedBuffer( size_t len, const char* data )
: m_len( len )
, m_allocated( NULL )
, m_data( NULL )
AlignedBuffer::AlignedBuffer( size_t len, const char* data ) : m_len( len ), m_allocated( NULL ), m_data( NULL )
{
size_t alloc_len = len ? len : 1;
#if defined( HAVE_POSIX_MEMALIGN )
Expand Down Expand Up @@ -155,13 +152,8 @@ string Base64Key::printable_key( void ) const
}

Session::Session( Base64Key s_key )
: key( s_key )
, ctx_buf( ae_ctx_sizeof() )
, ctx( (ae_ctx*)ctx_buf.data() )
, blocks_encrypted( 0 )
, plaintext_buffer( RECEIVE_MTU )
, ciphertext_buffer( RECEIVE_MTU )
, nonce_buffer( Nonce::NONCE_LEN )
: key( s_key ), ctx_buf( ae_ctx_sizeof() ), ctx( (ae_ctx*)ctx_buf.data() ), blocks_encrypted( 0 ),
plaintext_buffer( RECEIVE_MTU ), ciphertext_buffer( RECEIVE_MTU ), nonce_buffer( Nonce::NONCE_LEN )
{
if ( AE_SUCCESS != ae_init( ctx, key.data(), 16, 12, 16 ) ) {
throw CryptoException( "Could not initialize AES-OCB context." );
Expand Down
12 changes: 3 additions & 9 deletions src/crypto/crypto.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ class CryptoException : public std::exception
public:
string text;
bool fatal;
CryptoException( string s_text, bool s_fatal = false )
: text( s_text )
, fatal( s_fatal ) {};
CryptoException( string s_text, bool s_fatal = false ) : text( s_text ), fatal( s_fatal ) {};
const char* what() const throw() { return text.c_str(); }
~CryptoException() throw() {}
};
Expand Down Expand Up @@ -125,14 +123,10 @@ class Message
const string text;

Message( const char* nonce_bytes, size_t nonce_len, const char* text_bytes, size_t text_len )
: nonce( nonce_bytes, nonce_len )
, text( text_bytes, text_len )
: nonce( nonce_bytes, nonce_len ), text( text_bytes, text_len )
{}

Message( const Nonce& s_nonce, const string& s_text )
: nonce( s_nonce )
, text( s_text )
{}
Message( const Nonce& s_nonce, const string& s_text ) : nonce( s_nonce ), text( s_text ) {}
};

class Session
Expand Down
4 changes: 1 addition & 3 deletions src/crypto/prng.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ class PRNG
PRNG& operator=( const PRNG& );

public:
PRNG()
: randfile( rdev, std::ifstream::in | std::ifstream::binary )
{}
PRNG() : randfile( rdev, std::ifstream::in | std::ifstream::binary ) {}

void fill( void* dest, size_t size )
{
Expand Down
29 changes: 6 additions & 23 deletions src/frontend/stmclient.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,29 +94,12 @@ class STMClient
const char* predict_mode,
unsigned int s_verbose,
const char* predict_overwrite )
: ip( s_ip ? s_ip : "" )
, port( s_port ? s_port : "" )
, key( s_key ? s_key : "" )
, escape_key( 0x1E )
, escape_pass_key( '^' )
, escape_pass_key2( '^' )
, escape_requires_lf( false )
, escape_key_help( L"?" )
, saved_termios()
, raw_termios()
, window_size()
, local_framebuffer( 1, 1 )
, new_state( 1, 1 )
, overlays()
, network()
, display( true )
, /* use TERM environment var to initialize display */
connecting_notification()
, repaint_requested( false )
, lf_entered( false )
, quit_sequence_started( false )
, clean_shutdown( false )
, verbose( s_verbose )
: ip( s_ip ? s_ip : "" ), port( s_port ? s_port : "" ), key( s_key ? s_key : "" ), escape_key( 0x1E ),
escape_pass_key( '^' ), escape_pass_key2( '^' ), escape_requires_lf( false ), escape_key_help( L"?" ),
saved_termios(), raw_termios(), window_size(), local_framebuffer( 1, 1 ), new_state( 1, 1 ), overlays(),
network(), display( true ), /* use TERM environment var to initialize display */
connecting_notification(), repaint_requested( false ), lf_entered( false ), quit_sequence_started( false ),
clean_shutdown( false ), verbose( s_verbose )
{
if ( predict_mode ) {
if ( !strcmp( predict_mode, "always" ) ) {
Expand Down
9 changes: 2 additions & 7 deletions src/frontend/terminaloverlay.cc
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,8 @@ void ConditionalCursorMove::apply( Framebuffer& fb, uint64_t confirmed_epoch ) c
}

NotificationEngine::NotificationEngine()
: last_word_from_server( timestamp() )
, last_acked_state( timestamp() )
, escape_key_string()
, message()
, message_is_network_error( false )
, message_expiration( -1 )
, show_quit_keystroke( true )
: last_word_from_server( timestamp() ), last_acked_state( timestamp() ), escape_key_string(), message(),
message_is_network_error( false ), message_expiration( -1 ), show_quit_keystroke( true )
{}

static std::string human_readable_duration( int num_seconds, const std::string& seconds_abbr )
Expand Down
52 changes: 11 additions & 41 deletions src/frontend/terminaloverlay.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,8 @@ class ConditionalOverlay
uint64_t prediction_time; /* used to find long-pending predictions */

ConditionalOverlay( uint64_t s_exp, int s_col, uint64_t s_tentative )
: expiration_frame( s_exp )
, col( s_col )
, active( false )
, tentative_until_epoch( s_tentative )
, prediction_time( uint64_t( -1 ) )
: expiration_frame( s_exp ), col( s_col ), active( false ), tentative_until_epoch( s_tentative ),
prediction_time( uint64_t( -1 ) )
{}

virtual ~ConditionalOverlay() {}
Expand Down Expand Up @@ -100,8 +97,7 @@ class ConditionalCursorMove : public ConditionalOverlay
Validity get_validity( const Framebuffer& fb, uint64_t early_ack, uint64_t late_ack ) const;

ConditionalCursorMove( uint64_t s_exp, int s_row, int s_col, uint64_t s_tentative )
: ConditionalOverlay( s_exp, s_col, s_tentative )
, row( s_row )
: ConditionalOverlay( s_exp, s_col, s_tentative ), row( s_row )
{}
};

Expand All @@ -118,10 +114,7 @@ class ConditionalOverlayCell : public ConditionalOverlay
Validity get_validity( const Framebuffer& fb, int row, uint64_t early_ack, uint64_t late_ack ) const;

ConditionalOverlayCell( uint64_t s_exp, int s_col, uint64_t s_tentative )
: ConditionalOverlay( s_exp, s_col, s_tentative )
, replacement( 0 )
, unknown( false )
, original_contents()
: ConditionalOverlay( s_exp, s_col, s_tentative ), replacement( 0 ), unknown( false ), original_contents()
{}

void reset( void )
Expand Down Expand Up @@ -152,10 +145,7 @@ class ConditionalOverlayRow

void apply( Framebuffer& fb, uint64_t confirmed_epoch, bool flag ) const;

ConditionalOverlayRow( int s_row_num )
: row_num( s_row_num )
, overlay_cells()
{}
ConditionalOverlayRow( int s_row_num ) : row_num( s_row_num ), overlay_cells() {}
};

/* the various overlays */
Expand Down Expand Up @@ -319,24 +309,10 @@ class PredictionEngine
int wait_time( void ) const { return ( timing_tests_necessary() && active() ) ? 50 : INT_MAX; }

PredictionEngine( void )
: last_byte( 0 )
, parser()
, overlays()
, cursors()
, local_frame_sent( 0 )
, local_frame_acked( 0 )
, local_frame_late_acked( 0 )
, prediction_epoch( 1 )
, confirmed_epoch( 0 )
, flagging( false )
, srtt_trigger( false )
, glitch_trigger( 0 )
, last_quick_confirmation( 0 )
, send_interval( 250 )
, last_height( 0 )
, last_width( 0 )
, display_preference( Adaptive )
, predict_overwrite( false )
: last_byte( 0 ), parser(), overlays(), cursors(), local_frame_sent( 0 ), local_frame_acked( 0 ),
local_frame_late_acked( 0 ), prediction_epoch( 1 ), confirmed_epoch( 0 ), flagging( false ),
srtt_trigger( false ), glitch_trigger( 0 ), last_quick_confirmation( 0 ), send_interval( 250 ),
last_height( 0 ), last_width( 0 ), display_preference( Adaptive ), predict_overwrite( false )
{}
};

Expand All @@ -347,9 +323,7 @@ class TitleEngine

public:
void apply( Framebuffer& fb ) const { fb.prefix_window_title( prefix ); }
TitleEngine()
: prefix()
{}
TitleEngine() : prefix() {}
void set_prefix( const wstring& s );
};

Expand All @@ -369,11 +343,7 @@ class OverlayManager

void set_title_prefix( const wstring& s ) { title.set_prefix( s ); }

OverlayManager()
: notifications()
, predictions()
, title()
{}
OverlayManager() : notifications(), predictions(), title() {}

int wait_time( void ) const { return std::min( notifications.wait_time(), predictions.wait_time() ); }
};
Expand Down
4 changes: 1 addition & 3 deletions src/network/compressor.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ class Compressor
unsigned char buffer[BUFFER_SIZE];

public:
Compressor()
: buffer()
{}
Compressor() : buffer() {}
~Compressor() {}

std::string compress_str( const std::string& input );
Expand Down
63 changes: 14 additions & 49 deletions src/network/network.cc
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,9 @@ const uint64_t SEQUENCE_MASK = uint64_t( -1 ) ^ DIRECTION_MASK;

/* Read in packet */
Packet::Packet( const Message& message )
: seq( message.nonce.val() & SEQUENCE_MASK )
, direction( ( message.nonce.val() & DIRECTION_MASK ) ? TO_CLIENT : TO_SERVER )
, timestamp( -1 )
, timestamp_reply( -1 )
, payload()
: seq( message.nonce.val() & SEQUENCE_MASK ),
direction( ( message.nonce.val() & DIRECTION_MASK ) ? TO_CLIENT : TO_SERVER ), timestamp( -1 ),
timestamp_reply( -1 ), payload()
{
dos_assert( message.text.size() >= 2 * sizeof( uint16_t ) );

Expand Down Expand Up @@ -148,8 +146,7 @@ void Connection::prune_sockets( void )
}
}

Connection::Socket::Socket( int family )
: _fd( socket( family, SOCK_DGRAM, 0 ) )
Connection::Socket::Socket( int family ) : _fd( socket( family, SOCK_DGRAM, 0 ) )
{
if ( _fd < 0 ) {
throw NetworkException( "socket", errno );
Expand Down Expand Up @@ -213,8 +210,7 @@ class AddrInfo
{
public:
struct addrinfo* res;
AddrInfo( const char* node, const char* service, const struct addrinfo* hints )
: res( NULL )
AddrInfo( const char* node, const char* service, const struct addrinfo* hints ) : res( NULL )
{
int errcode = getaddrinfo( node, service, hints, &res );
if ( errcode != 0 ) {
Expand All @@ -231,25 +227,10 @@ class AddrInfo
};

Connection::Connection( const char* desired_ip, const char* desired_port ) /* server */
: socks()
, has_remote_addr( false )
, remote_addr()
, remote_addr_len( 0 )
, server( true )
, MTU( DEFAULT_SEND_MTU )
, key()
, session( key )
, direction( TO_CLIENT )
, saved_timestamp( -1 )
, saved_timestamp_received_at( 0 )
, expected_receiver_seq( 0 )
, last_heard( -1 )
, last_port_choice( -1 )
, last_roundtrip_success( -1 )
, RTT_hit( false )
, SRTT( 1000 )
, RTTVAR( 500 )
, send_error()
: socks(), has_remote_addr( false ), remote_addr(), remote_addr_len( 0 ), server( true ), MTU( DEFAULT_SEND_MTU ),
key(), session( key ), direction( TO_CLIENT ), saved_timestamp( -1 ), saved_timestamp_received_at( 0 ),
expected_receiver_seq( 0 ), last_heard( -1 ), last_port_choice( -1 ), last_roundtrip_success( -1 ),
RTT_hit( false ), SRTT( 1000 ), RTTVAR( 500 ), send_error()
{
setup();

Expand Down Expand Up @@ -357,25 +338,10 @@ bool Connection::try_bind( const char* addr, int port_low, int port_high )
}

Connection::Connection( const char* key_str, const char* ip, const char* port ) /* client */
: socks()
, has_remote_addr( false )
, remote_addr()
, remote_addr_len( 0 )
, server( false )
, MTU( DEFAULT_SEND_MTU )
, key( key_str )
, session( key )
, direction( TO_SERVER )
, saved_timestamp( -1 )
, saved_timestamp_received_at( 0 )
, expected_receiver_seq( 0 )
, last_heard( -1 )
, last_port_choice( -1 )
, last_roundtrip_success( -1 )
, RTT_hit( false )
, SRTT( 1000 )
, RTTVAR( 500 )
, send_error()
: socks(), has_remote_addr( false ), remote_addr(), remote_addr_len( 0 ), server( false ),
MTU( DEFAULT_SEND_MTU ), key( key_str ), session( key ), direction( TO_SERVER ), saved_timestamp( -1 ),
saved_timestamp_received_at( 0 ), expected_receiver_seq( 0 ), last_heard( -1 ), last_port_choice( -1 ),
last_roundtrip_success( -1 ), RTT_hit( false ), SRTT( 1000 ), RTTVAR( 500 ), send_error()
{
setup();

Expand Down Expand Up @@ -638,8 +604,7 @@ Connection::Socket::~Socket()
fatal_assert( close( _fd ) == 0 );
}

Connection::Socket::Socket( const Socket& other )
: _fd( dup( other._fd ) )
Connection::Socket::Socket( const Socket& other ) : _fd( dup( other._fd ) )
{
if ( _fd < 0 ) {
throw NetworkException( "socket", errno );
Expand Down
11 changes: 3 additions & 8 deletions src/network/network.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ class NetworkException : public std::exception

public:
NetworkException( string s_function = "<none>", int s_errno = 0 )
: function( s_function )
, the_errno( s_errno )
, my_what( function + ": " + strerror( the_errno ) )
: function( s_function ), the_errno( s_errno ), my_what( function + ": " + strerror( the_errno ) )
{}
const char* what() const throw() { return my_what.c_str(); }
~NetworkException() throw() {}
Expand All @@ -89,11 +87,8 @@ class Packet
string payload;

Packet( Direction s_direction, uint16_t s_timestamp, uint16_t s_timestamp_reply, const string& s_payload )
: seq( Crypto::unique() )
, direction( s_direction )
, timestamp( s_timestamp )
, timestamp_reply( s_timestamp_reply )
, payload( s_payload )
: seq( Crypto::unique() ), direction( s_direction ), timestamp( s_timestamp ),
timestamp_reply( s_timestamp_reply ), payload( s_payload )
{}

Packet( const Message& message );
Expand Down
20 changes: 6 additions & 14 deletions src/network/networktransport-impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,9 @@ Transport<MyState, RemoteState>::Transport( MyState& initial_state,
RemoteState& initial_remote,
const char* desired_ip,
const char* desired_port )
: connection( desired_ip, desired_port )
, sender( &connection, initial_state )
, received_states( 1, TimestampedState<RemoteState>( timestamp(), 0, initial_remote ) )
, receiver_quench_timer( 0 )
, last_receiver_state( initial_remote )
, fragments()
, verbose( 0 )
: connection( desired_ip, desired_port ), sender( &connection, initial_state ),
received_states( 1, TimestampedState<RemoteState>( timestamp(), 0, initial_remote ) ),
receiver_quench_timer( 0 ), last_receiver_state( initial_remote ), fragments(), verbose( 0 )
{
/* server */
}
Expand All @@ -61,13 +57,9 @@ Transport<MyState, RemoteState>::Transport( MyState& initial_state,
const char* key_str,
const char* ip,
const char* port )
: connection( key_str, ip, port )
, sender( &connection, initial_state )
, received_states( 1, TimestampedState<RemoteState>( timestamp(), 0, initial_remote ) )
, receiver_quench_timer( 0 )
, last_receiver_state( initial_remote )
, fragments()
, verbose( 0 )
: connection( key_str, ip, port ), sender( &connection, initial_state ),
received_states( 1, TimestampedState<RemoteState>( timestamp(), 0, initial_remote ) ),
receiver_quench_timer( 0 ), last_receiver_state( initial_remote ), fragments(), verbose( 0 )
{
/* client */
}
Expand Down
Loading

0 comments on commit 886c540

Please sign in to comment.