mirror of https://github.com/ARMmbed/mbed-os.git
bd: Fix missing init in MBRBlockDevice
parent
d7fe4ff599
commit
adc3d75936
|
@ -187,11 +187,16 @@ MBRBlockDevice::MBRBlockDevice(BlockDevice *bd, int part)
|
||||||
|
|
||||||
int MBRBlockDevice::init()
|
int MBRBlockDevice::init()
|
||||||
{
|
{
|
||||||
|
int err = _bd->init();
|
||||||
|
if (err) {
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
// Allocate smallest buffer necessary to write MBR
|
// Allocate smallest buffer necessary to write MBR
|
||||||
uint32_t buffer_size = std::max<uint32_t>(_bd->get_read_size(), sizeof(struct mbr_table));
|
uint32_t buffer_size = std::max<uint32_t>(_bd->get_read_size(), sizeof(struct mbr_table));
|
||||||
uint8_t *buffer = new uint8_t[buffer_size];
|
uint8_t *buffer = new uint8_t[buffer_size];
|
||||||
|
|
||||||
int err = _bd->read(buffer, 512-buffer_size, buffer_size);
|
err = _bd->read(buffer, 512-buffer_size, buffer_size);
|
||||||
if (err) {
|
if (err) {
|
||||||
delete[] buffer;
|
delete[] buffer;
|
||||||
return err;
|
return err;
|
||||||
|
|
Loading…
Reference in New Issue