Repository: randombit/botan
Pull request #2169 (2019-10-20 08:51:45)

silence trivial warnings

codecov-io: # [Codecov](https://codecov.io/gh/randombit/botan/pull/2169?src=pr&el=h1) Report
> Merging [#2169](https://codecov.io/gh/randombit/botan/pull/2169?src=pr&el=desc) into [master](https://codecov.io/gh/randombit/botan/commit/7b3453963dac1a8f45354343b0af26535aea21ae?src=pr&el=desc) will **increase** coverage by `<.01%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/randombit/botan/pull/2169/graphs/tree.svg?width=650&token=VR6iYmSPH8&height=150&src=pr)](https://codecov.io/gh/randombit/botan/pull/2169?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master    #2169      +/-   ##
==========================================
+ Coverage   92.35%   92.35%   +<.01%     
==========================================
  Files         553      553              
  Lines       60186    60186              
  Branches     6375     6375              
==========================================
+ Hits        55582    55585       +3     
+ Misses       4604     4601       -3
```


| [Impacted Files](https://codecov.io/gh/randombit/botan/pull/2169?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [src/lib/utils/os\_utils.cpp](https://codecov.io/gh/randombit/botan/pull/2169/diff?src=pr&el=tree#diff-c3JjL2xpYi91dGlscy9vc191dGlscy5jcHA=) | `69.01% <ø> (ø)` | :arrow_up: |
| [src/lib/tls/tls\_record.cpp](https://codecov.io/gh/randombit/botan/pull/2169/diff?src=pr&el=tree#diff-c3JjL2xpYi90bHMvdGxzX3JlY29yZC5jcHA=) | `98% <ø> (ø)` | :arrow_up: |
| [src/lib/utils/socket/uri.cpp](https://codecov.io/gh/randombit/botan/pull/2169/diff?src=pr&el=tree#diff-c3JjL2xpYi91dGlscy9zb2NrZXQvdXJpLmNwcA==) | `100% <ø> (ø)` | :arrow_up: |
| [src/cli/tls\_helpers.h](https://codecov.io/gh/randombit/botan/pull/2169/diff?src=pr&el=tree#diff-c3JjL2NsaS90bHNfaGVscGVycy5o) | `90.62% <ø> (ø)` | :arrow_up: |
| [src/tests/test\_pubkey.cpp](https://codecov.io/gh/randombit/botan/pull/2169/diff?src=pr&el=tree#diff-c3JjL3Rlc3RzL3Rlc3RfcHVia2V5LmNwcA==) | `85.91% <ø> (ø)` | :arrow_up: |
| [src/lib/utils/socket/socket.cpp](https://codecov.io/gh/randombit/botan/pull/2169/diff?src=pr&el=tree#diff-c3JjL2xpYi91dGlscy9zb2NrZXQvc29ja2V0LmNwcA==) | `87.23% <ø> (ø)` | :arrow_up: |
| [src/lib/tls/msg\_server\_kex.cpp](https://codecov.io/gh/randombit/botan/pull/2169/diff?src=pr&el=tree#diff-c3JjL2xpYi90bHMvbXNnX3NlcnZlcl9rZXguY3Bw) | `79.54% <ø> (ø)` | :arrow_up: |
| [src/lib/tls/msg\_cert\_verify.cpp](https://codecov.io/gh/randombit/botan/pull/2169/diff?src=pr&el=tree#diff-c3JjL2xpYi90bHMvbXNnX2NlcnRfdmVyaWZ5LmNwcA==) | `97.29% <ø> (ø)` | :arrow_up: |
| [src/lib/utils/socket/socket\_udp.cpp](https://codecov.io/gh/randombit/botan/pull/2169/diff?src=pr&el=tree#diff-c3JjL2xpYi91dGlscy9zb2NrZXQvc29ja2V0X3VkcC5jcHA=) | `85.18% <ø> (ø)` | :arrow_up: |
| [src/lib/pubkey/rsa/rsa.cpp](https://codecov.io/gh/randombit/botan/pull/2169/diff?src=pr&el=tree#diff-c3JjL2xpYi9wdWJrZXkvcnNhL3JzYS5jcHA=) | `98.03% <100%> (ø)` | :arrow_up: |
| ... and [5 more](https://codecov.io/gh/randombit/botan/pull/2169/diff?src=pr&el=tree-more) | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/randombit/botan/pull/2169?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/randombit/botan/pull/2169?src=pr&el=footer). Last update [7b34539...2a86d16](https://codecov.io/gh/randombit/botan/pull/2169?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/src/cli/tls_helpers.h b/src/cli/tls_helpers.h
index 9a8517e45..653a106e0 100644
--- a/src/cli/tls_helpers.h
+++ b/src/cli/tls_helpers.h
@@ -50,6 +50,8 @@ class Basic_Credentials_Manager : public Botan::Credentials_Manager
             {
             m_certstores.push_back(std::make_shared<Botan::System_Certificate_Store>());
             }
+#else
+         BOTAN_UNUSED(use_system_store);
 #endif
          }
 
diff --git a/src/lib/misc/roughtime/roughtime.cpp b/src/lib/misc/roughtime/roughtime.cpp
index 435308cd0..671b78cb4 100644
--- a/src/lib/misc/roughtime/roughtime.cpp
+++ b/src/lib/misc/roughtime/roughtime.cpp
@@ -162,7 +162,7 @@ Nonce::Nonce(RandomNumberGenerator& rng)
 
 std::array<uint8_t, request_min_size> encode_request(const Nonce& nonce)
    {
-   std::array<uint8_t, request_min_size> buf = {2, 0, 0, 0, 64, 0, 0, 0, 'N', 'O', 'N', 'C', 'P', 'A', 'D', 0xff};
+   std::array<uint8_t, request_min_size> buf = {{2, 0, 0, 0, 64, 0, 0, 0, 'N', 'O', 'N', 'C', 'P', 'A', 'D', 0xff}};
    std::memcpy(buf.data() + 16, nonce.get_nonce().data(), nonce.get_nonce().size());
    std::memset(buf.data() + 16 + nonce.get_nonce().size(), 0, buf.size() - 16 - nonce.get_nonce().size());
    return buf;
diff --git a/src/lib/pubkey/rsa/rsa.cpp b/src/lib/pubkey/rsa/rsa.cpp
index 830b1a5e8..fa88b497f 100644
--- a/src/lib/pubkey/rsa/rsa.cpp
+++ b/src/lib/pubkey/rsa/rsa.cpp
@@ -396,7 +396,7 @@ class RSA_Private_Operation
          the "Smooth RSA-CRT" method. https://eprint.iacr.org/2007/039.pdf
          */
 
-         const size_t powm_window = 4;
+         static constexpr size_t powm_window = 4;
 
          // Compute this in main thread to avoid racing on the rng
          const BigInt d1_mask(m_blinder.rng(), m_blinding_bits);
@@ -413,7 +413,7 @@ class RSA_Private_Operation
          */
          m.sig_words();
 
-         auto future_j1 = std::async(std::launch::async, [this, &m, &d1_mask, powm_window]() {
+         auto future_j1 = std::async(std::launch::async, [this, &m, &d1_mask]() {
 #endif
             const BigInt masked_d1 = m_private->get_d1() + (d1_mask * (m_private->get_p() - 1));
             auto powm_d1_p = monty_precompute(m_private->m_monty_p, m_private->m_mod_p.reduce(m), powm_window);
diff --git a/src/lib/tls/msg_cert_verify.cpp b/src/lib/tls/msg_cert_verify.cpp
index 021185003..711566bd0 100644
--- a/src/lib/tls/msg_cert_verify.cpp
+++ b/src/lib/tls/msg_cert_verify.cpp
@@ -98,6 +98,7 @@ bool Certificate_Verify::verify(const X509_Certificate& cert,
                                            state.hash().get_contents(), m_signature);
 
 #if defined(BOTAN_UNSAFE_FUZZER_MODE)
+   BOTAN_UNUSED(signature_valid);
    return true;
 #else
    return signature_valid;
diff --git a/src/lib/tls/msg_server_kex.cpp b/src/lib/tls/msg_server_kex.cpp
index 1b42cba99..797907ed8 100644
--- a/src/lib/tls/msg_server_kex.cpp
+++ b/src/lib/tls/msg_server_kex.cpp
@@ -316,6 +316,7 @@ bool Server_Key_Exchange::verify(const Public_Key& server_key,
                                            buf, m_signature);
 
 #if defined(BOTAN_UNSAFE_FUZZER_MODE)
+   BOTAN_UNUSED(signature_valid);
    return true;
 #else
    return signature_valid;
diff --git a/src/lib/tls/tls_record.cpp b/src/lib/tls/tls_record.cpp
index 71f942bc4..c662d1fe5 100644
--- a/src/lib/tls/tls_record.cpp
+++ b/src/lib/tls/tls_record.cpp
@@ -71,6 +71,7 @@ Connection_Cipher_State::Connection_Cipher_State(Protocol_Version version,
          }
 
 #else
+      BOTAN_UNUSED(uses_encrypt_then_mac);
       throw Internal_Error("Negotiated disabled TLS CBC+HMAC ciphersuite");
 #endif
       }
diff --git a/src/lib/utils/cpuid/cpuid_arm.cpp b/src/lib/utils/cpuid/cpuid_arm.cpp
index bc9ac5daa..6c947c62b 100644
--- a/src/lib/utils/cpuid/cpuid_arm.cpp
+++ b/src/lib/utils/cpuid/cpuid_arm.cpp
@@ -145,6 +145,8 @@ uint64_t CPUID::CPUID_Data::detect_cpu_features(size_t* cache_line_size)
    // plausibility check
    if(dcache_line == 32 || dcache_line == 64 || dcache_line == 128)
       *cache_line_size = static_cast<size_t>(dcache_line);
+#else
+   BOTAN_UNUSED(cache_line_size);
 #endif
 
    const unsigned long hwcap_neon = OS::get_auxval(ARM_hwcap_bit::ARCH_hwcap_neon);
diff --git a/src/lib/utils/os_utils.cpp b/src/lib/utils/os_utils.cpp
index 84a2d0ebe..72de063e8 100644
--- a/src/lib/utils/os_utils.cpp
+++ b/src/lib/utils/os_utils.cpp
@@ -315,6 +315,7 @@ size_t OS::system_page_size()
    else
       return default_page_size;
 #elif defined(BOTAN_TARGET_OS_HAS_VIRTUAL_LOCK)
+   BOTAN_UNUSED(default_page_size);
    SYSTEM_INFO sys_info;
    ::GetSystemInfo(&sys_info);
    return sys_info.dwPageSize;
diff --git a/src/lib/utils/socket/socket.cpp b/src/lib/utils/socket/socket.cpp
index 54033bc55..3c742c3ca 100644
--- a/src/lib/utils/socket/socket.cpp
+++ b/src/lib/utils/socket/socket.cpp
@@ -358,6 +358,9 @@ OS::open_socket(const std::string& hostname,
    return std::unique_ptr<OS::Socket>(new BSD_Socket(hostname, service, timeout));
 
 #else
+   BOTAN_UNUSED(hostname);
+   BOTAN_UNUSED(service);
+   BOTAN_UNUSED(timeout);
    // No sockets for you
    return std::unique_ptr<Socket>();
 #endif
diff --git a/src/lib/utils/socket/socket_udp.cpp b/src/lib/utils/socket/socket_udp.cpp
index 651fe1b0c..6e7cb1f11 100644
--- a/src/lib/utils/socket/socket_udp.cpp
+++ b/src/lib/utils/socket/socket_udp.cpp
@@ -320,6 +320,9 @@ OS::open_socket_udp(const std::string& hostname,
 #elif defined(BOTAN_TARGET_OS_HAS_SOCKETS) || defined(BOTAN_TARGET_OS_HAS_WINSOCK2)
    return std::unique_ptr<OS::SocketUDP>(new BSD_SocketUDP(hostname, service, timeout));
 #else
+   BOTAN_UNUSED(hostname);
+   BOTAN_UNUSED(service);
+   BOTAN_UNUSED(timeout);
    return std::unique_ptr<OS::SocketUDP>();
 #endif
    }
diff --git a/src/lib/utils/socket/uri.cpp b/src/lib/utils/socket/uri.cpp
index f8506d0e7..05bd8647d 100644
--- a/src/lib/utils/socket/uri.cpp
+++ b/src/lib/utils/socket/uri.cpp
@@ -28,6 +28,7 @@ bool isDomain(const std::string& domain)
    {
 #if defined(__GLIBCXX__) && (__GLIBCXX__ < 20160726)
    // GCC 4.8 does not support regex
+   BOTAN_UNUSED(domain);
    return true;
 #else
    std::regex re(


Test patch:
diff --git a/src/tests/test_modes.cpp b/src/tests/test_modes.cpp
index b371c476b..9f6f493c0 100644
--- a/src/tests/test_modes.cpp
+++ b/src/tests/test_modes.cpp
@@ -145,10 +145,10 @@ class Cipher_Mode_Tests final : public Text_Based_Test
                         mode.valid_nonce_length(mode.default_nonce_length()));
 
          // Test that disallowed nonce sizes result in an exception
-         const size_t large_nonce_size = 65000;
+         static constexpr size_t large_nonce_size = 65000;
          result.test_eq("Large nonce not allowed", mode.valid_nonce_length(large_nonce_size), false);
          result.test_throws("Large nonce causes exception",
-                            [&mode,large_nonce_size]() { mode.start(nullptr, large_nonce_size); });
+                            [&mode]() { mode.start(nullptr, large_nonce_size); });
 
          Botan::secure_vector<uint8_t> garbage = Test::rng().random_vec(update_granularity);
 
diff --git a/src/tests/test_pubkey.cpp b/src/tests/test_pubkey.cpp
index c3a44a57d..6e1f331c7 100644
--- a/src/tests/test_pubkey.cpp
+++ b/src/tests/test_pubkey.cpp
@@ -539,6 +539,7 @@ std::vector<std::string> PK_Key_Generation_Test::possible_providers(
 
 namespace {
 
+#if defined(BOTAN_HAS_PKCS5_PBES2) && defined(BOTAN_HAS_AES) && (defined(BOTAN_HAS_SHA2_32) || defined(BOTAN_HAS_SCRYPT))
 void test_pbe_roundtrip(Test::Result& result,
                         const Botan::Private_Key& key,
                         const std::string& pbe_algo,
@@ -591,6 +592,7 @@ void test_pbe_roundtrip(Test::Result& result,
       result.test_failure("roundtrip encrypted BER private key", e.what());
       }
    }
+#endif
 
 }