printout fixes for UnixFileGuard #468

Merged
muellerr merged 5 commits from eive/fsfw:mueller/unix-file-guard-fix into development 2021-09-13 15:10:00 +02:00
Showing only changes of commit 845c00044e - Show all commits

View File

@ -1,5 +1,10 @@
#include "fsfw/FSFW.h"
#include "fsfw/serviceinterface.h"
#include "fsfw_hal/linux/UnixFileGuard.h"
#include <cerrno>
#include <cstring>
UnixFileGuard::UnixFileGuard(std::string device, int* fileDescriptor, int flags,
std::string diagnosticPrefix):
fileDescriptor(fileDescriptor) {
@ -10,12 +15,11 @@ UnixFileGuard::UnixFileGuard(std::string device, int* fileDescriptor, int flags,
if (*fileDescriptor < 0) {
#if FSFW_VERBOSE_LEVEL >= 1
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << diagnosticPrefix <<"Opening device failed with error code " << errno <<
"." << std::endl;
sif::warning << "Error description: " << strerror(errno) << std::endl;
sif::warning << diagnosticPrefix << "Opening device failed with error code " <<
errno << ": " << strerror(errno) << std::endl;
#else
sif::printError("%sOpening device failed with error code %d.\n", diagnosticPrefix);
sif::printWarning("Error description: %s\n", strerror(errno));
sif::printWarning("%sOpening device failed with error code %d: %s\n",
muellerr marked this conversation as resolved Outdated

Shouldn't there be a space between diagnosticPrefix and "Opening..." ?

Shouldn't there be a space between diagnosticPrefix and "Opening..." ?

Maybe this and a colon would be more clean. Then it needs to be adapted for the ostream implementation as well and some calling code needs to be adapted

Maybe this and a colon would be more clean. Then it needs to be adapted for the ostream implementation as well and some calling code needs to be adapted
diagnosticPrefix, errno, strerror(errno));
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
openStatus = OPEN_FILE_FAILED;