src: Fixing signed/unsigned comparison warnings and removing all warning-suppressing pragmas
Change-Id: I5526a00d9be6d576bb500d51c0bc6c2ad8cc541d
diff --git a/src/encoding/block.cpp b/src/encoding/block.cpp
index 0785ec0..5656b61 100644
--- a/src/encoding/block.cpp
+++ b/src/encoding/block.cpp
@@ -43,7 +43,7 @@
m_type = Tlv::readType(m_value_begin, m_value_end);
uint64_t length = Tlv::readVarNumber(m_value_begin, m_value_end);
- if (length != (m_value_end - m_value_begin))
+ if (length != static_cast<uint64_t>(m_value_end - m_value_begin))
{
throw Tlv::Error("TLV length doesn't match buffer length");
}
@@ -60,7 +60,7 @@
m_type = Tlv::readType(m_value_begin, m_value_end);
uint64_t length = Tlv::readVarNumber(m_value_begin, m_value_end);
- if (length != (m_value_end - m_value_begin))
+ if (length != static_cast<uint64_t>(m_value_end - m_value_begin))
{
throw Tlv::Error("TLV length doesn't match buffer length");
}
@@ -84,7 +84,7 @@
buf[0] = *tmp_begin;
is.read(buf+1, length-1);
- if(length-1 != is.gcount())
+ if(length != static_cast<uint64_t>(is.gcount())+1)
{
delete [] buf;
throw Tlv::Error("Not enough data in the buffer to fully parse TLV");
@@ -112,7 +112,7 @@
m_type = Tlv::readType(tmp_begin, tmp_end);
uint64_t length = Tlv::readVarNumber(tmp_begin, tmp_end);
- if (length > (tmp_end - tmp_begin))
+ if (length > static_cast<uint64_t>(tmp_end - tmp_begin))
{
throw Tlv::Error("Not enough data in the buffer to fully parse TLV");
}
@@ -137,7 +137,7 @@
m_type = Tlv::readType(tmp_begin, tmp_end);
uint64_t length = Tlv::readVarNumber(tmp_begin, tmp_end);
- if (length > (tmp_end - tmp_begin))
+ if (length > static_cast<uint64_t>(tmp_end - tmp_begin))
{
throw Tlv::Error("Not enough data in the buffer to fully parse TLV");
}
@@ -195,7 +195,7 @@
uint32_t type = Tlv::readType(begin, end);
uint64_t length = Tlv::readVarNumber(begin, end);
- if (end-begin < length)
+ if (length > static_cast<uint64_t>(end - begin))
{
m_subBlocks.clear();
throw Tlv::Error("TLV length exceeds buffer length");
@@ -280,7 +280,7 @@
uint32_t type = Tlv::readType(begin, end);
uint64_t length = Tlv::readVarNumber(begin, end);
- if (end-begin != length)
+ if (length != static_cast<uint64_t>(end - begin))
throw Tlv::Error("TLV length mismatches buffer length");
return Block(m_buffer,
diff --git a/src/encoding/cryptopp/asn_ext.hpp b/src/encoding/cryptopp/asn_ext.hpp
index d344edc..e0a9a6b 100644
--- a/src/encoding/cryptopp/asn_ext.hpp
+++ b/src/encoding/cryptopp/asn_ext.hpp
@@ -9,19 +9,6 @@
#ifndef NDN_ASN_EXT_HPP
#define NDN_ASN_EXT_HPP
-#if __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wreorder"
-#pragma clang diagnostic ignored "-Wtautological-compare"
-#pragma clang diagnostic ignored "-Wunused-variable"
-#pragma clang diagnostic ignored "-Wunused-function"
-#elif __GNUC__
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wreorder"
-#pragma GCC diagnostic ignored "-Wunused-variable"
-#pragma GCC diagnostic ignored "-Wunused-function"
-#endif
-
#include <stdexcept>
#include "../../common.hpp"
#include <cryptopp/asn.h>
diff --git a/src/encoding/oid.cpp b/src/encoding/oid.cpp
index d1504e1..d023f82 100644
--- a/src/encoding/oid.cpp
+++ b/src/encoding/oid.cpp
@@ -5,19 +5,6 @@
* See COPYING for copyright and distribution information.
*/
-#if __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wreorder"
-#pragma clang diagnostic ignored "-Wtautological-compare"
-#pragma clang diagnostic ignored "-Wunused-variable"
-#pragma clang diagnostic ignored "-Wunused-function"
-#elif __GNUC__
-#pragma GCC diagnostic ignored "-Wreorder"
-#pragma GCC diagnostic ignored "-Wtautological-compare"
-#pragma GCC diagnostic ignored "-Wunused-variable"
-#pragma GCC diagnostic ignored "-Wunused-function"
-#endif
-
#include <stdlib.h>
#include <sstream>
diff --git a/src/key-locator.hpp b/src/key-locator.hpp
index 2ff85f0..a3fb896 100644
--- a/src/key-locator.hpp
+++ b/src/key-locator.hpp
@@ -18,7 +18,7 @@
struct Error : public std::runtime_error { Error(const std::string &what) : std::runtime_error(what) {} };
enum {
- KeyLocator_None = -1,
+ KeyLocator_None = 4294967295,
KeyLocator_Name = 0,
KeyLocator_Unknown = 255
diff --git a/src/security/certificate-extension.cpp b/src/security/certificate-extension.cpp
index 4864a6b..f876823 100644
--- a/src/security/certificate-extension.cpp
+++ b/src/security/certificate-extension.cpp
@@ -6,18 +6,6 @@
* See COPYING for copyright and distribution information.
*/
-#if __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wreorder"
-#pragma clang diagnostic ignored "-Wtautological-compare"
-#pragma clang diagnostic ignored "-Wunused-variable"
-#pragma clang diagnostic ignored "-Wunused-function"
-#elif __GNUC__
-#pragma GCC diagnostic ignored "-Wreorder"
-#pragma GCC diagnostic ignored "-Wunused-variable"
-#pragma GCC diagnostic ignored "-Wunused-function"
-#endif
-
#include "security/certificate-extension.hpp"
#include <cryptopp/asn.h>
diff --git a/src/security/certificate-subject-description.cpp b/src/security/certificate-subject-description.cpp
index 73c0c1b..fc6156f 100644
--- a/src/security/certificate-subject-description.cpp
+++ b/src/security/certificate-subject-description.cpp
@@ -6,18 +6,6 @@
* See COPYING for copyright and distribution information.
*/
-#if __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wreorder"
-#pragma clang diagnostic ignored "-Wtautological-compare"
-#pragma clang diagnostic ignored "-Wunused-variable"
-#pragma clang diagnostic ignored "-Wunused-function"
-#elif __GNUC__
-#pragma GCC diagnostic ignored "-Wreorder"
-#pragma GCC diagnostic ignored "-Wunused-variable"
-#pragma GCC diagnostic ignored "-Wunused-function"
-#endif
-
#include "security/certificate-subject-description.hpp"
#include <cryptopp/asn.h>
diff --git a/src/security/certificate.cpp b/src/security/certificate.cpp
index e94f962..3a3b224 100644
--- a/src/security/certificate.cpp
+++ b/src/security/certificate.cpp
@@ -6,18 +6,6 @@
* See COPYING for copyright and distribution information.
*/
-#if __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wreorder"
-#pragma clang diagnostic ignored "-Wtautological-compare"
-#pragma clang diagnostic ignored "-Wunused-variable"
-#pragma clang diagnostic ignored "-Wunused-function"
-#elif __GNUC__
-#pragma GCC diagnostic ignored "-Wreorder"
-#pragma GCC diagnostic ignored "-Wunused-variable"
-#pragma GCC diagnostic ignored "-Wunused-function"
-#endif
-
#include "common.hpp"
#include "security/certificate.hpp"
diff --git a/src/security/public-key.cpp b/src/security/public-key.cpp
index c1cb84d..27992ca 100644
--- a/src/security/public-key.cpp
+++ b/src/security/public-key.cpp
@@ -6,18 +6,6 @@
* See COPYING for copyright and distribution information.
*/
-#if __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wreorder"
-#pragma clang diagnostic ignored "-Wtautological-compare"
-#pragma clang diagnostic ignored "-Wunused-variable"
-#pragma clang diagnostic ignored "-Wunused-function"
-#elif __GNUC__
-#pragma GCC diagnostic ignored "-Wreorder"
-#pragma GCC diagnostic ignored "-Wunused-variable"
-#pragma GCC diagnostic ignored "-Wunused-function"
-#endif
-
#include "common.hpp"
#include "security/public-key.hpp"
diff --git a/src/security/validator.cpp b/src/security/validator.cpp
index 9440d84..62289f5 100644
--- a/src/security/validator.cpp
+++ b/src/security/validator.cpp
@@ -6,18 +6,6 @@
* See COPYING for copyright and distribution information.
*/
-#if __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wreorder"
-#pragma clang diagnostic ignored "-Wtautological-compare"
-#pragma clang diagnostic ignored "-Wunused-variable"
-#pragma clang diagnostic ignored "-Wunused-function"
-#elif __GNUC__
-#pragma GCC diagnostic ignored "-Wreorder"
-#pragma GCC diagnostic ignored "-Wunused-variable"
-#pragma GCC diagnostic ignored "-Wunused-function"
-#endif
-
#include "validator.hpp"
#include "../util/logging.hpp"
diff --git a/src/util/random.cpp b/src/util/random.cpp
index 5ef2ffc..f1cb5b9 100644
--- a/src/util/random.cpp
+++ b/src/util/random.cpp
@@ -6,18 +6,6 @@
#include "random.hpp"
-#if __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wreorder"
-#pragma clang diagnostic ignored "-Wtautological-compare"
-#pragma clang diagnostic ignored "-Wunused-variable"
-#pragma clang diagnostic ignored "-Wunused-function"
-#elif __GNUC__
-#pragma GCC diagnostic ignored "-Wreorder"
-#pragma GCC diagnostic ignored "-Wunused-variable"
-#pragma GCC diagnostic ignored "-Wunused-function"
-#endif
-
#include <cryptopp/osrng.h>
namespace ndn {