diff --git a/src/fsfw_hal/linux/i2c/I2cComIF.cpp b/src/fsfw_hal/linux/i2c/I2cComIF.cpp index d66e91de..10e493e5 100644 --- a/src/fsfw_hal/linux/i2c/I2cComIF.cpp +++ b/src/fsfw_hal/linux/i2c/I2cComIF.cpp @@ -66,8 +66,7 @@ ReturnValue_t I2cComIF::initializeInterface(CookieIF* cookie) { ReturnValue_t I2cComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, size_t sendLen) { ReturnValue_t result; - int fd; - std::string deviceFile; + int fd = 0; if (sendData == nullptr) { #if FSFW_CPP_OSTREAM_ENABLED == 1 @@ -98,7 +97,7 @@ ReturnValue_t I2cComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s return returnvalue::FAILED; } - deviceFile = i2cCookie->getDeviceFile(); + const auto& deviceFile = i2cCookie->getDeviceFile(); UnixFileGuard fileHelper(deviceFile, &fd, O_RDWR, "I2cComIF::sendMessage"); if (fileHelper.getOpenResult() != returnvalue::OK) { return fileHelper.getOpenResult(); @@ -132,7 +131,6 @@ ReturnValue_t I2cComIF::getSendSuccess(CookieIF* cookie) { return returnvalue::O ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLen) { ReturnValue_t result; int fd; - std::string deviceFile; if (requestLen == 0) { return returnvalue::OK; @@ -157,7 +155,7 @@ ReturnValue_t I2cComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLe } i2cDeviceMapIter->second.replyLen = 0; - deviceFile = i2cCookie->getDeviceFile(); + auto& deviceFile = i2cCookie->getDeviceFile(); UnixFileGuard fileHelper(deviceFile, &fd, O_RDWR, "I2cComIF::requestReceiveMessage"); if (fileHelper.getOpenResult() != returnvalue::OK) { return fileHelper.getOpenResult();