Fixed compiler warnings in libexecstream

This commit is contained in:
Ray Speth 2012-03-15 19:55:07 +00:00
parent d27066d7bd
commit 6ec589a9e5
6 changed files with 27 additions and 14 deletions

View file

@ -45,6 +45,13 @@ def prep_sundials(env):
return localenv
def prep_libexecstream(env):
localenv = env.Clone()
if '-Wall' in localenv['CCFLAGS']:
localenv['CCFLAGS'].append('-Wno-unused-result')
return localenv
def prep_gtest(env):
localenv = env.Clone()
localenv.Append(CPPPATH=[Dir('#ext/gtest'),
@ -53,7 +60,7 @@ def prep_gtest(env):
return localenv
# (subdir, (file extensions), prepfunction)
libs = [('libexecstream', ['cpp'], prep_default)]
libs = [('libexecstream', ['cpp'], prep_libexecstream)]
if env['build_with_f2c']:
libs.append(('f2c_math', ['cpp','c'], prep_f2c))

View file

@ -61,7 +61,7 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#endif
// helper classes
namespace {
namespace exec_stream_internal {
class buffer_list_t {
public:
@ -212,7 +212,7 @@ void buffer_list_t::clear()
// platform-dependent helpers
namespace {
namespace exec_stream_internal {
#include HELPERS_H
#include HELPERS_CPP
@ -220,7 +220,7 @@ namespace {
}
// stream buffer class
namespace {
namespace exec_stream_internal {
class exec_stream_buffer_t : public std::streambuf {
public:
@ -270,7 +270,7 @@ exec_stream_buffer_t::int_type exec_stream_buffer_t::underflow()
{
if( gptr()==egptr() ) {
std::size_t read_size=STREAM_BUFFER_SIZE;
bool no_more;
bool no_more = true;
m_thread_buffer.get( m_kind, m_stream_buffer, read_size, no_more );
if( no_more || read_size==0 ) { // there is no way for underflow to return something other than eof when 0 bytes are read
return traits_type::eof();
@ -312,11 +312,11 @@ exec_stream_buffer_t::int_type exec_stream_buffer_t::overflow( exec_stream_buffe
}
if( c!=traits_type::eof() ) {
if( pbase()==epptr() ) {
if( !send_char( c ) ) {
if( !send_char( static_cast<char>(c) ) ) {
return traits_type::eof();
}
}else {
sputc( c );
sputc( static_cast<char>(c) );
}
}
return traits_type::not_eof( c );
@ -411,7 +411,7 @@ void exec_stream_t::exceptions( bool enable )
}
// exec_stream_t::error_t
namespace {
namespace exec_stream_internal {
std::string int2str( unsigned long i, int base, std::size_t width )
{

View file

@ -27,6 +27,9 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
// exec_stream_t::impl_t
using namespace exec_stream_internal;
struct exec_stream_t::impl_t {
impl_t();
~impl_t();
@ -244,7 +247,7 @@ void exec_stream_t::impl_t::start( std::string const & program )
write( status_pipe.w(), msg, len );
_exit( -1 );
}catch( ... ) {
char * msg="exec_stream_t::start: unknown exception in child process";
const char * msg="exec_stream_t::start: unknown exception in child process";
std::size_t len=strlen( msg );
write( status_pipe.w(), &len, sizeof( len ) );
write( status_pipe.w(), msg, len );

View file

@ -357,7 +357,7 @@ void thread_buffer_t::set_read_buffer_size( std::size_t size )
if( m_direction!=dir_none ) {
throw exec_stream_t::error_t( "thread_buffer_t::set_read_buffer_size: thread already started" );
}
m_read_buffer_size=size;
m_read_buffer_size= static_cast<DWORD>(size);
}
void thread_buffer_t::start_reader_thread( HANDLE pipe )
@ -632,7 +632,7 @@ DWORD WINAPI thread_buffer_t::writer_thread( LPVOID param )
buffer_list_t::buffer_t buffer;
buffer.data=0;
buffer.size=0;
std::size_t buffer_offset=0;
DWORD buffer_offset=0;
while( true ) {
// wait for got_data or destruction, ignore timeout errors
@ -681,7 +681,8 @@ DWORD WINAPI thread_buffer_t::writer_thread( LPVOID param )
if( buffer.data!=0 ) {
// we have buffer - write it
DWORD written_size;
if( !WriteFile( p->m_pipe, buffer.data+buffer_offset, buffer.size-buffer_offset, &written_size, 0 ) ) {
DWORD bytes_to_write = static_cast<DWORD>(buffer.size) - buffer_offset;
if( !WriteFile( p->m_pipe, buffer.data+buffer_offset, bytes_to_write, &written_size, 0 ) ) {
p->note_thread_error( "thread_buffer_t::writer_thread: WriteFile failed", GetLastError(), "" );
break;
}

View file

@ -161,8 +161,8 @@ private:
char const * m_error_message; // so setting them anywhere in the thread is safe
DWORD m_wait_timeout; // parameters used in thread
std::size_t m_buffer_limit; // they are set before the thread is started,
std::size_t m_read_buffer_size; // so accessing them anywhere in the thread is safe
std::size_t m_buffer_limit; // they are set before the thread is started,
DWORD m_read_buffer_size; // so accessing them anywhere in the thread is safe
HANDLE m_thread;
event_t m_want_data; // for synchronisation between get and reader_thread

View file

@ -26,6 +26,8 @@ OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using namespace exec_stream_internal;
// exec_stream_t::impl_t
struct exec_stream_t::impl_t {
impl_t();