Commit ae67c778 authored by Frediano Ziglio's avatar Frediano Ziglio

Declare virtual destructor to avoid a warning

GCC gives this warning:

.../plugin.hpp:103:7: warning: ‘class spice::streaming_agent::Agent’ has virtual functions and accessible non-virtual destructor [-Wnon-virtual-dtor]
103 | class Agent
    |       ^~~~~

Although in this case is not an issue (the class is planned to be
inherited only once and destructor not be called from base class)
add virtual destructor. Declare protected to avoid plugins to call
delete on the Agent.

The destructor is declared at the end to avoid changing ABI.
Currently we supported and released only GCC compiler where the
vtable has this layout:

Without the patch:

RELOCATION RECORDS FOR [.data.rel.ro.local._ZTVN5spice15streaming_agent13ConcreteAgentE]:
OFFSET           TYPE              VALUE
0000000000000008 R_X86_64_64       typeinfo for spice::streaming_agent::ConcreteAgent
0000000000000010 R_X86_64_64       spice::streaming_agent::ConcreteAgent::Register(std::shared_ptr<spice::streaming_agent::Plugin> const&)
0000000000000018 R_X86_64_64       spice::streaming_agent::ConcreteAgent::Options() const
0000000000000020 R_X86_64_64       spice::streaming_agent::ConcreteAgent::LogStat(char const*, ...)

Destructor at the beginning of the class:

RELOCATION RECORDS FOR [.data.rel.ro.local._ZTVN5spice15streaming_agent13ConcreteAgentE]:
OFFSET           TYPE              VALUE
0000000000000008 R_X86_64_64       typeinfo for spice::streaming_agent::ConcreteAgent
0000000000000010 R_X86_64_64       spice::streaming_agent::ConcreteAgent::~ConcreteAgent()
0000000000000018 R_X86_64_64       spice::streaming_agent::ConcreteAgent::~ConcreteAgent()
0000000000000020 R_X86_64_64       spice::streaming_agent::ConcreteAgent::Register(std::shared_ptr<spice::streaming_agent::Plugin> const&)
0000000000000028 R_X86_64_64       spice::streaming_agent::ConcreteAgent::Options() const
0000000000000030 R_X86_64_64       spice::streaming_agent::ConcreteAgent::LogStat(char const*, ...)

Destructor at the end of the class:

RELOCATION RECORDS FOR [.data.rel.ro.local._ZTVN5spice15streaming_agent13ConcreteAgentE]:
OFFSET           TYPE              VALUE
0000000000000008 R_X86_64_64       typeinfo for spice::streaming_agent::ConcreteAgent
0000000000000010 R_X86_64_64       spice::streaming_agent::ConcreteAgent::Register(std::shared_ptr<spice::streaming_agent::Plugin> const&)
0000000000000018 R_X86_64_64       spice::streaming_agent::ConcreteAgent::Options() const
0000000000000020 R_X86_64_64       spice::streaming_agent::ConcreteAgent::LogStat(char const*, ...)
0000000000000028 R_X86_64_64       spice::streaming_agent::ConcreteAgent::~ConcreteAgent()
0000000000000030 R_X86_64_64       spice::streaming_agent::ConcreteAgent::~ConcreteAgent()

As you can see offsets do not change declaring destructor at the end
while they change putting declaration at the beginning.
Signed-off-by: Frediano Ziglio's avatarFrediano Ziglio <fziglio@redhat.com>
Acked-by: Kevin Pouget's avatarKevin Pouget <kpouget@redhat.com>
parent 7570624f
Pipeline #122226 passed with stage
in 7 minutes and 32 seconds