mirror of https://github.com/ARMmbed/mbed-os.git
Avoid calling virtual functions from constructors and destructors
Virtual functions are resolved statically (not dynamically) in constructors and destructors for the same class. The call should be made explicitly static by qualifying it using the scope resolution operator.pull/15401/head
parent
975dfcf968
commit
4c3928ecf4
|
@ -77,7 +77,7 @@ TLSSocketWrapper::TLSSocketWrapper(Socket *transport, const char *hostname, cont
|
|||
TLSSocketWrapper::~TLSSocketWrapper()
|
||||
{
|
||||
if (_transport) {
|
||||
close();
|
||||
TLSSocketWrapper::close();
|
||||
}
|
||||
mbedtls_entropy_free(&_entropy);
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ int CAN::filter(unsigned int id, unsigned int mask, CANFormat format, int handle
|
|||
|
||||
void CAN::attach(Callback<void()> func, IrqType type)
|
||||
{
|
||||
lock();
|
||||
CAN::lock();
|
||||
if (func) {
|
||||
// lock deep sleep only the first time
|
||||
if (!_irq[(CanIrqType)type]) {
|
||||
|
@ -154,7 +154,7 @@ void CAN::attach(Callback<void()> func, IrqType type)
|
|||
_irq[(CanIrqType)type] = nullptr;
|
||||
can_irq_set(&_can, (CanIrqType)type, 0);
|
||||
}
|
||||
unlock();
|
||||
CAN::unlock();
|
||||
}
|
||||
|
||||
void CAN::_irq_handler(uintptr_t context, CanIrqType type)
|
||||
|
|
|
@ -148,12 +148,12 @@ void SPI::_do_construct()
|
|||
|
||||
SPI::~SPI()
|
||||
{
|
||||
lock();
|
||||
SPI::lock();
|
||||
/* Make sure a stale pointer isn't left in peripheral's owner field */
|
||||
if (_peripheral->owner == this) {
|
||||
_peripheral->owner = nullptr;
|
||||
}
|
||||
unlock();
|
||||
SPI::unlock();
|
||||
}
|
||||
|
||||
SPI::spi_peripheral_s *SPI::_lookup(SPI::SPIName name)
|
||||
|
|
|
@ -34,7 +34,7 @@ Dir::Dir(FileSystem *fs, const char *path)
|
|||
Dir::~Dir()
|
||||
{
|
||||
if (_fs) {
|
||||
close();
|
||||
Dir::close();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ File::File(FileSystem *fs, const char *path, int flags)
|
|||
File::~File()
|
||||
{
|
||||
if (_fs) {
|
||||
close();
|
||||
File::close();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue