diff options
| author | Max Holliday <maholli@stanford.edu> | 2020-05-09 12:03:26 -0700 |
|---|---|---|
| committer | Max Holliday <maholli@stanford.edu> | 2020-05-09 12:03:26 -0700 |
| commit | 9e01bb213617fd46723f3dbb869ba51c1985ac21 (patch) | |
| tree | 5ae4caf95a186c6e4c2355e26550648843ca39e0 | |
| parent | 9ef28d85363718b2bf0dd17e78c50f422712bccb (diff) | |
Removing erroneous else statements
| -rw-r--r-- | supervisor/shared/external_flash/external_flash.c | 54 |
1 files changed, 26 insertions, 28 deletions
diff --git a/supervisor/shared/external_flash/external_flash.c b/supervisor/shared/external_flash/external_flash.c index 168bbbf68..a2d8ff5f3 100644 --- a/supervisor/shared/external_flash/external_flash.c +++ b/supervisor/shared/external_flash/external_flash.c @@ -131,31 +131,30 @@ static bool page_erased(uint32_t sector_address) { if (flash_device->no_erase_cmd){ // skip this if device doesn't have an erase command. return true; - } else { - uint8_t short_buffer[4]; - if (read_flash(sector_address, short_buffer, 4)) { - for (uint16_t i = 0; i < 4; i++) { - if (short_buffer[i] != 0xff) { - return false; - } + } + uint8_t short_buffer[4]; + if (read_flash(sector_address, short_buffer, 4)) { + for (uint16_t i = 0; i < 4; i++) { + if (short_buffer[i] != 0xff) { + return false; } - } else { - return false; } + } else { + return false; + } - // Now check the full length. - uint8_t full_buffer[FILESYSTEM_BLOCK_SIZE]; - if (read_flash(sector_address, full_buffer, FILESYSTEM_BLOCK_SIZE)) { - for (uint16_t i = 0; i < FILESYSTEM_BLOCK_SIZE; i++) { - if (short_buffer[i] != 0xff) { - return false; - } + // Now check the full length. + uint8_t full_buffer[FILESYSTEM_BLOCK_SIZE]; + if (read_flash(sector_address, full_buffer, FILESYSTEM_BLOCK_SIZE)) { + for (uint16_t i = 0; i < FILESYSTEM_BLOCK_SIZE; i++) { + if (short_buffer[i] != 0xff) { + return false; } - } else { - return false; } - return true; + } else { + return false; } + return true; } // Erases the given sector. Make sure you copied all of the data out of it you @@ -166,16 +165,15 @@ static bool erase_sector(uint32_t sector_address) { if (flash_device->no_erase_cmd){ // skip this if device doesn't have an erase command. return true; - } else { - if (!wait_for_flash_ready() || !write_enable()) { - return false; - } - if (flash_device->no_erase_cmd) { - return true; - } else { - spi_flash_sector_command(CMD_SECTOR_ERASE, sector_address); + } + if (!wait_for_flash_ready() || !write_enable()) { + return false; + } + if (flash_device->no_erase_cmd) { return true; - } + } else { + spi_flash_sector_command(CMD_SECTOR_ERASE, sector_address); + return true; } } |
