Skip to content

Commit 4c3928e

Browse files
committed
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.
1 parent 975dfcf commit 4c3928e

File tree

5 files changed

+7
-7
lines changed

5 files changed

+7
-7
lines changed

connectivity/netsocket/source/TLSSocketWrapper.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ TLSSocketWrapper::TLSSocketWrapper(Socket *transport, const char *hostname, cont
7777
TLSSocketWrapper::~TLSSocketWrapper()
7878
{
7979
if (_transport) {
80-
close();
80+
TLSSocketWrapper::close();
8181
}
8282
mbedtls_entropy_free(&_entropy);
8383

drivers/source/CAN.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ int CAN::filter(unsigned int id, unsigned int mask, CANFormat format, int handle
138138

139139
void CAN::attach(Callback<void()> func, IrqType type)
140140
{
141-
lock();
141+
CAN::lock();
142142
if (func) {
143143
// lock deep sleep only the first time
144144
if (!_irq[(CanIrqType)type]) {
@@ -154,7 +154,7 @@ void CAN::attach(Callback<void()> func, IrqType type)
154154
_irq[(CanIrqType)type] = nullptr;
155155
can_irq_set(&_can, (CanIrqType)type, 0);
156156
}
157-
unlock();
157+
CAN::unlock();
158158
}
159159

160160
void CAN::_irq_handler(uintptr_t context, CanIrqType type)

drivers/source/SPI.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,12 @@ void SPI::_do_construct()
148148

149149
SPI::~SPI()
150150
{
151-
lock();
151+
SPI::lock();
152152
/* Make sure a stale pointer isn't left in peripheral's owner field */
153153
if (_peripheral->owner == this) {
154154
_peripheral->owner = nullptr;
155155
}
156-
unlock();
156+
SPI::unlock();
157157
}
158158

159159
SPI::spi_peripheral_s *SPI::_lookup(SPI::SPIName name)

storage/filesystem/source/Dir.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Dir::Dir(FileSystem *fs, const char *path)
3434
Dir::~Dir()
3535
{
3636
if (_fs) {
37-
close();
37+
Dir::close();
3838
}
3939
}
4040

storage/filesystem/source/File.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ File::File(FileSystem *fs, const char *path, int flags)
3434
File::~File()
3535
{
3636
if (_fs) {
37-
close();
37+
File::close();
3838
}
3939
}
4040

0 commit comments

Comments
 (0)