summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTaybin Rutkin <taybin@taybin.com>2007-03-13 14:57:02 +0000
committerTaybin Rutkin <taybin@taybin.com>2007-03-13 14:57:02 +0000
commit3f4232c64686ea8e10517c4c28a9badd86e59484 (patch)
treef170d97abfecfbefda8127dde88a033446fbf9e5
parentc1a5269c55be92f5b571ce3bb6a0040b54bb0257 (diff)
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
-rw-r--r--libs/surfaces/mackie/surface_port.cc25
1 files changed, 18 insertions, 7 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 <sstream>
#include <cstring>
#include <cerrno>
+
using namespace std;
using namespace Mackie;
@@ -84,11 +87,15 @@ MidiByteArray SurfacePort::read()
{
if ( errno != EAGAIN )
{
+ ostringstream os;
+ os << "Surface: error reading from port: " << port().name() << ": " << errno;
+
char buf[512];
- char * msg = strerror_r( errno, buf, 512 );
+ int result = strerror_r( errno, buf, 512 );
+ if (!result) {
+ os << " " << buf;
+ }
- ostringstream os;
- os << "Surface: error reading from port: " << port().name() << ": " << errno << " " << msg;
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() );