From cdaa89e30e12d247a8086763d341e5f020151b67 Mon Sep 17 00:00:00 2001 From: Jonathan Liu Date: Mon, 9 Mar 2015 22:35:56 +1100 Subject: [PATCH] Unix: Clear serial_struct instances Silences the following Valgrind warning: Conditional jump or move depends on uninitialised value(s) Upstream-Status: Backport from 5.5 branch Change-Id: I8fd8cfd6aa6f75ed515e6151cfc282faca508bdc Reviewed-by: Denis Shienkov Signed-off-by: Jonathan Liu --- src/serialport/qserialport_unix.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/serialport/qserialport_unix.cpp b/src/serialport/qserialport_unix.cpp index cda73b2..62c454c 100644 --- a/src/serialport/qserialport_unix.cpp +++ b/src/serialport/qserialport_unix.cpp @@ -451,6 +451,8 @@ QSerialPortPrivate::setStandardBaudRate(qint32 baudRate, QSerialPort::Directions { struct serial_struct currentSerialInfo; + ::memset(¤tSerialInfo, 0, sizeof(currentSerialInfo)); + if ((::ioctl(descriptor, TIOCGSERIAL, ¤tSerialInfo) != -1) && (currentSerialInfo.flags & ASYNC_SPD_CUST)) { currentSerialInfo.flags &= ~ASYNC_SPD_CUST; @@ -481,6 +483,8 @@ QSerialPortPrivate::setCustomBaudRate(qint32 baudRate, QSerialPort::Directions d struct serial_struct currentSerialInfo; + ::memset(¤tSerialInfo, 0, sizeof(currentSerialInfo)); + if (::ioctl(descriptor, TIOCGSERIAL, ¤tSerialInfo) == -1) return decodeSystemError(); -- 2.3.5