diff options
author | lloyd <[email protected]> | 2012-08-13 20:40:47 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2012-08-13 20:40:47 +0000 |
commit | 404ae3514fbbdb51e32af1c2c1434acacf5ec20c (patch) | |
tree | 6f4107667adb924d763f6c6ab699e1ee416025d0 /src | |
parent | 53d53fbe291f1e049f55d9018d2b07cf62fbef24 (diff) |
Fix various issues flagged by cppcheck. Nothing too interesting.
Diffstat (limited to 'src')
-rw-r--r-- | src/cert/cvc/asn1_eac_str.cpp | 2 | ||||
-rw-r--r-- | src/cert/x509/certstor.cpp | 2 | ||||
-rw-r--r-- | src/cert/x509/x509cert.cpp | 4 | ||||
-rw-r--r-- | src/cert/x509/x509path.cpp | 2 | ||||
-rw-r--r-- | src/engine/core_engine/core_modes.cpp | 6 | ||||
-rw-r--r-- | src/engine/openssl/ossl_md.cpp | 1 | ||||
-rw-r--r-- | src/math/bigint/big_io.cpp | 2 | ||||
-rw-r--r-- | src/pk_pad/emsa1/emsa1.cpp | 4 |
8 files changed, 11 insertions, 12 deletions
diff --git a/src/cert/cvc/asn1_eac_str.cpp b/src/cert/cvc/asn1_eac_str.cpp index 37a601e4e..2084a9c03 100644 --- a/src/cert/cvc/asn1_eac_str.cpp +++ b/src/cert/cvc/asn1_eac_str.cpp @@ -88,7 +88,7 @@ void ASN1_EAC_String::decode_from(BER_Decoder& source) Charset::transcode(ASN1::to_string(obj), charset_is, LOCAL_CHARSET), obj.type_tag); } - catch(Invalid_Argument inv_arg) + catch(Invalid_Argument& inv_arg) { throw Decoding_Error(std::string("ASN1_EAC_String decoding failed: ") + inv_arg.what()); diff --git a/src/cert/x509/certstor.cpp b/src/cert/x509/certstor.cpp index 293072785..f68177230 100644 --- a/src/cert/x509/certstor.cpp +++ b/src/cert/x509/certstor.cpp @@ -15,7 +15,7 @@ bool Certificate_Store::certificate_known(const X509_Certificate& cert) const find_cert_by_subject_and_key_id(cert.subject_dn(), cert.subject_key_id()); - return (found.size() > 0); + return !found.empty(); } void Certificate_Store_In_Memory::add_certificate(const X509_Certificate& cert) diff --git a/src/cert/x509/x509cert.cpp b/src/cert/x509/x509cert.cpp index 42f2d084e..c738f9dc2 100644 --- a/src/cert/x509/x509cert.cpp +++ b/src/cert/x509/x509cert.cpp @@ -506,7 +506,7 @@ std::string X509_Certificate::to_string() const } std::vector<std::string> policies = this->policies(); - if(policies.size()) + if(!policies.empty()) { out << "Policies: " << "\n"; for(size_t i = 0; i != policies.size(); i++) @@ -514,7 +514,7 @@ std::string X509_Certificate::to_string() const } std::vector<std::string> ex_constraints = this->ex_constraints(); - if(ex_constraints.size()) + if(!ex_constraints.empty()) { out << "Extended Constraints:\n"; for(size_t i = 0; i != ex_constraints.size(); i++) diff --git a/src/cert/x509/x509path.cpp b/src/cert/x509/x509path.cpp index 7d6108ffa..f8d0b770e 100644 --- a/src/cert/x509/x509path.cpp +++ b/src/cert/x509/x509path.cpp @@ -40,7 +40,7 @@ X509_Certificate find_issuing_cert(const X509_Certificate& cert, std::vector<X509_Certificate> certs = certstores[i]->find_cert_by_subject_and_key_id(issuer_dn, auth_key_id); - if(certs.size() == 0) + if(certs.empty()) continue; if(certs.size() > 1) diff --git a/src/engine/core_engine/core_modes.cpp b/src/engine/core_engine/core_modes.cpp index ffd8aa04f..21a5863e2 100644 --- a/src/engine/core_engine/core_modes.cpp +++ b/src/engine/core_engine/core_modes.cpp @@ -140,10 +140,10 @@ Keyed_Filter* get_cipher_mode(const BlockCipher* block_cipher, if(mode.find("CFB") != std::string::npos || mode.find("EAX") != std::string::npos) { - size_t bits = 0; - std::vector<std::string> algo_info = parse_algorithm_name(mode); - std::string mode_name = algo_info[0]; + const std::string mode_name = algo_info[0]; + + size_t bits = 0; if(algo_info.size() == 1) bits = 8 * block_cipher->block_size(); else if(algo_info.size() == 2) diff --git a/src/engine/openssl/ossl_md.cpp b/src/engine/openssl/ossl_md.cpp index 3fcee91d6..e09a68a8e 100644 --- a/src/engine/openssl/ossl_md.cpp +++ b/src/engine/openssl/ossl_md.cpp @@ -38,7 +38,6 @@ class EVP_HashFunction : public HashFunction void add_data(const byte[], size_t); void final_result(byte[]); - size_t block_size; std::string algo_name; EVP_MD_CTX md; }; diff --git a/src/math/bigint/big_io.cpp b/src/math/bigint/big_io.cpp index 095d56510..b561c218f 100644 --- a/src/math/bigint/big_io.cpp +++ b/src/math/bigint/big_io.cpp @@ -29,7 +29,7 @@ std::ostream& operator<<(std::ostream& stream, const BigInt& n) stream.write("-", 1); const std::vector<byte> buffer = BigInt::encode(n, base); size_t skip = 0; - while(buffer[skip] == '0' && skip < buffer.size()) + while(skip < buffer.size() && buffer[skip] == '0') ++skip; stream.write(reinterpret_cast<const char*>(&buffer[0]) + skip, buffer.size() - skip); diff --git a/src/pk_pad/emsa1/emsa1.cpp b/src/pk_pad/emsa1/emsa1.cpp index 7f9a1885f..2358023f8 100644 --- a/src/pk_pad/emsa1/emsa1.cpp +++ b/src/pk_pad/emsa1/emsa1.cpp @@ -81,11 +81,11 @@ bool EMSA1::verify(const secure_vector<byte>& coded, secure_vector<byte> our_coding = emsa1_encoding(raw, key_bits); if(our_coding == coded) return true; - if(our_coding[0] != 0) return false; + if(our_coding.empty() || our_coding[0] != 0) return false; if(our_coding.size() <= coded.size()) return false; size_t offset = 0; - while(our_coding[offset] == 0 && offset < our_coding.size()) + while(offset < our_coding.size() && our_coding[offset] == 0) ++offset; if(our_coding.size() - offset != coded.size()) return false; |