Skip to content

Commit 9857a4d

Browse files
Add const keyword to get_erase_size declaration
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.
1 parent 6d89500 commit 9857a4d

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

storage/blockdevice/COMPONENT_QSPIF/include/QSPIF/QSPIFBlockDevice.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ class QSPIFBlockDevice : public mbed::BlockDevice {
223223
* @return Size of minimal erase sector size, in given address region, in bytes
224224
* @note Must be a multiple of the program size
225225
*/
226-
virtual mbed::bd_size_t get_erase_size(mbed::bd_addr_t addr);
226+
virtual mbed::bd_size_t get_erase_size(mbed::bd_addr_t addr) const;
227227

228228
/** Get the value of storage byte after it was erased
229229
*

storage/blockdevice/COMPONENT_QSPIF/source/QSPIFBlockDevice.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ const char *QSPIFBlockDevice::get_type() const
502502
}
503503

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

0 commit comments

Comments
 (0)