Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DataFlash: add sanity checks around EraseAll #9671

Merged
merged 1 commit into from Nov 5, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions libraries/DataFlash/DataFlash_File.cpp
Expand Up @@ -478,11 +478,18 @@ char *DataFlash_File::_lastlog_file_name(void) const
// remove all log files
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);
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);
if (fname == nullptr) {
break;
Expand Down