From: Danny Al-Gaaf Date: Fri, 2 Jan 2015 21:12:31 +0000 (+0100) Subject: src/common/obj_bencher: fix some UNINIT issues X-Git-Tag: v0.92~23^2~3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=aacdaae1c8bf2546fd2c7a19ef817df9a3600fda;p=ceph.git src/common/obj_bencher: fix some UNINIT issues Make sure concurrentios is always >= 0 to fix these coverity issues and to prevent bad_alloc/negative array sizes: CID 1128404 (#1 of 1): Uninitialized scalar variable (UNINIT) uninit_use: Using uninitialized value index[slot]. CID 1128405 (#1 of 1): Uninitialized pointer read (UNINIT) uninit_use: Using uninitialized value contents[slot]. CID 1219644 (#1 of 1): Uninitialized pointer read (UNINIT) uninit_use: Using uninitialized value contents[slot]. CID 1219645 (#1 of 1): Uninitialized pointer read (UNINIT) uninit_use: Using uninitialized value contents[slot]. CID 1219646 (#1 of 1): Uninitialized scalar variable (UNINIT) uninit_use: Using uninitialized value index[slot]. Signed-off-by: Danny Al-Gaaf --- diff --git a/src/common/obj_bencher.cc b/src/common/obj_bencher.cc index 9098918cceba..81abe091417d 100644 --- a/src/common/obj_bencher.cc +++ b/src/common/obj_bencher.cc @@ -1,4 +1,5 @@ // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab /* * Ceph - scalable distributed file system * @@ -154,6 +155,10 @@ int ObjBencher::aio_bench( int operation, int secondsToRun, int maxObjectsToCreate, int concurrentios, int op_size, bool cleanup, const char* run_name) { + + if (concurrentios <= 0) + return -EINVAL; + int object_size = op_size; int num_objects = 0; int r = 0; @@ -286,6 +291,9 @@ int ObjBencher::fetch_bench_metadata(const std::string& metadata_file, int* obje int ObjBencher::write_bench(int secondsToRun, int maxObjectsToCreate, int concurrentios, const string& run_name_meta) { + if (concurrentios <= 0) + return -EINVAL; + if (maxObjectsToCreate > 0 && concurrentios > maxObjectsToCreate) concurrentios = maxObjectsToCreate; out(cout) << "Maintaining " << concurrentios << " concurrent writes of " @@ -484,6 +492,10 @@ int ObjBencher::write_bench(int secondsToRun, int maxObjectsToCreate, int ObjBencher::seq_read_bench(int seconds_to_run, int num_objects, int concurrentios, int pid) { lock_cond lc(&lock); + + if (concurrentios <= 0) + return -EINVAL; + std::vector name(concurrentios); std::string newName; bufferlist* contents[concurrentios]; @@ -668,6 +680,10 @@ int ObjBencher::seq_read_bench(int seconds_to_run, int num_objects, int concurre int ObjBencher::rand_read_bench(int seconds_to_run, int num_objects, int concurrentios, int pid) { lock_cond lc(&lock); + + if (concurrentios <= 0) + return -EINVAL; + std::vector name(concurrentios); std::string newName; bufferlist* contents[concurrentios]; @@ -883,6 +899,10 @@ int ObjBencher::clean_up(const char* prefix, int concurrentios, const char* run_ int ObjBencher::clean_up(int num_objects, int prevPid, int concurrentios) { lock_cond lc(&lock); + + if (concurrentios <= 0) + return -EINVAL; + std::vector name(concurrentios); std::string newName; int r = 0; @@ -1043,6 +1063,10 @@ bool ObjBencher::more_objects_matching_prefix(const std::string& prefix, std::li int ObjBencher::clean_up_slow(const std::string& prefix, int concurrentios) { lock_cond lc(&lock); + + if (concurrentios <= 0) + return -EINVAL; + std::vector name(concurrentios); std::string newName; int r = 0; diff --git a/src/common/obj_bencher.h b/src/common/obj_bencher.h index ffdd64162b1a..4d89f41255e6 100644 --- a/src/common/obj_bencher.h +++ b/src/common/obj_bencher.h @@ -1,4 +1,5 @@ // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab /* * Ceph - scalable distributed file system *