Skip to content

Commit

Permalink
Add const keyword to get_erase_size declaration
Browse files Browse the repository at this point in the history
Add const to function declaration. Const objects cannot access const
safe functions, a compiler error is thrown if one tries to do so. This
helps ensure that the object calling the method will not be modified.
This is espescially desirable in functions where all we need to do is
query existing data and not make any alterations.
  • Loading branch information
harrisonmutai-arm committed Nov 25, 2020
1 parent 6d89500 commit 9857a4d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Expand Up @@ -223,7 +223,7 @@ class QSPIFBlockDevice : public mbed::BlockDevice {
* @return Size of minimal erase sector size, in given address region, in bytes
* @note Must be a multiple of the program size
*/
virtual mbed::bd_size_t get_erase_size(mbed::bd_addr_t addr);
virtual mbed::bd_size_t get_erase_size(mbed::bd_addr_t addr) const;

/** Get the value of storage byte after it was erased
*
Expand Down
Expand Up @@ -502,7 +502,7 @@ const char *QSPIFBlockDevice::get_type() const
}

// Find minimal erase size supported by the region to which the address belongs to
bd_size_t QSPIFBlockDevice::get_erase_size(bd_addr_t addr)
bd_size_t QSPIFBlockDevice::get_erase_size(bd_addr_t addr) const
{
// If the legacy erase instruction is in use, the erase size is uniformly 4k
if (_sfdp_info.bptbl.legacy_erase_instruction != QSPI_NO_INST) {
Expand Down

0 comments on commit 9857a4d

Please sign in to comment.