diff --git a/libraries/DataFlash/DataFlash_File.cpp b/libraries/DataFlash/DataFlash_File.cpp index f4f67c6ea8..f0c61962e3 100644 --- a/libraries/DataFlash/DataFlash_File.cpp +++ b/libraries/DataFlash/DataFlash_File.cpp @@ -861,9 +861,14 @@ uint16_t DataFlash_File::start_new_log(void) char buf[30]; snprintf(buf, sizeof(buf), "%u\r\n", (unsigned)log_num); - write(fd, buf, strlen(buf)); + const ssize_t to_write = strlen(buf); + const ssize_t written = write(fd, buf, to_write); close(fd); + if (written < to_write) { + return 0xFFFF; + } + return log_num; }