Skip to content

Commit 9e01bb2

Browse files
committed
Removing erroneous else statements
1 parent 9ef28d8 commit 9e01bb2

File tree

1 file changed

+26
-28
lines changed

1 file changed

+26
-28
lines changed

supervisor/shared/external_flash/external_flash.c

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -131,31 +131,30 @@ static bool page_erased(uint32_t sector_address) {
131131
if (flash_device->no_erase_cmd){
132132
// skip this if device doesn't have an erase command.
133133
return true;
134-
} else {
135-
uint8_t short_buffer[4];
136-
if (read_flash(sector_address, short_buffer, 4)) {
137-
for (uint16_t i = 0; i < 4; i++) {
138-
if (short_buffer[i] != 0xff) {
139-
return false;
140-
}
134+
}
135+
uint8_t short_buffer[4];
136+
if (read_flash(sector_address, short_buffer, 4)) {
137+
for (uint16_t i = 0; i < 4; i++) {
138+
if (short_buffer[i] != 0xff) {
139+
return false;
141140
}
142-
} else {
143-
return false;
144141
}
142+
} else {
143+
return false;
144+
}
145145

146-
// Now check the full length.
147-
uint8_t full_buffer[FILESYSTEM_BLOCK_SIZE];
148-
if (read_flash(sector_address, full_buffer, FILESYSTEM_BLOCK_SIZE)) {
149-
for (uint16_t i = 0; i < FILESYSTEM_BLOCK_SIZE; i++) {
150-
if (short_buffer[i] != 0xff) {
151-
return false;
152-
}
146+
// Now check the full length.
147+
uint8_t full_buffer[FILESYSTEM_BLOCK_SIZE];
148+
if (read_flash(sector_address, full_buffer, FILESYSTEM_BLOCK_SIZE)) {
149+
for (uint16_t i = 0; i < FILESYSTEM_BLOCK_SIZE; i++) {
150+
if (short_buffer[i] != 0xff) {
151+
return false;
153152
}
154-
} else {
155-
return false;
156153
}
157-
return true;
154+
} else {
155+
return false;
158156
}
157+
return true;
159158
}
160159

161160
// 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) {
166165
if (flash_device->no_erase_cmd){
167166
// skip this if device doesn't have an erase command.
168167
return true;
169-
} else {
170-
if (!wait_for_flash_ready() || !write_enable()) {
171-
return false;
172-
}
173-
if (flash_device->no_erase_cmd) {
174-
return true;
175-
} else {
176-
spi_flash_sector_command(CMD_SECTOR_ERASE, sector_address);
168+
}
169+
if (!wait_for_flash_ready() || !write_enable()) {
170+
return false;
171+
}
172+
if (flash_device->no_erase_cmd) {
177173
return true;
178-
}
174+
} else {
175+
spi_flash_sector_command(CMD_SECTOR_ERASE, sector_address);
176+
return true;
179177
}
180178
}
181179

0 commit comments

Comments
 (0)