mirror of
https://github.com/eclipse/upm.git
synced 2025-03-24 17:30:01 +03:00
mhz16: Remove post-throw returns + small fixes
Removed the 'return false;' lines after throws since these are not needed and are generally flagged by static analysis tools. Also removed a EOL spaces and added initializers for member variables at declaration (since more than one constructor exists). Signed-off-by: Noel Eck <noel.eck@intel.com>
This commit is contained in:
parent
dd73c4aa45
commit
17110d41d0
@ -41,7 +41,6 @@ MHZ16::MHZ16(int uart)
|
||||
{
|
||||
throw std::invalid_argument(std::string(__FUNCTION__) +
|
||||
": mraa_uart_init() failed");
|
||||
return;
|
||||
}
|
||||
|
||||
// This requires a recent MRAA (1/2015)
|
||||
@ -51,7 +50,6 @@ MHZ16::MHZ16(int uart)
|
||||
{
|
||||
throw std::runtime_error(std::string(__FUNCTION__) +
|
||||
": mraa_uart_get_dev_path() failed");
|
||||
return;
|
||||
}
|
||||
|
||||
// now open the tty
|
||||
@ -61,7 +59,6 @@ MHZ16::MHZ16(int uart)
|
||||
": open of " +
|
||||
string(devPath) + " failed: " +
|
||||
string(strerror(errno)));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,7 +70,6 @@ MHZ16::MHZ16(const std::string& uart_raw)
|
||||
{
|
||||
throw std::invalid_argument(std::string(__FUNCTION__) +
|
||||
": mraa_uart_init_raw() failed");
|
||||
return;
|
||||
}
|
||||
|
||||
// This requires a recent MRAA (1/2015)
|
||||
@ -83,7 +79,6 @@ MHZ16::MHZ16(const std::string& uart_raw)
|
||||
{
|
||||
throw std::runtime_error(std::string(__FUNCTION__) +
|
||||
": mraa_uart_get_dev_path() failed");
|
||||
return;
|
||||
}
|
||||
|
||||
// now open the tty
|
||||
@ -93,7 +88,6 @@ MHZ16::MHZ16(const std::string& uart_raw)
|
||||
": open of " +
|
||||
string(devPath) + " failed: " +
|
||||
string(strerror(errno)));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -124,8 +118,8 @@ bool MHZ16::dataAvailable(unsigned int millis)
|
||||
|
||||
if (select(m_ttyFd + 1, &readfds, NULL, NULL, &timeout) > 0)
|
||||
return true; // data is ready
|
||||
else
|
||||
return false;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
int MHZ16::readData(char *buffer, int len)
|
||||
@ -143,7 +137,6 @@ int MHZ16::readData(char *buffer, int len)
|
||||
throw std::runtime_error(std::string(__FUNCTION__) +
|
||||
": read() failed: " +
|
||||
string(strerror(errno)));
|
||||
return rv;
|
||||
}
|
||||
|
||||
return rv;
|
||||
@ -164,7 +157,6 @@ int MHZ16::writeData(char *buffer, int len)
|
||||
throw std::runtime_error(std::string(__FUNCTION__) +
|
||||
": write() failed: " +
|
||||
string(strerror(errno)));
|
||||
return rv;
|
||||
}
|
||||
|
||||
tcdrain(m_ttyFd);
|
||||
@ -196,7 +188,6 @@ bool MHZ16::setupTty(speed_t baud)
|
||||
throw std::runtime_error(std::string(__FUNCTION__) +
|
||||
": tcsetattr() failed: " +
|
||||
string(strerror(errno)));
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -208,7 +199,6 @@ bool MHZ16::verifyPacket(uint8_t *pkt, int len)
|
||||
{
|
||||
throw std::runtime_error(std::string(__FUNCTION__) +
|
||||
": invalid packet header received");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -227,7 +217,6 @@ bool MHZ16::getData()
|
||||
{
|
||||
throw std::runtime_error(std::string(__FUNCTION__) +
|
||||
": Timed out waiting for response");
|
||||
return false;
|
||||
}
|
||||
|
||||
// read the packet
|
||||
@ -238,7 +227,6 @@ bool MHZ16::getData()
|
||||
{
|
||||
throw std::runtime_error(std::string(__FUNCTION__) +
|
||||
": Invalid packet size read");
|
||||
return false;
|
||||
}
|
||||
|
||||
// will throw an exception if it fails
|
||||
|
@ -170,9 +170,9 @@ namespace upm {
|
||||
|
||||
private:
|
||||
mraa_uart_context m_uart;
|
||||
int m_ttyFd;
|
||||
int gas;
|
||||
int temp;
|
||||
int m_ttyFd = 0;
|
||||
int gas = 0;
|
||||
int temp = 0;
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user