From abb33637a3b7e571dbe2e2b842edd8fe8523002a Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 1 Apr 2018 15:27:58 -0400 Subject: [PATCH 1/3] IOS/Socket: In-class initialize WiiSocket members --- Source/Core/Core/IOS/Network/Socket.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Core/Core/IOS/Network/Socket.h b/Source/Core/Core/IOS/Network/Socket.h index c02cd2ee43..733ba65f71 100644 --- a/Source/Core/Core/IOS/Network/Socket.h +++ b/Source/Core/Core/IOS/Network/Socket.h @@ -185,9 +185,9 @@ class WiiSocket }; private: - s32 fd; - s32 wii_fd; - bool nonBlock; + s32 fd = -1; + s32 wii_fd = -1; + bool nonBlock = false; std::list pending_sockops; friend class WiiSockMan; @@ -201,7 +201,7 @@ private: void Update(bool read, bool write, bool except); bool IsValid() const { return fd >= 0; } public: - WiiSocket() : fd(-1), nonBlock(false) {} + WiiSocket() = default; ~WiiSocket(); void operator=(WiiSocket const&) = delete; }; From ad575a15564a393cee3002684fa47bfc178e838a Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 1 Apr 2018 15:29:00 -0400 Subject: [PATCH 2/3] IOS/Socket: Place WiiSocket's private interface below the public interface In the rest of the codebase we try to position the private interface below the public interface (unless it's otherwise not possible). --- Source/Core/Core/IOS/Network/Socket.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Source/Core/Core/IOS/Network/Socket.h b/Source/Core/Core/IOS/Network/Socket.h index 733ba65f71..028f70022d 100644 --- a/Source/Core/Core/IOS/Network/Socket.h +++ b/Source/Core/Core/IOS/Network/Socket.h @@ -173,6 +173,12 @@ struct WiiSockAddrIn class WiiSocket { +public: + WiiSocket() = default; + ~WiiSocket(); + void operator=(WiiSocket const&) = delete; + +private: struct sockop { Request request; @@ -184,12 +190,6 @@ class WiiSocket }; }; -private: - s32 fd = -1; - s32 wii_fd = -1; - bool nonBlock = false; - std::list pending_sockops; - friend class WiiSockMan; void SetFd(s32 s); void SetWiiFd(s32 s); @@ -200,10 +200,10 @@ private: void DoSock(Request request, SSL_IOCTL type); void Update(bool read, bool write, bool except); bool IsValid() const { return fd >= 0; } -public: - WiiSocket() = default; - ~WiiSocket(); - void operator=(WiiSocket const&) = delete; + s32 fd = -1; + s32 wii_fd = -1; + bool nonBlock = false; + std::list pending_sockops; }; class WiiSockMan From ad17d9a9799f581f734963699e4ab135726cb308 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 1 Apr 2018 15:32:33 -0400 Subject: [PATCH 3/3] IOS/Socket: Delete WiiSocket's copy constructor If the copy assignment operator is deleted, then the copy constructor should be deleted as well, otherwise it's a hole in the API where copies can be made (and if this were an intended case, it should be documented). So we delete the copy constructor and explicitly default the move assignment and move constructor to signify this is intended to be a move-only type. --- Source/Core/Core/IOS/Network/Socket.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Source/Core/Core/IOS/Network/Socket.h b/Source/Core/Core/IOS/Network/Socket.h index 028f70022d..7299de5429 100644 --- a/Source/Core/Core/IOS/Network/Socket.h +++ b/Source/Core/Core/IOS/Network/Socket.h @@ -175,8 +175,11 @@ class WiiSocket { public: WiiSocket() = default; + WiiSocket(const WiiSocket&) = delete; + WiiSocket(WiiSocket&&) = default; ~WiiSocket(); - void operator=(WiiSocket const&) = delete; + WiiSocket& operator=(const WiiSocket&) = delete; + WiiSocket& operator=(WiiSocket&&) = default; private: struct sockop