mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-13 06:23:34 +08:00
POSIX dynamic ID storage backend: calling fsync() on set(), plus a minor style fix
This commit is contained in:
+5
-4
@@ -53,9 +53,9 @@ class FileStorageBackend : public uavcan::dynamic_node_id_server::IStorageBacken
|
||||
if (fd >= 0)
|
||||
{
|
||||
char buffer[MaxStringLength + 1];
|
||||
memset(buffer, 0, sizeof(buffer));
|
||||
(void)memset(buffer, 0, sizeof(buffer));
|
||||
int len = read(fd, buffer, MaxStringLength);
|
||||
close(fd);
|
||||
(void)close(fd);
|
||||
if (len > 0)
|
||||
{
|
||||
for (int i = 0; i < len; i++)
|
||||
@@ -80,8 +80,9 @@ class FileStorageBackend : public uavcan::dynamic_node_id_server::IStorageBacken
|
||||
int fd = open(path.c_str(), O_WRONLY | O_CREAT | O_TRUNC, FilePermissions);
|
||||
if (fd >= 0)
|
||||
{
|
||||
write(fd, value.c_str(), value.size());
|
||||
close(fd);
|
||||
(void)write(fd, value.c_str(), value.size());
|
||||
(void)fsync(fd);
|
||||
(void)close(fd);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user