mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-24 08:44:08 -04:00
DataFlash: add sanity checks around EraseAll
This commit is contained in:
parent
40e2238936
commit
c16a810e89
@ -489,11 +489,18 @@ char *DataFlash_File::_lastlog_file_name(void) const
|
|||||||
// remove all log files
|
// remove all log files
|
||||||
void DataFlash_File::EraseAll()
|
void DataFlash_File::EraseAll()
|
||||||
{
|
{
|
||||||
uint16_t log_num;
|
if (hal.util->get_soft_armed()) {
|
||||||
|
// do not want to do any filesystem operations while we are e.g. flying
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!_initialised) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const bool was_logging = (_write_fd != -1);
|
const bool was_logging = (_write_fd != -1);
|
||||||
stop_logging();
|
stop_logging();
|
||||||
|
|
||||||
for (log_num=1; log_num<=MAX_LOG_FILES; log_num++) {
|
for (uint16_t log_num=1; log_num<=MAX_LOG_FILES; log_num++) {
|
||||||
char *fname = _log_file_name(log_num);
|
char *fname = _log_file_name(log_num);
|
||||||
if (fname == nullptr) {
|
if (fname == nullptr) {
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user