aboutsummaryrefslogtreecommitdiffstats
path: root/src/cli
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2016-04-09 11:23:51 -0400
committerJack Lloyd <[email protected]>2016-04-09 11:23:51 -0400
commit8dd6eb9252ad91f59630e2889fa6803f6e3bf554 (patch)
tree11de0bdbf598afc2a7207e9bbef911716ba54ce1 /src/cli
parent5e75f6db1c3d73fdb778d49751f1b2ef4549b177 (diff)
Fix a couple MSVC warnings.
Cast std::streamsize to size_t since MSVC is worried gcount() might return a negative number. The entropy callbacks took the entropy estimate as a size_t instead of a double, which causes some verbose warnings due to the conversion.
Diffstat (limited to 'src/cli')
-rw-r--r--src/cli/cli.h2
-rw-r--r--src/cli/speed.cpp14
2 files changed, 9 insertions, 7 deletions
diff --git a/src/cli/cli.h b/src/cli/cli.h
index c2609bc55..11cc8add7 100644
--- a/src/cli/cli.h
+++ b/src/cli/cli.h
@@ -443,7 +443,7 @@ class Command
while(in.good())
{
in.read(reinterpret_cast<char*>(buf.data()), buf.size());
- consumer_fn(buf.data(), in.gcount());
+ consumer_fn(buf.data(), static_cast<size_t>(in.gcount()));
}
}
diff --git a/src/cli/speed.cpp b/src/cli/speed.cpp
index ffe10844e..c767b2a55 100644
--- a/src/cli/speed.cpp
+++ b/src/cli/speed.cpp
@@ -597,13 +597,14 @@ class Speed final : public Command
for(auto src : srcs.enabled_sources())
{
- size_t entropy_bits = 0, samples = 0;
+ double entropy_bits = 0.0;
+ size_t samples = 0;
std::vector<size_t> entropy;
Botan::Entropy_Accumulator accum(
- [&](const uint8_t buf[], size_t buf_len, size_t buf_entropy) -> bool {
- entropy.insert(entropy.end(), buf, buf + buf_len);
- entropy_bits += buf_entropy;
+ [&](const uint8_t buf[], size_t buf_len, double buf_entropy) -> bool {
+ entropy.insert(entropy.end(), buf, buf + buf_len);
+ entropy_bits += buf_entropy;
samples += 1;
return (samples > 1024 || entropy_bits > 1024 || clock::now() > deadline);
});
@@ -623,8 +624,9 @@ class Speed final : public Command
}
#endif
- output() << "Entropy source " << src << " output " << entropy.size()
- << " bytes in " << timer.milliseconds() << " ms";
+ output() << "Entropy source " << src << " output " << entropy.size() << " bytes"
+ << " estimated entropy " << entropy_bits
+ << " in " << timer.milliseconds() << " ms";
#if defined(BOTAN_HAS_COMPRESSION)
if(compressed.size() > 0)