0
0
mirror of https://github.com/OpenVPN/openvpn3.git synced 2024-09-19 19:52:15 +02:00

Add default virtual destructors to base classes with virtual functions

Without this fix, the openvpn3-linux build is broken whenever a
dependency enables -Wnon-virtual-dtor (which protobuf 27.3
currently does on Arch Linux). The openvpn3-linux build treats
warnings as errors.

Jira: OVPN3-1242
Signed-off-by: Razvan Cojocaru <razvan.cojocaru@openvpn.com>
(cherry picked from commit 6217fa0e1a)
This commit is contained in:
Razvan Cojocaru 2024-08-07 11:59:07 +03:00 committed by David Sommerseth
parent 8ced530d72
commit 6b56849c87
10 changed files with 33 additions and 2 deletions

View File

@ -32,8 +32,9 @@ namespace openvpn {
class BufferComplete class BufferComplete
{ {
public: public:
/* each advance/get method returns false if message is incomplete */ virtual ~BufferComplete() = default;
/* each advance/get method returns false if message is incomplete */
bool advance(size_t size) bool advance(size_t size)
{ {
while (size) while (size)

View File

@ -214,7 +214,17 @@ class ConstBufferType
{ {
} }
// const index into array /**
* @brief Needed because this class has virtual member functions and is
* intended as a base class.
*/
virtual ~ConstBufferType() = default;
/**
* @brief Const indexing operator for ConstBufferType.
* @param index Index of the element to access.
* @return Const reference to the element at the specified index.
*/
const T &operator[](const size_t index) const const T &operator[](const size_t index) const
{ {
if (index >= size_) if (index >= size_)

View File

@ -43,6 +43,8 @@ class BufferLimit
reset(); reset();
} }
virtual ~BufferLimit() = default;
void set_max(const T max_lines_arg, void set_max(const T max_lines_arg,
const T max_bytes_arg) const T max_bytes_arg)
{ {

View File

@ -34,6 +34,8 @@ class ClientLifeCycle : public RC<thread_unsafe_refcount>
public: public:
struct NotifyCallback struct NotifyCallback
{ {
virtual ~NotifyCallback() = default;
virtual void cln_stop() = 0; virtual void cln_stop() = 0;
virtual void cln_pause(const std::string &reason) = 0; virtual void cln_pause(const std::string &reason) = 0;
virtual void cln_resume() = 0; virtual void cln_resume() = 0;

View File

@ -81,6 +81,8 @@ namespace openvpn::ClientProto {
struct NotifyCallback struct NotifyCallback
{ {
virtual ~NotifyCallback() = default;
virtual void client_proto_terminate() = 0; virtual void client_proto_terminate() = 0;
virtual void client_proto_connected() virtual void client_proto_connected()
{ {

View File

@ -112,6 +112,8 @@ class RemoteList : public RC<thread_unsafe_refcount>
{ {
typedef RCPtr<ConnBlockFactory> Ptr; typedef RCPtr<ConnBlockFactory> Ptr;
virtual ~ConnBlockFactory() = default;
virtual ConnBlock::Ptr new_conn_block(const OptionList::Ptr &opt) = 0; virtual ConnBlock::Ptr new_conn_block(const OptionList::Ptr &opt) = 0;
}; };
@ -229,6 +231,8 @@ class RemoteList : public RC<thread_unsafe_refcount>
struct RemoteOverride struct RemoteOverride
{ {
virtual ~RemoteOverride() = default;
virtual Item::Ptr get() = 0; virtual Item::Ptr get() = 0;
}; };
@ -311,6 +315,8 @@ class RemoteList : public RC<thread_unsafe_refcount>
struct NotifyCallback struct NotifyCallback
{ {
virtual ~NotifyCallback() = default;
// client callback when resolve operation is complete // client callback when resolve operation is complete
virtual void bulk_resolve_done() = 0; virtual void bulk_resolve_done() = 0;
}; };

View File

@ -161,6 +161,8 @@ enum
class ProtoContextCallbackInterface class ProtoContextCallbackInterface
{ {
public: public:
virtual ~ProtoContextCallbackInterface() = default;
/** /**
* Sends out bytes to the network. * Sends out bytes to the network.
*/ */

View File

@ -26,6 +26,8 @@ namespace openvpn {
class ReconnectNotify class ReconnectNotify
{ {
public: public:
virtual ~ReconnectNotify() = default;
// When a connection is close to timeout, the core will call this // When a connection is close to timeout, the core will call this
// method. If it returns false, the core will disconnect with a // method. If it returns false, the core will disconnect with a
// CONNECTION_TIMEOUT event. If true, the core will enter a PAUSE // CONNECTION_TIMEOUT event. If true, the core will enter a PAUSE

View File

@ -35,6 +35,8 @@ namespace openvpn {
class BaseSocketProtect class BaseSocketProtect
{ {
public: public:
virtual ~BaseSocketProtect() = default;
virtual bool socket_protect(openvpn_io::detail::socket_type socket, IP::Addr endpoint) = 0; virtual bool socket_protect(openvpn_io::detail::socket_type socket, IP::Addr endpoint) = 0;
}; };

View File

@ -70,6 +70,8 @@ struct TunClient : public virtual RC<thread_unsafe_refcount>
// special events, and progress notifications. // special events, and progress notifications.
struct TunClientParent struct TunClientParent
{ {
virtual ~TunClientParent() = default;
virtual void tun_recv(BufferAllocated &buf) = 0; virtual void tun_recv(BufferAllocated &buf) = 0;
virtual void tun_error(const Error::Type fatal_err, const std::string &err_text) = 0; virtual void tun_error(const Error::Type fatal_err, const std::string &err_text) = 0;