Skip to content

Commit f6873d5

Browse files
committed
Checking for correct storage type selection allows elimination of if clause and therefore further code simplification.
1 parent d1eef9e commit f6873d5

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

src/Arduino_Portenta_OTA_QSPI.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,18 +78,15 @@ bool Arduino_Portenta_OTA_QSPI::init()
7878

7979
bool Arduino_Portenta_OTA_QSPI::open()
8080
{
81-
if(_storage_type == QSPI_FLASH_FATFS || _storage_type == QSPI_FLASH_FATFS_MBR)
81+
DIR * dir = NULL;
82+
if ((dir = opendir("/fs")) != NULL)
8283
{
83-
DIR * dir = NULL;
84-
if ((dir = opendir("/fs")) != NULL)
84+
if (Arduino_Portenta_OTA::findProgramLength(dir, _program_length))
8585
{
86-
if (Arduino_Portenta_OTA::findProgramLength(dir, _program_length))
87-
{
88-
closedir(dir);
89-
return true;
90-
}
9186
closedir(dir);
87+
return true;
9288
}
89+
closedir(dir);
9390
}
9491

9592
return false;

src/Arduino_Portenta_OTA_SD.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -87,18 +87,15 @@ bool Arduino_Portenta_OTA_SD::init()
8787

8888
bool Arduino_Portenta_OTA_SD::open()
8989
{
90-
if (_storage_type == SD_FATFS || _storage_type == SD_FATFS_MBR)
90+
DIR * dir = NULL;
91+
if ((dir = opendir("/fs")) != NULL)
9192
{
92-
DIR * dir = NULL;
93-
if ((dir = opendir("/fs")) != NULL)
93+
if (Arduino_Portenta_OTA::findProgramLength(dir, _program_length))
9494
{
95-
if (Arduino_Portenta_OTA::findProgramLength(dir, _program_length))
96-
{
97-
closedir(dir);
98-
return true;
99-
}
10095
closedir(dir);
96+
return true;
10197
}
98+
closedir(dir);
10299
}
103100

104101
return false;

0 commit comments

Comments
 (0)