Cleared Coverity finding CID 12086 (Issue 299)

pull/301/head
Jeffrey Walton 2016-09-22 00:11:35 -04:00
parent 933e63f162
commit c7303a600f
1 changed files with 4 additions and 4 deletions

View File

@ -359,9 +359,9 @@ int CRYPTOPP_API main(int argc, char *argv[])
else if (command == "v" || command == "vv") else if (command == "v" || command == "vv")
return !Validate(argc>2 ? StringToValue<int, true>(argv[2]) : 0, argv[1][1] == 'v', argc>3 ? argv[3] : NULL); return !Validate(argc>2 ? StringToValue<int, true>(argv[2]) : 0, argv[1][1] == 'v', argc>3 ? argv[3] : NULL);
else if (command == "b") else if (command == "b")
BenchmarkAll(argc<3 ? 1 : StringToValue<float, true>(argv[2]), argc<4 ? 0 : StringToValue<float, true>(argv[3])*1e9); BenchmarkAll(argc<3 ? 1 : StringToValue<float, true>(argv[2]), argc<4 ? 0.0f : StringToValue<float, true>(argv[3])*1e9);
else if (command == "b2") else if (command == "b2")
BenchmarkAll2(argc<3 ? 1 : StringToValue<float, true>(argv[2]), argc<4 ? 0 : StringToValue<float, true>(argv[3])*1e9); BenchmarkAll2(argc<3 ? 1 : StringToValue<float, true>(argv[2]), argc<4 ? 0.0f : StringToValue<float, true>(argv[3])*1e9);
else if (command == "z") else if (command == "z")
GzipFile(argv[3], argv[4], argv[2][0]-'0'); GzipFile(argv[3], argv[4], argv[2][0]-'0');
else if (command == "u") else if (command == "u")
@ -432,10 +432,10 @@ template <class T, bool NON_NEGATIVE>
T StringToValue(const std::string& str) { T StringToValue(const std::string& str) {
std::istringstream iss(str); std::istringstream iss(str);
T value; T value;
iss >> value; iss >> std::noskipws >> value;
// Use fail(), not bad() // Use fail(), not bad()
if (iss.fail()) if (iss.fail() || !iss.eof())
throw InvalidArgument("cryptest.exe: '" + str +"' is not a value"); throw InvalidArgument("cryptest.exe: '" + str +"' is not a value");
if (NON_NEGATIVE && value < 0) if (NON_NEGATIVE && value < 0)