Several corrections to make sure code compiles with gcc and doesn't generate warnings
Change-Id: I63e72ba724233953e9f36b11eca37070d6e06372
diff --git a/ccnx/ccnx-name.cpp b/ccnx/ccnx-name.cpp
index b7b04a6..55d434b 100644
--- a/ccnx/ccnx-name.cpp
+++ b/ccnx/ccnx-name.cpp
@@ -105,7 +105,7 @@
Name::Name(const unsigned char *data, const ccn_indexbuf *comps)
{
- for (int i = 0; i < comps->n - 1; i++)
+ for (unsigned int i = 0; i < comps->n - 1; i++)
{
const unsigned char *compPtr;
size_t size;
@@ -284,10 +284,15 @@
const Bytes &
Name::getComp(int index) const
{
- if (index >= m_comps.size())
- {
- boost::throw_exception(NameException() << error_info_str("Index out of range: " + boost::lexical_cast<string>(index)));
- }
+ if (index < 0)
+ {
+ boost::throw_exception(NameException() << error_info_str("Negative index: " + boost::lexical_cast<string>(index)));
+ }
+
+ if (static_cast<unsigned int> (index) >= m_comps.size())
+ {
+ boost::throw_exception(NameException() << error_info_str("Index out of range: " + boost::lexical_cast<string>(index)));
+ }
return m_comps[index];
}
diff --git a/src/hash-helper.h b/src/hash-helper.h
index 41a8b8a..86b87c9 100644
--- a/src/hash-helper.h
+++ b/src/hash-helper.h
@@ -111,7 +111,7 @@
if (m_length > otherHash.m_length)
return false;
- for (int i = 0; i < m_length; i++)
+ for (unsigned int i = 0; i < m_length; i++)
{
if (m_buf [i] < otherHash.m_buf [i])
return true;
diff --git a/src/sync-log.cc b/src/sync-log.cc
index 47b1adf..5881bd9 100644
--- a/src/sync-log.cc
+++ b/src/sync-log.cc
@@ -32,10 +32,10 @@
using namespace std;
using namespace Ccnx;
-static void xTrace (void*, const char* q)
-{
- cout << q << endl;
-}
+// static void xTrace (void*, const char* q)
+// {
+// cout << q << endl;
+// }
const std::string INIT_DATABASE = "\
CREATE TABLE \n\
diff --git a/wscript b/wscript
index 47255a6..084d764 100644
--- a/wscript
+++ b/wscript
@@ -55,10 +55,12 @@
if conf.options.debug:
conf.define ('_DEBUG', 1)
- conf.env.append_value('CXXFLAGS', ['-O0', '-Wall', '-Wno-unused-variable',
- '-fcolor-diagnostics', '-g3', '-Qunused-arguments'])
+ conf.env.append_value('CXXFLAGS', ['-O0', '-Wall', '-Wno-unused-variable', '-g3'])
else:
- conf.env.append_value('CXXFLAGS', ['-O3', '-g', '-Qunused-arguments'])
+ conf.env.append_value('CXXFLAGS', ['-O3', '-g'])
+
+ if conf.env["CXX"] == ["clang++"]:
+ conf.env.append_value('CXXFLAGS', ['-fcolor-diagnostics', '-Qunused-arguments'])
if conf.options._test:
conf.define ('_TESTS', 1)