Fix asserts with side-effects (per Keegan McAllister)

This commit is contained in:
Keith Winstein
2012-03-08 10:50:19 -05:00
parent 4a29ab9d70
commit df5d163f9c
15 changed files with 80 additions and 35 deletions
+1 -1
View File
@@ -27,5 +27,5 @@ else
endif
ntester_SOURCES = ntester.cc
ntester_CPPFLAGS = -I$(srcdir)/../statesync -I$(srcdir)/../terminal -I$(srcdir)/../network -I$(srcdir)/../crypto -I../protobufs $(BOOST_CPPFLAGS)
ntester_CPPFLAGS = -I$(srcdir)/../util -I$(srcdir)/../statesync -I$(srcdir)/../terminal -I$(srcdir)/../network -I$(srcdir)/../crypto -I../protobufs $(BOOST_CPPFLAGS)
ntester_LDADD = ../statesync/libmoshstatesync.a ../terminal/libmoshterminal.a ../network/libmoshnetwork.a ../crypto/libmoshcrypto.a ../protobufs/libmoshprotos.a -lutil -lm $(BOOST_LDFLAGS) $(protobuf_LIBS)
+2 -1
View File
@@ -21,6 +21,7 @@
#include <poll.h>
#include "user.h"
#include "fatal_assert.h"
#include "networktransport.cc"
using namespace Network;
@@ -117,7 +118,7 @@ int main( int argc, char *argv[] )
if ( fds[ 0 ].revents & POLLIN ) {
char x;
assert( read( STDIN_FILENO, &x, 1 ) == 1 );
fatal_assert( read( STDIN_FILENO, &x, 1 ) == 1 );
n->get_current_state().push_back( Parser::UserByte( x ) );
}
+3 -2
View File
@@ -49,6 +49,7 @@
#include "parser.h"
#include "completeterminal.h"
#include "swrite.h"
#include "fatal_assert.h"
extern "C" {
#include "selfpipe.h"
@@ -202,7 +203,7 @@ void emulate_terminal( int fd )
return;
}
assert( selfpipe_trap(SIGWINCH) == 0 );
fatal_assert( selfpipe_trap(SIGWINCH) == 0 );
/* get current window size */
struct winsize window_size;
@@ -287,7 +288,7 @@ void emulate_terminal( int fd )
}
} else if ( pollfds[ 2 ].revents & POLLIN ) {
/* resize */
assert( selfpipe_read() == SIGWINCH );
fatal_assert( selfpipe_read() == SIGWINCH );
/* get new size */
if ( ioctl( STDIN_FILENO, TIOCGWINSZ, &window_size ) < 0 ) {