Skip to content

Commit

Permalink
Merge pull request #15401 from IVOES/fix-virtual-call-in-constructor
Browse files Browse the repository at this point in the history
Avoid calling virtual functions from constructors and destructors
  • Loading branch information
0xc0170 authored Apr 26, 2023
2 parents d0ca14e + 4c3928e commit 9a82ad6
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion connectivity/netsocket/source/TLSSocketWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ TLSSocketWrapper::TLSSocketWrapper(Socket *transport, const char *hostname, cont
TLSSocketWrapper::~TLSSocketWrapper()
{
if (_transport) {
close();
TLSSocketWrapper::close();
}
mbedtls_entropy_free(&_entropy);

Expand Down
4 changes: 2 additions & 2 deletions drivers/source/CAN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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]) {
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions drivers/source/SPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion storage/filesystem/source/Dir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Dir::Dir(FileSystem *fs, const char *path)
Dir::~Dir()
{
if (_fs) {
close();
Dir::close();
}
}

Expand Down
2 changes: 1 addition & 1 deletion storage/filesystem/source/File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ File::File(FileSystem *fs, const char *path, int flags)
File::~File()
{
if (_fs) {
close();
File::close();
}
}

Expand Down

0 comments on commit 9a82ad6

Please sign in to comment.