From 3f4232c64686ea8e10517c4c28a9badd86e59484 Mon Sep 17 00:00:00 2001 From: Taybin Rutkin Date: Tue, 13 Mar 2007 14:57:02 +0000 Subject: [PATCH] Fixed error handling to use XSI strerror_r(), not the GNU version. git-svn-id: svn://localhost/ardour2/trunk@1582 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/surfaces/mackie/surface_port.cc | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/libs/surfaces/mackie/surface_port.cc b/libs/surfaces/mackie/surface_port.cc index 08ed1a75a7..8f55754f49 100644 --- a/libs/surfaces/mackie/surface_port.cc +++ b/libs/surfaces/mackie/surface_port.cc @@ -27,10 +27,13 @@ #include "i18n.h" +#define _XOPEN_SOURCE 600 // force XSI for non-GNU strerror_r() + #include #include #include + using namespace std; using namespace Mackie; @@ -84,11 +87,15 @@ MidiByteArray SurfacePort::read() { if ( errno != EAGAIN ) { - char buf[512]; - char * msg = strerror_r( errno, buf, 512 ); - ostringstream os; - os << "Surface: error reading from port: " << port().name() << ": " << errno << " " << msg; + os << "Surface: error reading from port: " << port().name() << ": " << errno; + + char buf[512]; + int result = strerror_r( errno, buf, 512 ); + if (!result) { + os << " " << buf; + } + cout << os.str() << endl; inactive_event(); throw MackieControlException( os.str() ); @@ -114,11 +121,15 @@ void SurfacePort::write( const MidiByteArray & mba ) { if ( errno != EAGAIN ) { - char buf[512]; - char * msg = strerror_r( errno, buf, 512 ); - ostringstream os; - os << "Surface: couldn't write to port " << port().name() << ": " << errno << " " << msg; + os << "Surface: couldn't write to port " << port().name() << ": " << errno; + char buf[512]; + int result = strerror_r( errno, buf, 512 ); + + if (!result) { + os << " " << buf; + } + cout << os.str(); inactive_event(); throw MackieControlException( os.str() );