Fixed gcc-4.7 warnings

pull/16/merge
Tatsuhiro Tsujikawa 2012-04-08 03:12:29 +09:00
parent fcbdecfd1e
commit d9bb24a2e0
4 changed files with 18 additions and 13 deletions

View File

@ -36,6 +36,7 @@
#define D_DHT_CONNECTION_H
#include "common.h"
#include <sys/types.h>
#include <string>
namespace aria2 {

View File

@ -159,11 +159,13 @@ decodeString(InputIterator first, InputIterator last)
checkEof(first, last);
uint16_t codepoint = util::parseUInt(std::string(uchars, first), 16);
if(codepoint <= 0x007fu) {
unsigned char temp[1] = { static_cast<char>(codepoint) };
unsigned char temp[1];
temp[0] = static_cast<char>(codepoint);
s.append(&temp[0], &temp[sizeof(temp)]);
} else if(codepoint <= 0x07ffu) {
unsigned char temp[2] = { 0xC0u | (codepoint >> 6),
0x80u | (codepoint & 0x003fu) };
unsigned char temp[2];
temp[0] = 0xC0u | (codepoint >> 6);
temp[1] = 0x80u | (codepoint & 0x003fu);
s.append(&temp[0], &temp[sizeof(temp)]);
} else if(in(codepoint, 0xD800u, 0xDBFFu)) {
// surrogate pair
@ -186,15 +188,17 @@ decodeString(InputIterator first, InputIterator last)
uint32_t fullcodepoint = 0x010000u;
fullcodepoint += (codepoint & 0x03FFu) << 10;
fullcodepoint += (codepoint2 & 0x03FFu);
unsigned char temp[4] = { 0xf0u | (fullcodepoint >> 18),
0x80u | ((fullcodepoint >> 12) & 0x003Fu),
0x80u | ((fullcodepoint >> 6) & 0x003Fu),
0x80u | (fullcodepoint & 0x003Fu) };
unsigned char temp[4];
temp[0] = 0xf0u | (fullcodepoint >> 18);
temp[1] = 0x80u | ((fullcodepoint >> 12) & 0x003Fu);
temp[2] = 0x80u | ((fullcodepoint >> 6) & 0x003Fu);
temp[3] = 0x80u | (fullcodepoint & 0x003Fu);
s.append(&temp[0], &temp[sizeof(temp)]);
} else {
unsigned char temp[3] = { 0xE0u | (codepoint >> 12),
0x80u | ((codepoint >> 6) & 0x003Fu),
0x80u | (codepoint & 0x003Fu) };
unsigned char temp[3];
temp[0] = 0xE0u | (codepoint >> 12);
temp[1] = 0x80u | ((codepoint >> 6) & 0x003Fu);
temp[2] = 0x80u | (codepoint & 0x003Fu);
s.append(&temp[0], &temp[sizeof(temp)]);
}
offset = first;

View File

@ -78,7 +78,7 @@ public:
std::string getExtensionMessageID(const std::string& name)
{
char id[1] = { registry_->getExtensionMessageID(name) };
unsigned char id[1] = { registry_->getExtensionMessageID(name) };
return std::string(&id[0], &id[1]);
}
@ -105,7 +105,7 @@ void DefaultExtensionMessageFactoryTest::testCreateMessage_unknown()
{
peer_->setExtension("foo", 255);
char id[1] = { 255 };
unsigned char id[1] = { 255 };
std::string data = std::string(&id[0], &id[1]);
try {

View File

@ -100,7 +100,7 @@ void JsonTest::testDecode()
const List* list = downcast<List>(r);
CPPUNIT_ASSERT(list);
const String* s = downcast<String>(list->get(0));
const char arr[] = { 0xF0u, 0xA4u, 0xADu, 0xA2u };
const unsigned char arr[] = { 0xF0u, 0xA4u, 0xADu, 0xA2u };
CPPUNIT_ASSERT_EQUAL(std::string(vbegin(arr), vend(arr)), s->s());
}
{