Merge pull request #95 from blindmatrix/76296fe2dd49c55d85f818005ea9bb6901807c79

Fixed compile-time warnings
This commit is contained in:
Peter Thorson
2012-03-18 11:42:21 -07:00
3 changed files with 13 additions and 17 deletions

View File

@@ -550,11 +550,9 @@ public:
}
// set close payload
char val[3];
*reinterpret_cast<uint16_t*>(&val[0]) = htons(code);
val[2] = 0x00;
const uint16_t payload = htons(code);
msg->set_payload(std::string(val));
msg->set_payload(std::string(reinterpret_cast<const char*>(&payload), 2));
msg->append_payload(reason);
// prepare rest of frame

View File

@@ -62,12 +62,10 @@ public:
char key_final[16];
// copy key1 into final key
*reinterpret_cast<uint32_t*>(&key_final[0]) =
decode_client_key(request.header("Sec-WebSocket-Key1"));
decode_client_key(request.header("Sec-WebSocket-Key1"), &key_final[0]);
// copy key2 into final key
*reinterpret_cast<uint32_t*>(&key_final[4]) =
decode_client_key(request.header("Sec-WebSocket-Key2"));
decode_client_key(request.header("Sec-WebSocket-Key2"), &key_final[4]);
// copy key3 into final key
memcpy(&key_final[8],request.header("Sec-WebSocket-Key3").c_str(),8);
@@ -292,7 +290,7 @@ public:
}
private:
uint32_t decode_client_key(const std::string& key) {
void decode_client_key(const std::string& key, char* result) {
int spaces = 0;
std::string digits = "";
uint32_t num;
@@ -308,9 +306,10 @@ private:
num = atoi(digits.c_str());
if (spaces > 0 && num > 0) {
return htonl(num/spaces);
num = htonl(num/spaces);
memcpy(result, reinterpret_cast<char*>(&num), 4);
} else {
return 0;
memset(result, 0, 4);
}
}

View File

@@ -334,12 +334,11 @@ public:
if (get_payload_size() == 0) {
return close::status::NO_STATUS;
} else if (get_payload_size() >= 2) {
char val[2];
val[0] = m_payload[0];
val[1] = m_payload[1];
uint16_t code = ntohs(*(reinterpret_cast<uint16_t*>(&val[0])));
char val[2] = { m_payload[0], m_payload[1] };
uint16_t code;
memcpy(&code, val, sizeof(code));
code = ntohs(code);
return close::status::value(code);
} else {