From e0336403eee31f31ed969def8d36ddc8cda428c5 Mon Sep 17 00:00:00 2001 From: Weiyi Wang Date: Fri, 21 Sep 2018 20:25:53 -0400 Subject: [PATCH] nwm/uds_connection: specify endiannes for enum --- src/core/hle/service/nwm/uds_connection.cpp | 9 ++++----- src/core/hle/service/nwm/uds_connection.h | 8 ++++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/core/hle/service/nwm/uds_connection.cpp b/src/core/hle/service/nwm/uds_connection.cpp index c74f51253a..e52569287a 100644 --- a/src/core/hle/service/nwm/uds_connection.cpp +++ b/src/core/hle/service/nwm/uds_connection.cpp @@ -15,7 +15,7 @@ constexpr u16 DefaultExtraCapabilities = 0x0431; std::vector GenerateAuthenticationFrame(AuthenticationSeq seq) { AuthenticationFrame frame{}; - frame.auth_seq = static_cast(seq); + frame.auth_seq = seq; std::vector data(sizeof(frame)); std::memcpy(data.data(), &frame, sizeof(frame)); @@ -27,7 +27,7 @@ AuthenticationSeq GetAuthenticationSeqNumber(const std::vector& body) { AuthenticationFrame frame; std::memcpy(&frame, body.data(), sizeof(frame)); - return static_cast(frame.auth_seq); + return frame.auth_seq; } /** @@ -58,7 +58,7 @@ static std::vector GenerateSSIDTag(u32 network_id) { std::vector GenerateAssocResponseFrame(AssocStatus status, u16 association_id, u32 network_id) { AssociationResponseFrame frame{}; frame.capabilities = DefaultExtraCapabilities; - frame.status_code = static_cast(status); + frame.status_code = status; // The association id is ORed with this magic value (0xC000) constexpr u16 AssociationIdMagic = 0xC000; frame.assoc_id = association_id | AssociationIdMagic; @@ -80,8 +80,7 @@ std::tuple GetAssociationResult(const std::vector& body) { memcpy(&frame, body.data(), sizeof(frame)); constexpr u16 AssociationIdMask = 0x3FFF; - return std::make_tuple(static_cast(frame.status_code), - frame.assoc_id & AssociationIdMask); + return std::make_tuple(frame.status_code, frame.assoc_id & AssociationIdMask); } } // namespace NWM diff --git a/src/core/hle/service/nwm/uds_connection.h b/src/core/hle/service/nwm/uds_connection.h index a664f8471b..201d23e3f3 100644 --- a/src/core/hle/service/nwm/uds_connection.h +++ b/src/core/hle/service/nwm/uds_connection.h @@ -23,16 +23,16 @@ enum class AuthStatus : u16 { Successful = 0 }; enum class AssocStatus : u16 { Successful = 0 }; struct AuthenticationFrame { - u16_le auth_algorithm = static_cast(AuthAlgorithm::OpenSystem); - u16_le auth_seq; - u16_le status_code = static_cast(AuthStatus::Successful); + enum_le auth_algorithm = AuthAlgorithm::OpenSystem; + enum_le auth_seq; + enum_le status_code = AuthStatus::Successful; }; static_assert(sizeof(AuthenticationFrame) == 6, "AuthenticationFrame has wrong size"); struct AssociationResponseFrame { u16_le capabilities; - u16_le status_code; + enum_le status_code; u16_le assoc_id; };