From 2850a074eade247a4ee9220b095734e0f1f15ada Mon Sep 17 00:00:00 2001 From: Dennis Luxen Date: Thu, 8 May 2014 08:56:51 +0200 Subject: [PATCH] make sure parameter is not negative - fixes coverity issue 1198843 Argument cannot be negative --- Tools/io-benchmark.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Tools/io-benchmark.cpp b/Tools/io-benchmark.cpp index 829d10550..ace1b2957 100644 --- a/Tools/io-benchmark.cpp +++ b/Tools/io-benchmark.cpp @@ -116,9 +116,13 @@ int main(int argc, char *argv[]) #ifdef __linux__ int f = open(test_path.string().c_str(), O_CREAT | O_TRUNC | O_WRONLY | O_SYNC, S_IRWXU); + if (-1 == f) + { + throw OSRMException("Could not open random data file"); + } time1 = std::chrono::steady_clock::now(); int ret = write(f, random_array, number_of_elements * sizeof(unsigned)); - if (-1 == ret) + if (0 > ret) { throw OSRMException("could not write random data file"); }