From 2fba5ca47896c28da1b42bcb927565c3bf0e7a74 Mon Sep 17 00:00:00 2001 From: Peter Thorson Date: Fri, 24 Feb 2012 07:36:29 -0600 Subject: [PATCH] uses union instead of reinterpret_cast --- src/messages/control.hpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/messages/control.hpp b/src/messages/control.hpp index fcd3b8c456..6dd6ac72b5 100644 --- a/src/messages/control.hpp +++ b/src/messages/control.hpp @@ -143,12 +143,12 @@ private: throw processor::exception("get_raw_close_code called with invalid size",processor::error::FATAL_ERROR); } - char val[2]; - - val[0] = m_payload[0]; - val[1] = m_payload[1]; - - return ntohs(*(reinterpret_cast(&val[0]))); + union {uint16_t i;char c[2];} val; + + val.c[0] = m_payload[0]; + val.c[1] = m_payload[1]; + + return ntohs(val.i); } static const uint64_t PAYLOAD_SIZE_INIT = 128; // 128B