summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2012-04-08 03:12:29 +0900
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2012-04-08 03:12:29 +0900
commitd9bb24a2e090febb6ff152ca3db075eab5f724fb (patch)
tree9d530736fb6e6fa35b5e03d13eaed6680ee03ccd
parentfcbdecfd1e6aaa92cb1769ed1d395d59648ad5a6 (diff)
Fixed gcc-4.7 warnings
-rw-r--r--src/DHTConnection.h1
-rw-r--r--src/json.cc24
-rw-r--r--test/DefaultExtensionMessageFactoryTest.cc4
-rw-r--r--test/JsonTest.cc2
4 files changed, 18 insertions, 13 deletions
diff --git a/src/DHTConnection.h b/src/DHTConnection.h
index e269794d..cd718a74 100644
--- a/src/DHTConnection.h
+++ b/src/DHTConnection.h
@@ -36,6 +36,7 @@
#define D_DHT_CONNECTION_H
#include "common.h"
+#include <sys/types.h>
#include <string>
namespace aria2 {
diff --git a/src/json.cc b/src/json.cc
index 9094bcbb..81341ee6 100644
--- a/src/json.cc
+++ b/src/json.cc
@@ -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;
diff --git a/test/DefaultExtensionMessageFactoryTest.cc b/test/DefaultExtensionMessageFactoryTest.cc
index cad5037b..81de2036 100644
--- a/test/DefaultExtensionMessageFactoryTest.cc
+++ b/test/DefaultExtensionMessageFactoryTest.cc
@@ -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 {
diff --git a/test/JsonTest.cc b/test/JsonTest.cc
index 7810724d..79e4a5d8 100644
--- a/test/JsonTest.cc
+++ b/test/JsonTest.cc
@@ -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());
}
{