Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
FlashIAPBlockDevice init failing if using default constructor #9468
@tommikas FlashIAP block device is a special case where no default constructor can work for all boards. Reason is that flash addresses are different, block device can overrun the code and/or internal storage, and all in all much care should be taken when initializing this block device. Thus calling the default constructor without considering all the implications can be destructive - one can erase the code, the storage, configuration etc. Therefore an init failure is probably the best scenario. Maybe a better documentation or a better explained error can make things clearer, but all in all - this is the expected outcome. In addition, default constructor was kept for backward compatibility sake, as changing it broke few example codes.
I'm fine with all that, as long as it is indeed documented clearly and the failure is explicit. Fixing it now that I know what the problem is is trivial, but figuring out what exactly was wrong took too much work.
As a user I'd prefer it breaking at compile time rather than run time. I understand not wanting to break the API, but that doesn't help much if the functionality breaks.
Defining the flash address and size statically for the targets I want to support isn't a problem.
referenced this issue
Jan 23, 2019
PR created to resolve this issue. Note that it can't be resolved in compilation time, as the compiler can't tell whether the default constructor is used or not. Added a run time assertion that points out the error - better than before, where it just didn't work.