Skip to content

Commit

Permalink
Merge pull request #7784 from ceph/wip-da-SCA-20160219
Browse files Browse the repository at this point in the history
Coverity and SCA fixes

Reviewed-by: Sage Weil <sage@redhat.com>
  • Loading branch information
liewegas committed Nov 11, 2016
2 parents a1303ce + 79d658f commit 53fb099
Show file tree
Hide file tree
Showing 22 changed files with 93 additions and 81 deletions.
104 changes: 54 additions & 50 deletions doc/man/8/ceph-deploy.rst
Expand Up @@ -484,109 +484,113 @@ Another option :option:`--master` can also be used with this command.
Options
=======

.. option:: --version

The current installed version of :program:`ceph-deploy`.

.. option:: --username

The username to connect to the remote host.

.. option:: --overwrite-conf
.. option:: --address

Overwrite an existing conf file on remote host (if present).
IP address of the host node to be added to the cluster.

.. option:: --cluster
.. option:: --adjust-repos

Name of the cluster.
Install packages modifying source repos.

.. option:: --ceph-conf

Use (or reuse) a given ``ceph.conf`` file.

.. option:: --no-ssh-copykey
.. option:: --cluster

Do not attempt to copy ssh keys.
Name of the cluster.

.. option:: --fsid
.. option:: --dev

Provide an alternate FSID for ``ceph.conf`` generation.
Install a bleeding edge built from Git branch or tag (default: master).

.. option:: --cluster-network

Specify the (internal) cluster network.

.. option:: --public-network
.. option:: --dmcrypt

Specify the public network for a cluster.
Encrypt [data-path] and/or journal devices with ``dm-crypt``.

.. option:: --testing
.. option:: --dmcrypt-key-dir

Install the latest development release.
Directory where ``dm-crypt`` keys are stored.

.. option:: --dev
.. option:: --install

Install a bleeding edge built from Git branch or tag (default: master).
Comma-separated package(s) to install on remote hosts.

.. option:: --adjust-repos
.. option:: --fs-type

Install packages modifying source repos.
Filesystem to use to format disk ``(xfs, btrfs or ext4)``.

.. option:: --no-adjust-repos
.. option:: --fsid

Install packages without modifying source repos.
Provide an alternate FSID for ``ceph.conf`` generation.

.. option:: --repo
.. option:: --gpg-url

Install repo files only (skips package installation).
Specify a GPG key url to be used with custom repos (defaults to ceph.com).

.. option:: --keyrings

Concatenate multiple keyrings to be seeded on new monitors.

.. option:: --local-mirror

Fetch packages and push them to hosts for a local repo mirror.

.. option:: --repo-url
.. option:: --master

Specify a repo url that mirrors/contains Ceph packages.
The domain for the Calamari master server.

.. option:: --gpg-url
.. option:: --mkfs

Specify a GPG key url to be used with custom repos (defaults to ceph.com).
Inject keys to MONs on remote nodes.

.. option:: --address
.. option:: --no-adjust-repos

IP address of the host node to be added to the cluster.
Install packages without modifying source repos.

.. option:: --keyrings
.. option:: --no-ssh-copykey

Concatenate multiple keyrings to be seeded on new monitors.
Do not attempt to copy ssh keys.

.. option:: --zap-disk
.. option:: --overwrite-conf

Destroy the partition table and content of a disk.
Overwrite an existing conf file on remote host (if present).

.. option:: --fs-type
.. option:: --public-network

Filesystem to use to format disk (e.g., ``xfs``, ``btrfs``).
Specify the public network for a cluster.

.. option:: --dmcrypt
.. option:: --remove

Encrypt [data-path] and/or journal devices with ``dm-crypt``.
Comma-separated package(s) to remove from remote hosts.

.. option:: --dmcrypt-key-dir
.. option:: --repo

Directory where ``dm-crypt`` keys are stored.
Install repo files only (skips package installation).

.. option:: --install
.. option:: --repo-url

Comma-separated package(s) to install on remote hosts.
Specify a repo url that mirrors/contains Ceph packages.

.. option:: --remove
.. option:: --testing

Comma-separated package(s) to remove from remote hosts.
Install the latest development release.

.. option:: --master
.. option:: --username

The domain for the Calamari master server.
The username to connect to the remote host.

.. option:: --version

The current installed version of :program:`ceph-deploy`.

.. option:: --zap-disk

Destroy the partition table and content of a disk.


Availability
Expand Down
2 changes: 2 additions & 0 deletions src/common/ConfUtils.cc
Expand Up @@ -297,6 +297,8 @@ load_from_buffer(const char *buf, size_t sz, std::deque<std::string> *errors,
size_t rem = sz;
while (1) {
b += line_len + 1;
if ((line_len + 1) > rem)
break;
rem -= line_len + 1;
if (rem == 0)
break;
Expand Down
2 changes: 1 addition & 1 deletion src/common/bit_vector.hpp
Expand Up @@ -115,7 +115,7 @@ template <uint8_t _b>
const uint32_t BitVector<_b>::BLOCK_SIZE = 4096;

template <uint8_t _b>
BitVector<_b>::BitVector() : m_size(0), m_crc_enabled(true)
BitVector<_b>::BitVector() : m_size(0), m_crc_enabled(true), m_header_crc(0)
{
}

Expand Down
3 changes: 3 additions & 0 deletions src/erasure-code/shec/ErasureCodeShec.cc
Expand Up @@ -549,6 +549,9 @@ int ErasureCodeShec::shec_make_decoding_matrix(bool prepare, int *want_, int *av
{
int mindup = k+1, minp = k+1;
int want[k + m];

memset(want, 0, sizeof(want));

for (int i = 0; i < k + m; ++i) {
want[i] = want_[i];
}
Expand Down
2 changes: 1 addition & 1 deletion src/include/types.h
Expand Up @@ -460,7 +460,7 @@ __s32 ceph_to_host_errno(__s32 e);
struct errorcode32_t {
int32_t code;

errorcode32_t() {}
errorcode32_t() : code(0) {}
// cppcheck-suppress noExplicitConstructor
errorcode32_t(int32_t i) : code(i) {}

Expand Down
2 changes: 1 addition & 1 deletion src/librbd/WatchNotifyTypes.h
Expand Up @@ -179,7 +179,7 @@ struct AsyncCompletePayload : public AsyncRequestPayloadBase {
static const NotifyOp NOTIFY_OP = NOTIFY_OP_ASYNC_COMPLETE;
static const bool CHECK_FOR_REFRESH = false;

AsyncCompletePayload() {}
AsyncCompletePayload() : result(0) {}
AsyncCompletePayload(const AsyncRequestId &id, int r)
: AsyncRequestPayloadBase(id), result(r) {}

Expand Down
2 changes: 1 addition & 1 deletion src/librbd/exclusive_lock/AcquireRequest.cc
Expand Up @@ -417,7 +417,7 @@ Context *AcquireRequest<I>::handle_get_lockers(int *ret_val) {

std::map<rados::cls::lock::locker_id_t,
rados::cls::lock::locker_info_t> lockers;
ClsLockType lock_type;
ClsLockType lock_type = LOCK_NONE;
std::string lock_tag;
if (*ret_val == 0) {
bufferlist::iterator it = m_out_bl.begin();
Expand Down
6 changes: 3 additions & 3 deletions src/mds/Capability.h
Expand Up @@ -86,7 +86,7 @@ class Capability {
ceph_seq_t seq;
ceph_seq_t mseq;
utime_t last_issue_stamp;
Export() {}
Export() : cap_id(0), wanted(0), issued(0), pending(0), seq(0), mseq(0) {}
Export(int64_t id, int w, int i, int p, snapid_t cf, ceph_seq_t s, ceph_seq_t m, utime_t lis) :
cap_id(id), wanted(w), issued(i), pending(p), client_follows(cf),
seq(s), mseq(m), last_issue_stamp(lis) {}
Expand All @@ -99,7 +99,7 @@ class Capability {
int64_t cap_id;
ceph_seq_t issue_seq;
ceph_seq_t mseq;
Import() {}
Import() : cap_id(0), issue_seq(0), mseq(0) {}
Import(int64_t i, ceph_seq_t s, ceph_seq_t m) : cap_id(i), issue_seq(s), mseq(m) {}
void encode(bufferlist &bl) const;
void decode(bufferlist::iterator &p);
Expand All @@ -125,7 +125,7 @@ class Capability {
struct revoke_info {
__u32 before;
ceph_seq_t seq, last_issue;
revoke_info() {}
revoke_info() : before(0), seq(0), last_issue(0) {}
revoke_info(__u32 b, ceph_seq_t s, ceph_seq_t li) : before(b), seq(s), last_issue(li) {}
void encode(bufferlist& bl) const;
void decode(bufferlist::iterator& bl);
Expand Down
6 changes: 5 additions & 1 deletion src/os/bluestore/NVMEDevice.cc
Expand Up @@ -762,7 +762,11 @@ void io_complete(void *t, const struct spdk_nvme_cpl *completion)
#define dout_prefix *_dout << "bdev(" << name << ") "

NVMEDevice::NVMEDevice(aio_callback_t cb, void *cbpriv)
: buffer_lock("NVMEDevice::buffer_lock"),
: driver(NULL),
size(0),
block_size(0),
aio_stop(false),
buffer_lock("NVMEDevice::buffer_lock"),
aio_callback(cb),
aio_callback_priv(cbpriv)
{
Expand Down
2 changes: 1 addition & 1 deletion src/os/fs/FS.h
Expand Up @@ -64,7 +64,7 @@ class FS {

boost::intrusive::list_member_hook<> queue_item;

aio_t(void *p, int f) : priv(p), fd(f), rval(-1000) {
aio_t(void *p, int f) : priv(p), fd(f), offset(0), length(0), rval(-1000) {
memset(&iocb, 0, sizeof(iocb));
}

Expand Down
1 change: 1 addition & 0 deletions src/os/kstore/KStore.cc
Expand Up @@ -631,6 +631,7 @@ KStore::KStore(CephContext *cct, const string& path)
fsid_fd(-1),
mounted(false),
coll_lock("KStore::coll_lock"),
nid_last(0),
nid_max(0),
throttle_ops(cct, "kstore_max_ops", cct->_conf->kstore_max_ops),
throttle_bytes(cct, "kstore_max_bytes", cct->_conf->kstore_max_bytes),
Expand Down
1 change: 1 addition & 0 deletions src/osd/OSD.cc
Expand Up @@ -1668,6 +1668,7 @@ OSD::OSD(CephContext *cct_, ObjectStore *store_,
hbclient_messenger(hb_clientm),
hb_front_server_messenger(hb_front_serverm),
hb_back_server_messenger(hb_back_serverm),
daily_loadavg(0.0),
heartbeat_thread(this),
heartbeat_dispatcher(this),
op_tracker(cct, cct->_conf->osd_enable_op_tracker,
Expand Down
3 changes: 2 additions & 1 deletion src/rgw/rgw_op.h
Expand Up @@ -346,6 +346,7 @@ class RGWListBuckets : public RGWOp {
buckets_objcount = 0;
buckets_size = 0;
buckets_size_rounded = 0;
is_truncated = false;
}

int verify_permission();
Expand Down Expand Up @@ -667,7 +668,7 @@ struct RGWSLOInfo {
char *raw_data;
int raw_data_len;

RGWSLOInfo() : raw_data(NULL), raw_data_len(0) {}
RGWSLOInfo() : total_size(0), raw_data(NULL), raw_data_len(0) {}
~RGWSLOInfo() {
free(raw_data);
}
Expand Down
11 changes: 6 additions & 5 deletions src/rgw/rgw_rados.h
Expand Up @@ -871,9 +871,9 @@ class RGWSystemMetaObj {
int use_default(bool old_format = false);

public:
RGWSystemMetaObj() {}
RGWSystemMetaObj(const string& _name): name(_name) {}
RGWSystemMetaObj(const string& _id, const string& _name) : id(_id), name(_name) {}
RGWSystemMetaObj() : cct(NULL), store(NULL) {}
RGWSystemMetaObj(const string& _name): name(_name), cct(NULL), store(NULL) {}
RGWSystemMetaObj(const string& _id, const string& _name) : id(_id), name(_name), cct(NULL), store(NULL) {}
RGWSystemMetaObj(CephContext *_cct, RGWRados *_store): cct(_cct), store(_store){}
RGWSystemMetaObj(const string& _name, CephContext *_cct, RGWRados *_store): name(_name), cct(_cct), store(_store){}
const string& get_name() const { return name; }
Expand Down Expand Up @@ -1559,10 +1559,11 @@ class RGWPeriod
int update_sync_status();

public:
RGWPeriod() : epoch(0) {}
RGWPeriod() : epoch(0), cct(NULL), store(NULL) {}

RGWPeriod(const string& period_id, epoch_t _epoch = 0)
: id(period_id), epoch(_epoch) {}
: id(period_id), epoch(_epoch),
cct(NULL), store(NULL) {}

const string& get_id() const { return id; }
epoch_t get_epoch() const { return epoch; }
Expand Down
2 changes: 1 addition & 1 deletion src/rgw/rgw_sync.cc
Expand Up @@ -31,7 +31,7 @@ static string mdlog_sync_status_oid = "mdlog.sync-status";
static string mdlog_sync_status_shard_prefix = "mdlog.sync-status.shard";
static string mdlog_sync_full_sync_index_prefix = "meta.full-sync.index";

RGWSyncErrorLogger::RGWSyncErrorLogger(RGWRados *_store, const string oid_prefix, int _num_shards) : store(_store), num_shards(_num_shards) {
RGWSyncErrorLogger::RGWSyncErrorLogger(RGWRados *_store, const string &oid_prefix, int _num_shards) : store(_store), num_shards(_num_shards) {
for (int i = 0; i < num_shards; i++) {
oids.push_back(get_shard_oid(oid_prefix, i));
}
Expand Down
2 changes: 1 addition & 1 deletion src/rgw/rgw_sync.h
Expand Up @@ -67,7 +67,7 @@ class RGWSyncErrorLogger {

atomic_t counter;
public:
RGWSyncErrorLogger(RGWRados *_store, const string oid_prefix, int _num_shards);
RGWSyncErrorLogger(RGWRados *_store, const string &oid_prefix, int _num_shards);
RGWCoroutine *log_error_cr(const string& source_zone, const string& section, const string& name, uint32_t error_code, const string& message);

static string get_shard_oid(const string& oid_prefix, int shard_id);
Expand Down
2 changes: 0 additions & 2 deletions src/rgw/rgw_user.cc
Expand Up @@ -1840,9 +1840,7 @@ int RGWUser::check_op(RGWUserAdminOpState& op_state, std::string *err_msg)
{
bool same_id;
bool populated;
//bool existing_email = false; // this check causes a fault
rgw_user& op_id = op_state.get_user_id();
std::string op_email = op_state.get_user_email();

RGWUserInfo user_info;

Expand Down
4 changes: 2 additions & 2 deletions src/test/librbd/test_librbd.cc
Expand Up @@ -3166,8 +3166,8 @@ TEST_F(TestLibRBD, ZeroLengthDiscard)
ASSERT_EQ(0, create_image(ioctx, name.c_str(), size, &order));
ASSERT_EQ(0, rbd_open(ioctx, name.c_str(), &image, NULL));

const char *data = "blah";
char read_data[strlen(data)];
const char data[] = "blah";
char read_data[sizeof(data)];
ASSERT_EQ((int)strlen(data), rbd_write(image, 0, strlen(data), data));
ASSERT_EQ(0, rbd_discard(image, 0, 0));
ASSERT_EQ((int)strlen(data), rbd_read(image, 0, strlen(data), read_data));
Expand Down
10 changes: 3 additions & 7 deletions src/test/librgw_file.cc
Expand Up @@ -106,14 +106,12 @@ TEST(LibRGW, LOOKUP_BUCKETS) {
if (! fs)
return;

int ret = 0;
for (auto& fid_row : bucket_matrix) {
auto& fid = get<0>(fid_row);
// auto& obj_vector = get<1>(fid_row);
struct rgw_file_handle *rgw_fh = nullptr;
ret = rgw_lookup(fs, fs->root_fh, get<0>(fid).c_str(), &rgw_fh,
0 /* flags */);
ASSERT_EQ(ret, 0);
ASSERT_EQ(0, rgw_lookup(fs, fs->root_fh, get<0>(fid).c_str(), &rgw_fh,
0 /* flags */));
get<2>(fid) = rgw_fh;
ASSERT_NE(get<2>(fid), nullptr);
}
Expand All @@ -126,14 +124,12 @@ TEST(LibRGW, GETATTR_BUCKETS) {
if (! fs)
return;

int ret = 0;
struct stat st;

for (auto& fid_row : bucket_matrix) {
auto& fid = get<0>(fid_row);
struct rgw_file_handle *rgw_fh = get<2>(fid);
ret = rgw_getattr(fs, rgw_fh, &st, RGW_GETATTR_FLAG_NONE);
ASSERT_EQ(ret, 0);
ASSERT_EQ(0, rgw_getattr(fs, rgw_fh, &st, RGW_GETATTR_FLAG_NONE));
}
}
}
Expand Down

0 comments on commit 53fb099

Please sign in to comment.