IOS/USB: Fix -Winvalid-offset warnings

Unfortunately, compilers will issue warnings when using offsetof with
non-standard layout types even when offsetof actually works fine here;
just having a virtual function is enough to trigger the warning...

Let's just stop the scan threads explicitly in destructors instead of
relying on member destruction order.
This commit is contained in:
Léo Lam 2020-10-24 13:56:35 +02:00
parent 285b926e92
commit 8b9a0c9e09
No known key found for this signature in database
GPG Key ID: 0DF30F9081000741
6 changed files with 20 additions and 12 deletions

View File

@ -24,8 +24,11 @@ namespace IOS::HLE::Device
{
OH0::OH0(Kernel& ios, const std::string& device_name) : USBHost(ios, device_name)
{
static_assert(offsetof(OH0, m_scan_thread) == sizeof(OH0) - sizeof(ScanThread),
"ScanThread must be the last data member");
}
OH0::~OH0()
{
m_scan_thread.Stop();
}
IPCCommandResult OH0::Open(const OpenRequest& request)

View File

@ -37,6 +37,7 @@ class OH0 final : public USBHost
{
public:
OH0(Kernel& ios, const std::string& device_name);
~OH0() override;
IPCCommandResult Open(const OpenRequest& request) override;
IPCCommandResult IOCtl(const IOCtlRequest& request) override;

View File

@ -24,8 +24,11 @@ namespace IOS::HLE::Device
{
USB_HIDv4::USB_HIDv4(Kernel& ios, const std::string& device_name) : USBHost(ios, device_name)
{
static_assert(offsetof(USB_HIDv4, m_scan_thread) == sizeof(USB_HIDv4) - sizeof(ScanThread),
"ScanThread must be the last data member");
}
USB_HIDv4::~USB_HIDv4()
{
m_scan_thread.Stop();
}
IPCCommandResult USB_HIDv4::IOCtl(const IOCtlRequest& request)

View File

@ -22,6 +22,7 @@ class USB_HIDv4 final : public USBHost
{
public:
USB_HIDv4(Kernel& ios, const std::string& device_name);
~USB_HIDv4() override;
IPCCommandResult IOCtl(const IOCtlRequest& request) override;

View File

@ -18,13 +18,13 @@ namespace IOS::HLE::Device
{
constexpr u32 USBV5_VERSION = 0x50001;
USB_HIDv5::~USB_HIDv5() = default;
USB_HIDv5::~USB_HIDv5()
{
m_scan_thread.Stop();
}
IPCCommandResult USB_HIDv5::IOCtl(const IOCtlRequest& request)
{
static_assert(offsetof(USB_HIDv5, m_scan_thread) == sizeof(USB_HIDv5) - sizeof(ScanThread),
"ScanThread must be the last data member");
request.Log(GetDeviceName(), Common::Log::IOS_USB);
switch (request.request)
{

View File

@ -18,13 +18,13 @@ namespace IOS::HLE::Device
{
constexpr u32 USBV5_VERSION = 0x50001;
USB_VEN::~USB_VEN() = default;
USB_VEN::~USB_VEN()
{
m_scan_thread.Stop();
}
IPCCommandResult USB_VEN::IOCtl(const IOCtlRequest& request)
{
static_assert(offsetof(USB_VEN, m_scan_thread) == sizeof(USB_VEN) - sizeof(ScanThread),
"ScanThread must be the last data member");
request.Log(GetDeviceName(), Common::Log::IOS_USB);
switch (request.request)
{