Skip to content

Commit 74f57cc

Browse files
authored
Merge pull request #19 from alrvid/main
Fix undefined behavior
2 parents 1f48b3f + eda8173 commit 74f57cc

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

libraries/BlockDevices/BlockDevice.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@
3030
#define BD_ERROR_DEVICE_ERROR (-4001)
3131
#define BD_ERROR_WRITE_PROTECTED (4002)
3232

33-
typedef uint32_t bd_addr_t;
34-
typedef uint32_t bd_size_t;
33+
typedef uint64_t bd_addr_t;
34+
typedef uint64_t bd_size_t;
3535
typedef pin_size_t pin_t;
3636

3737
/* -------------------------------------------------------------------------- */
@@ -107,4 +107,4 @@ class BlockDevice {
107107
virtual const char *get_type() const = 0;
108108
};
109109

110-
#endif
110+
#endif

libraries/BlockDevices/CodeFlashBlockDevice.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -54,8 +54,8 @@ using FLASH_set_callback_f = fsp_err_t (*)(flash_ctrl_t * const p_api_ct
5454
class CodeFlashBlockDevice : public BlockDevice {
5555
private:
5656
CodeFlashBlockDevice();
57-
int erase_block(uint32_t add);
58-
int check_blank(uint32_t add);
57+
int erase_block(bd_addr_t add);
58+
int check_blank(bd_addr_t add);
5959
uint32_t get_block_starting_address(bd_addr_t add);
6060
uint32_t get_physical_address(bd_addr_t add);
6161
virtual int write(const void *buffer, bd_addr_t addr, bd_size_t size) override;

libraries/BlockDevices/DataFlashBlockDevice.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ using FLASH_set_callback_f = fsp_err_t (*)(flash_ctrl_t * const p_api_ct
7373
class DataFlashBlockDevice : public BlockDevice {
7474
private:
7575
DataFlashBlockDevice();
76-
int erase_block(uint32_t add);
77-
int check_blank(uint32_t add);
76+
int erase_block(bd_addr_t add);
77+
int check_blank(bd_addr_t add);
7878
uint32_t get_block_starting_address(bd_addr_t add);
7979
uint32_t get_physical_address(bd_addr_t add);
8080
bool is_address_correct(bd_addr_t add);
@@ -136,4 +136,4 @@ class DataFlashBlockDevice : public BlockDevice {
136136
};
137137

138138

139-
#endif
139+
#endif

libraries/BlockDevices/SDCardBlockDevice.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ int SDCardBlockDevice::open() {
313313
read_block_size = sd_card_info.sector_size_bytes;
314314
erase_block_size = sd_card_info.sector_size_bytes;
315315
write_block_size = sd_card_info.sector_size_bytes;
316-
total_size = sd_card_info.sector_count * sd_card_info.sector_size_bytes;
316+
total_size = (bd_size_t) sd_card_info.sector_count * (bd_size_t) sd_card_info.sector_size_bytes;
317317

318318
}
319319
}
@@ -478,7 +478,7 @@ fsp_err_t SDCardBlockDevice::wait_for_completition() {
478478

479479
rv = FSP_ERR_TIMEOUT;
480480
}
481-
481+
return rv;
482482
}
483483

484484

0 commit comments

Comments
 (0)