Skip to content

Commit

Permalink
Add default virtual destructors to base classes with virtual functions
Browse files Browse the repository at this point in the history
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 <[email protected]>
(cherry picked from commit 6217fa0)
  • Loading branch information
Razvan Cojocaru authored and dsommers committed Aug 20, 2024
1 parent 8ced530 commit 6b56849
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 2 deletions.
3 changes: 2 additions & 1 deletion openvpn/buffer/bufcomplete.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@ namespace openvpn {
class BufferComplete
{
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)
{
while (size)
Expand Down
12 changes: 11 additions & 1 deletion openvpn/buffer/buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
if (index >= size_)
Expand Down
2 changes: 2 additions & 0 deletions openvpn/buffer/buflimit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class BufferLimit
reset();
}

virtual ~BufferLimit() = default;

void set_max(const T max_lines_arg,
const T max_bytes_arg)
{
Expand Down
2 changes: 2 additions & 0 deletions openvpn/client/clilife.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class ClientLifeCycle : public RC<thread_unsafe_refcount>
public:
struct NotifyCallback
{
virtual ~NotifyCallback() = default;

virtual void cln_stop() = 0;
virtual void cln_pause(const std::string &reason) = 0;
virtual void cln_resume() = 0;
Expand Down
2 changes: 2 additions & 0 deletions openvpn/client/cliproto.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ namespace openvpn::ClientProto {

struct NotifyCallback
{
virtual ~NotifyCallback() = default;

virtual void client_proto_terminate() = 0;
virtual void client_proto_connected()
{
Expand Down
6 changes: 6 additions & 0 deletions openvpn/client/remotelist.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ class RemoteList : public RC<thread_unsafe_refcount>
{
typedef RCPtr<ConnBlockFactory> Ptr;

virtual ~ConnBlockFactory() = default;

virtual ConnBlock::Ptr new_conn_block(const OptionList::Ptr &opt) = 0;
};

Expand Down Expand Up @@ -229,6 +231,8 @@ class RemoteList : public RC<thread_unsafe_refcount>

struct RemoteOverride
{
virtual ~RemoteOverride() = default;

virtual Item::Ptr get() = 0;
};

Expand Down Expand Up @@ -311,6 +315,8 @@ class RemoteList : public RC<thread_unsafe_refcount>

struct NotifyCallback
{
virtual ~NotifyCallback() = default;

// client callback when resolve operation is complete
virtual void bulk_resolve_done() = 0;
};
Expand Down
2 changes: 2 additions & 0 deletions openvpn/ssl/proto.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ enum
class ProtoContextCallbackInterface
{
public:
virtual ~ProtoContextCallbackInterface() = default;

/**
* Sends out bytes to the network.
*/
Expand Down
2 changes: 2 additions & 0 deletions openvpn/transport/reconnect_notify.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ namespace openvpn {
class ReconnectNotify
{
public:
virtual ~ReconnectNotify() = default;

// When a connection is close to timeout, the core will call this
// method. If it returns false, the core will disconnect with a
// CONNECTION_TIMEOUT event. If true, the core will enter a PAUSE
Expand Down
2 changes: 2 additions & 0 deletions openvpn/transport/socket_protect.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ namespace openvpn {
class BaseSocketProtect
{
public:
virtual ~BaseSocketProtect() = default;

virtual bool socket_protect(openvpn_io::detail::socket_type socket, IP::Addr endpoint) = 0;
};

Expand Down
2 changes: 2 additions & 0 deletions openvpn/tun/client/tunbase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ struct TunClient : public virtual RC<thread_unsafe_refcount>
// special events, and progress notifications.
struct TunClientParent
{
virtual ~TunClientParent() = default;

virtual void tun_recv(BufferAllocated &buf) = 0;
virtual void tun_error(const Error::Type fatal_err, const std::string &err_text) = 0;

Expand Down

0 comments on commit 6b56849

Please sign in to comment.