flash_internal: minor, fix spacing

This commit is contained in:
King Kévin 2020-01-01 23:35:56 +01:00
parent d51c18ab5a
commit fe16ad18cd
1 changed files with 8 additions and 8 deletions

View File

@ -36,18 +36,18 @@
* @return if the data is in the internal flash area
*/
static bool flash_internal_range(uint32_t address, size_t size) {
if (address>(UINT32_MAX-size)) { // on integer overflow will occur
if (address > (UINT32_MAX - size)) { // on integer overflow will occur
return false;
}
if (address<FLASH_BASE) { // start address is before the start of the internal flash
if (address < FLASH_BASE) { // start address is before the start of the internal flash
return false;
}
if ((uint32_t)&__flash_end>=FLASH_BASE) { // check if the end for the internal flash is enforce by the linker script
if ((address+size)>(uint32_t)&__flash_end) { // end address is after the end of the enforced internal flash
if ((uint32_t)&__flash_end >= FLASH_BASE) { // check if the end for the internal flash is enforce by the linker script
if ((address + size) > (uint32_t)&__flash_end) { // end address is after the end of the enforced internal flash
return false;
}
} else {
if ((address+size)>(FLASH_BASE+DESIG_FLASH_SIZE*1024)) { // end address is after the end of the advertised flash
if ((address + size) > (FLASH_BASE + DESIG_FLASH_SIZE * 1024)) { // end address is after the end of the advertised flash
return false;
}
}
@ -57,7 +57,7 @@ static bool flash_internal_range(uint32_t address, size_t size) {
bool flash_internal_read(uint32_t address, uint8_t *buffer, size_t size)
{
// sanity checks
if (buffer==NULL || size==0) {
if (buffer == NULL || size == 0) {
return false;
}
if (!flash_internal_range(address, size)) {
@ -65,8 +65,8 @@ bool flash_internal_read(uint32_t address, uint8_t *buffer, size_t size)
}
// copy data byte per byte (a more efficient way would be to copy words, than the remaining bytes)
for (size_t i=0; i<size; i++) {
buffer[i] = *((uint8_t*)address+i);
for (size_t i = 0; i < size; i++) {
buffer[i] = *((uint8_t*)address + i);
}
return true;