diff --git a/libuavcan_drivers/posix_tools/include/posix_tools/file_event_tracer.hpp b/libuavcan_drivers/posix_tools/include/posix_tools/file_event_tracer.hpp index 1d69bd932e..e88e622c85 100644 --- a/libuavcan_drivers/posix_tools/include/posix_tools/file_event_tracer.hpp +++ b/libuavcan_drivers/posix_tools/include/posix_tools/file_event_tracer.hpp @@ -63,9 +63,12 @@ public: if (path.size() > 0) { + rv = 0; path_ = path.c_str(); - rv = open(path_.c_str(), O_WRONLY | O_CREAT | O_TRUNC); - close(rv); + int fd = open(path_.c_str(), O_RDWR | O_CREAT | O_TRUNC); + if ( fd >= 0) { + close(fd); + } } return rv; } diff --git a/libuavcan_drivers/posix_tools/include/posix_tools/file_storage_backend.hpp b/libuavcan_drivers/posix_tools/include/posix_tools/file_storage_backend.hpp index 5595f3b478..55292e7ef6 100644 --- a/libuavcan_drivers/posix_tools/include/posix_tools/file_storage_backend.hpp +++ b/libuavcan_drivers/posix_tools/include/posix_tools/file_storage_backend.hpp @@ -71,6 +71,7 @@ public: break; } } + value = buffer; } } return value; @@ -121,10 +122,12 @@ public: { rv = mkdir(base_path.c_str(), S_IRWXU | S_IRWXG | S_IRWXO); } - base_path.push_back('/'); - if ((base_path.size() + MaxStringLength) > MaxPathLength) - { - rv = -uavcan::ErrInvalidConfiguration; + if (rv >= 0 ) { + base_path.push_back('/'); + if ((base_path.size() + MaxStringLength) > MaxPathLength) + { + rv = -uavcan::ErrInvalidConfiguration; + } } } return rv;