ReplicatedPG.cc: fix ressource leak, delete cb

CID 1188145 (#1 of 1): Resource leak (RESOURCE_LEAK)
 leaked_storage: Variable "cb" going out of scope leaks the storage it points to.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
histogram.h: fix potential div by zero

CID 1188131 (#1 of 1): Division or modulo by zero (DIVIDE_BY_ZERO)
 divide_by_zero: In expression "lower_sum * 1000000UL / total", division
 by expression "total" which may be zero has undefined behavior

Added check for non zero total.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
store_test.cc: fix unchecked return value

CID 1188126 (#1 of 1): Unchecked return value (CHECKED_RETURN)
 2. check_return: Calling function "ObjectStore::stat(coll_t,
    ghobject_t const &, stat *, bool)" without checking return value
    (as is done elsewhere 8 out of 9 times).
 3. unchecked_value: No check of the return value of "this->store->stat(
    coll_t(this->cid), hoid, &buf, false)".

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
ReplicatedBackend: check result of dynamic_cast to fix null pointer deref

CID 1188135 (#1 of 1): Unchecked dynamic_cast (FORWARD_NULL)
 var_deref_model: Passing null pointer "t" to function
 "RPGTransaction::get_transaction()", which dereferences it

CID 1188134 (#1 of 1): Unchecked dynamic_cast (FORWARD_NULL)
 var_deref_op: Dereferencing null pointer "to_append".

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
c_write_operations.cc: fix some ioctx resource leaks

CID 1160833 (#3 of 3): Resource leak (RESOURCE_LEAK)
 leaked_storage: Variable "ioctx" going out of scope leaks the storage
 it points to

CID 1160835 (#3 of 3): Resource leak (RESOURCE_LEAK)
 leaked_storage: Variable "ioctx" going out of scope leaks the storage
 it points to.

CID 1188156 (#5 of 5): Resource leak (RESOURCE_LEAK)
 leaked_storage: Variable "ioctx" going out of scope leaks the storage
 it points to.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
c_read_operations.cc: fix resource leak

CID 1188154 (#2 of 2): Resource leak (RESOURCE_LEAK)
 overwrite_var: Overwriting "op" in "op = rados_create_read_op()" leaks
 the storage that "op" points to.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
FileStore: fix resource leak in queue_transactions() blackhole case

CID 1135931 (#1 of 1): Resource leak (RESOURCE_LEAK)
 leaked_storage: Variable "ondisk" going out of scope leaks the storage it
 points to.

CID 1135932 (#1 of 1): Resource leak (RESOURCE_LEAK)
 leaked_storage: Variable "onreadable" going out of scope leaks the storage
 it points to.

CID 1135933 (#1 of 1): Resource leak (RESOURCE_LEAK)
 leaked_storage: Variable "onreadable_sync" going out of scope leaks the
 storage it points to.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
MDCache::handle_discover: fix null pointer deref

CID 716990 (#1 of 1): Dereference null return value (NULL_RETURNS)
 dereference: Dereferencing a pointer that might be null "cur" when calling
 "MDCache::replicate_inode(CInode *, int, ceph::bufferlist &)"

Add assert to check for return value from get_inode() as done in other places.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
MDCache: fix potential null pointer deref

CID 716921 (#1 of 1): Dereference after null check (FORWARD_NULL)
 var_deref_model: Passing null pointer "dir" to function
 "operator <<(std::ostream &, CDir &)", which dereferences it.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
PGMonitor: fix uninitialized scalar variable

Fix type handling in dump_stuck_pg_stats. If type is type doesn't
match to known PGMap::STUCK_* type print out a message and return
directly from function.

CID 1030132 (#2 of 2): Uninitialized scalar variable (UNINIT)
 uninit_use_in_call: Using uninitialized value "stuck_type" when calling
 "PGMap::dump_stuck(ceph::Formatter *, PGMap::StuckPG, utime_t) const"

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Objecter::recalc_op_target: fix uninitialized scalar variable

CID 1160848 (#1 of 1): Uninitialized scalar variable (UNINIT)
 uninit_use: Using uninitialized value "best".

Init 'best' with -1 (from the code logic it will be set at least to 0)
to silence coverity.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
req_state: fix uninitialized bool var

CID 717359 (#1 of 1): Uninitialized scalar field (UNINIT_CTOR)
 uninit_member: Non-static class member "bucket_exists" is not
 initialized in this constructor nor in any functions that it calls.

Set bucket_exists to false in req_state::req_state().

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
Merge pull request #1337 from ceph/wip-fix-coverity-20140228

Fix different issues found by Coverity

Reviewed-by: Sage Weil <sage@inktank.com>