Skip to content

Commit 56fe2db

Browse files
luc-githubme-no-dev
authored andcommitted
Fix F_Fat::format return false when succeed (#3220)
this is due to ussage of esp_err_t result; instead of boolean, ESP_OK =0 so it is false
1 parent 06a399b commit 56fe2db

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

libraries/FFat/src/FFat.cpp

+13-2
Original file line numberDiff line numberDiff line change
@@ -76,21 +76,28 @@ void F_Fat::end()
7676
bool F_Fat::format(bool full_wipe, char* partitionLabel)
7777
{
7878
esp_err_t result;
79+
bool res = true;
7980
if(_wl_handle){
8081
log_w("Already Mounted!");
8182
return false;
8283
}
8384
wl_handle_t temp_handle;
8485
// Attempt to mount to see if there is already data
8586
const esp_partition_t *ffat_partition = check_ffat_partition(partitionLabel);
86-
if (!ffat_partition) return false;
87+
if (!ffat_partition){
88+
log_w("No partition!");
89+
return false;
90+
}
8791
result = wl_mount(ffat_partition, &temp_handle);
8892

8993
if (result == ESP_OK) {
9094
// Wipe disk- quick just wipes the FAT. Full zeroes the whole disk
9195
uint32_t wipe_size = full_wipe ? wl_size(temp_handle) : 16384;
9296
wl_erase_range(temp_handle, 0, wipe_size);
9397
wl_unmount(temp_handle);
98+
} else {
99+
res = false;
100+
log_w("wl_mount failed!");
94101
}
95102
// Now do a mount with format_if_fail (which it will)
96103
esp_vfs_fat_mount_config_t conf = {
@@ -99,7 +106,11 @@ bool F_Fat::format(bool full_wipe, char* partitionLabel)
99106
};
100107
result = esp_vfs_fat_spiflash_mount("/format_ffat", partitionLabel, &conf, &temp_handle);
101108
esp_vfs_fat_spiflash_unmount("/format_ffat", temp_handle);
102-
return result;
109+
if (result != ESP_OK){
110+
res = false;
111+
log_w("esp_vfs_fat_spiflash_mount failed!");
112+
}
113+
return res;
103114
}
104115

105116
size_t F_Fat::totalBytes()

0 commit comments

Comments
 (0)