PrebufferedStream: avoid dereferencing end()

This appeared to work, but probably isn't a good idea.

CID 716940: Using invalid iterator (INVALIDATE_ITERATOR)
At (4): Dereferencing iterator "this->m_overflow.end()" though it is already past the end of its container.

Signed-off-by: Sage Weil <sage@inktank.com>
adminsocket: fix sock-fd leak in failure path

CID 728088: Resource leak (RESOURCE_LEAK)
At (9): Handle variable "sock_fd" going out of scope leaks the handle.

Signed-off-by: Sage Weil <sage@inktank.com>
Revert "obj_bencher: fix bufferlist leak in error path"

This reverts commit 82f77d0e4ac6d20d1ca8889414bd493d4e2120d5.
crushtester: avoid divide by zero

CID 716904: Division or modulo by zero (DIVIDE_BY_ZERO)
At (4): In expression "(float)weight[i] / (float)total_weight", division by expression "total_weight" which may be zero has undefined behavior.

At (8): On this path, function call "this->crush->get_max_devices()" has return value of 0
CID 716905: Division or modulo by zero (DIVIDE_BY_ZERO)
At (9): In expression "lrand48() % this->crush->get_max_devices()" modulo by expression "this->crush->get_max_devices()" which may be zero has undefined behavior.

Signed-off-by: Sage Weil <sage@inktank.com>
crushtester: avoid divide by zero

CID 716906: Division or modulo by zero (DIVIDE_BY_ZERO)
At (214): In expression "(float)weight[i] / (float)total_weight", division by expression "total_weight" which may be zero has undefined behavior.

Signed-off-by: Sage Weil <sage@inktank.com>
crushtester: fix uninit var

CID 717197: Uninitialized scalar variable (UNINIT)
At (35): Using uninitialized value "only_osd_affected".

Fix some whitespace too.

Signed-off-by: Sage Weil <sage@inktank.com>
pidfile: fix fd leak from pidfile_remove()

CID 717081: Resource leak (RESOURCE_LEAK)
At (10): Handle variable "fd" going out of scope leaks the handle.

Signed-off-by: Sage Weil <sage@inktank.com>
addr_parsing: fix memory leak

CID 717082: Resource leak (RESOURCE_LEAK)
At (4): Variable "buf" going out of scope leaks the storage it points to.

Signed-off-by: Sage Weil <sage@inktank.com>
stringify: use const ref

CID 727974: Big parameter passed by value (PASS_BY_VALUE)
At (1): Passing parameter a of type entity_addr_t (size 136 bytes) by value.

Signed-off-by: Sage Weil <sage@inktank.com>
utime: restore ostream state

CID 717130: Not restoring ostream format (STREAM_FORMAT_STATE)
At (4): Changing format state of stream "out" for category fill without later restoring it.

CID 717131: Not restoring ostream format (STREAM_FORMAT_STATE)
At (4): Changing format state of stream "out" for category fill without later restoring it.

Signed-off-by: Sage Weil <sage@inktank.com>
LogEntry: fix uninit in ctor

At (2): Non-static class member "m_thread" is not initialized in this constructor nor in any functions that it calls.
At (4): Non-static class member "m_prio" is not initialized in this constructor nor in any functions that it calls.
At (6): Non-static class member "m_subsys" is not initialized in this constructor nor in any functions that it calls.
CID 717229: Uninitialized scalar field (UNINIT_CTOR)
At (8): Non-static class member "m_static_buf" is not initialized in this constructor nor in any functions that it calls.

Signed-off-by: Sage Weil <sage@inktank.com>
msg/Accepter: check getsockbyname() return value

CID 717442: Other violation (CHECKED_RETURN)
At (10): Calling function "getsockname(this->listen_sd, (sockaddr *)listen_addr.ss_addr(), &llen)" without checking return value. This library function may fail and return an error code.
At (11): No check of the return value of "getsockname(this->listen_sd, (sockaddr *)listen_addr.ss_addr(), &llen)".

Signed-off-by: Sage Weil <sage@inktank.com>
msg/Messenger: avoid large pass by value

CID 717049: Big parameter passed by value (PASS_BY_VALUE)
At (1): Passing parameter bind_addr of type entity_addr_t (size 136 bytes) by value.

Signed-off-by: Sage Weil <sage@inktank.com>
messages: uninit values

CID 717259: Uninitialized scalar field (UNINIT_CTOR)
At (2): Non-static class member "global_id" is not initialized in this constructor nor in any functions that it calls.

CID 728086: Uninitialized scalar field (UNINIT_CTOR)
At (4): Non-static class member "type" is not initialized in this constructor nor in any functions that it calls.

CID 717260: Uninitialized scalar field (UNINIT_CTOR)
At (2): Non-static class member "from" is not initialized in this constructor nor in any functions that it calls.

CID 717261: Uninitialized scalar field (UNINIT_CTOR)
At (51): Non-static class member field "head.time_warp_seq" is not initialized in this constructor nor in any functions that it calls.

+ more

Signed-off-by: Sage Weil <sage@inktank.com>
fix msgr one
MRoute: avoid pass by value

CID 717038: Big parameter passed by value (PASS_BY_VALUE)
At (1): Passing parameter i of type entity_inst_t (size 152 bytes) by value.

Signed-off-by: Sage Weil <sage@inktank.com>
MMonJoin: avoid large pass by value

CID 717036: Big parameter passed by value (PASS_BY_VALUE)
At (1): Passing parameter a of type entity_addr_t (size 136 bytes) by value.

Signed-off-by: Sage Weil <sage@inktank.com>
more fix
MOSDFailure: avoid big pass by value

CID 727975: Big parameter passed by value (PASS_BY_VALUE)
At (1): Passing parameter f of type entity_inst_t (size 152 bytes) by value.

Signed-off-by: Sage Weil <sage@inktank.com>
filer: fix overflow

CID 717017: Unintentional integer overflow (OVERFLOW_BEFORE_WIDEN)
At (1): Potentially overflowing expression "layout->fl_stripe_count.operator unsigned int() * layout->fl_object_size.operator unsigned int()" with type "unsigned int" (32 bits, unsigned) is evaluated using 32-bit arithmetic before being used in a context which expects an expression of type "uint64_t" (64 bits, unsigned). To avoid overflow, cast either operand to "uint64_t" before performing the multiplication.

+ more

Signed-off-by: Sage Weil <sage@inktank.com>