mirror of https://github.com/ARMmbed/mbed-os.git
SlicingBlockDevice should assert, if size does not look valid
parent
92a60c3d80
commit
bcaf37dcfa
|
@ -20,6 +20,7 @@
|
|||
#include <algorithm>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "mbed_assert.h"
|
||||
|
||||
namespace mbed {
|
||||
|
||||
|
@ -34,6 +35,7 @@ FlashSimBlockDevice::FlashSimBlockDevice(BlockDevice *bd, uint8_t erase_value) :
|
|||
_erase_value(erase_value), _blank_buf_size(0),
|
||||
_blank_buf(0), _bd(bd), _init_ref_count(0), _is_initialized(false)
|
||||
{
|
||||
MBED_ASSERT(bd);
|
||||
}
|
||||
|
||||
FlashSimBlockDevice::~FlashSimBlockDevice()
|
||||
|
|
|
@ -27,6 +27,11 @@ SlicingBlockDevice::SlicingBlockDevice(BlockDevice *bd, bd_addr_t start, bd_addr
|
|||
, _start_from_end(false), _start(start)
|
||||
, _stop_from_end(false), _stop(stop)
|
||||
{
|
||||
MBED_ASSERT(bd);
|
||||
// SlicingBlockDevice(bd, 0,0) would use the full block, which does not make sense, it must be a programming eror.
|
||||
// SlicingBlockDevice(bd, 100,100) would have no size, which is also a programming error.
|
||||
MBED_ASSERT(start != stop);
|
||||
|
||||
if ((int64_t)_start < 0) {
|
||||
_start_from_end = true;
|
||||
_start = -_start;
|
||||
|
|
Loading…
Reference in New Issue