From 843d5656bd63cb651945139fe1a758398ec5e7d0 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Tue, 3 Sep 2013 10:45:33 -0700 Subject: [PATCH] Fix for compile warnings on Linux: check return values on read/write. --- interface/src/SerialInterface.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/interface/src/SerialInterface.cpp b/interface/src/SerialInterface.cpp index d9c1bd928f..4082bc87ef 100644 --- a/interface/src/SerialInterface.cpp +++ b/interface/src/SerialInterface.cpp @@ -125,9 +125,15 @@ void SerialInterface::initializePort(char* portname) { tcflush(_serialDescriptor, TCIOFLUSH); // this disables streaming so there's no garbage data on reads - write(_serialDescriptor, "SD\n", 3); + if (write(_serialDescriptor, "SD\n", 3) != 3) { + qDebug("Failed.\n"); + return; + } char result[4]; - read(_serialDescriptor, result, 4); + if (read(_serialDescriptor, result, 4) != 4) { + qDebug("Failed.\n"); + return; + } tty_set_file_descriptor(_serialDescriptor); mpu_init(0);