src: Enabling -Werror in debug mode and some style updates
Several important warnings are still getting suppressed, because of
CryptoPP library
Change-Id: I8fb3d938544ecc38c65529262504dc753124bafd
diff --git a/src/security/identity-certificate.cpp b/src/security/identity-certificate.cpp
index 5fddbfc..b4d5cb5 100644
--- a/src/security/identity-certificate.cpp
+++ b/src/security/identity-certificate.cpp
@@ -17,9 +17,8 @@
bool
IdentityCertificate::isCorrectName(const Name& name)
{
- int i = name.size() - 1;
-
string idString("ID-CERT");
+ int i = name.size() - 1;
for (; i >= 0; i--) {
if(name.get(i).toEscapedString() == idString)
break;
@@ -28,7 +27,7 @@
if (i < 0)
return false;
- int keyIdx = 0;
+ size_t keyIdx = 0;
string keyString("KEY");
for (; keyIdx < name.size(); keyIdx++) {
if(name.get(keyIdx).toEscapedString() == keyString)
@@ -59,11 +58,11 @@
Name
IdentityCertificate::certificateNameToPublicKeyName(const Name& certificateName)
{
- int i = certificateName.size() - 1;
string idString("ID-CERT");
bool foundIdString = false;
- for (; i >= 0; i--) {
- if (certificateName.get(i).toEscapedString() == idString)
+ size_t idCertComponentIndex = certificateName.size() - 1;
+ for (; idCertComponentIndex + 1 > 0; --idCertComponentIndex) {
+ if (certificateName.get(idCertComponentIndex).toEscapedString() == idString)
{
foundIdString = true;
break;
@@ -73,11 +72,12 @@
if(!foundIdString)
throw Error("Incorrect identity certificate name " + certificateName.toUri());
- Name tmpName = certificateName.getSubName(0, i);
+ Name tmpName = certificateName.getSubName(0, idCertComponentIndex);
string keyString("KEY");
bool foundKeyString = false;
- for (i = 0; i < tmpName.size(); i++) {
- if (tmpName.get(i).toEscapedString() == keyString)
+ size_t keyComponentIndex = 0;
+ for (; keyComponentIndex < tmpName.size(); keyComponentIndex++) {
+ if (tmpName.get(keyComponentIndex).toEscapedString() == keyString)
{
foundKeyString = true;
break;
@@ -86,8 +86,11 @@
if(!foundKeyString)
throw Error("Incorrect identity certificate name " + certificateName.toUri());
-
- return tmpName.getSubName(0, i).append(tmpName.getSubName(i + 1, tmpName.size() - i - 1));
+
+ return tmpName
+ .getSubName(0, keyComponentIndex)
+ .append(tmpName.getSubName(keyComponentIndex + 1,
+ tmpName.size() - keyComponentIndex - 1));
}
} // namespace ndn
diff --git a/src/security/sec-public-info-sqlite3.cpp b/src/security/sec-public-info-sqlite3.cpp
index aeb34dd..393355f 100644
--- a/src/security/sec-public-info-sqlite3.cpp
+++ b/src/security/sec-public-info-sqlite3.cpp
@@ -337,8 +337,8 @@
// sqlite3_stmt *statement;
// sqlite3_prepare_v2(m_database,
-// "INSERT OR REPLACE INTO Certificate (cert_name, cert_issuer, identity_name, key_identifier, not_before, not_after, certificate_data)\
-// values (?, ?, ?, ?, datetime(?, 'unixepoch'), datetime(?, 'unixepoch'), ?)",
+// "INSERT OR REPLACE INTO Certificate (cert_name, cert_issuer, identity_name, key_identifier, not_before, not_after, certificate_data) "
+// "VALUES (?, ?, ?, ?, datetime(?, 'unixepoch'), datetime(?, 'unixepoch'), ?)",
// -1, &statement, 0);
// _LOG_DEBUG("certName: " << certificateName);
diff --git a/src/security/validator.cpp b/src/security/validator.cpp
index 82de103..be166e5 100644
--- a/src/security/validator.cpp
+++ b/src/security/validator.cpp
@@ -249,7 +249,7 @@
const uint8_t* p1 = buffer->buf();
const uint8_t* p2 = sigValue.value();
- for(int i = 0; i < crypto::SHA256_DIGEST_SIZE; i++)
+ for(size_t i = 0; i < crypto::SHA256_DIGEST_SIZE; i++)
if(p1[i] != p2[i])
return false;
return true;