Skip to content

Commit

Permalink
Merge pull request ceph#12863 from dillaman/wip-rbd-coverity
Browse files Browse the repository at this point in the history
librbd: resolve static analyser warnings

Reviewed-by: Mykola Golub <[email protected]>
  • Loading branch information
Mykola Golub authored Jan 12, 2017
2 parents 60c3667 + 5f2689b commit 5b97cce
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 13 deletions.
23 changes: 13 additions & 10 deletions src/cls/rbd/cls_rbd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2712,19 +2712,19 @@ int metadata_get(cls_method_context_t hctx, bufferlist *in, bufferlist *out)
int snapshot_get_limit(cls_method_context_t hctx, bufferlist *in,
bufferlist *out)
{
int rc;
uint64_t snap_limit;

rc = read_key(hctx, "snap_limit", &snap_limit);
if (rc == -ENOENT) {
rc = 0;
::encode(UINT64_MAX, *out);
} else {
::encode(snap_limit, *out);
int r = read_key(hctx, "snap_limit", &snap_limit);
if (r == -ENOENT) {
snap_limit = UINT64_MAX;
} else if (r < 0) {
CLS_ERR("error retrieving snapshot limit: %s", cpp_strerror(r).c_str());
return r;
}

CLS_LOG(20, "read snapshot limit %lu", snap_limit);
return rc;
::encode(snap_limit, *out);

return 0;
}

int snapshot_set_limit(cls_method_context_t hctx, bufferlist *in,
Expand Down Expand Up @@ -3777,7 +3777,10 @@ int mirror_peer_add(cls_method_context_t hctx, bufferlist *in,

std::string mirror_uuid;
r = mirror::uuid_get(hctx, &mirror_uuid);
if (mirror_peer.uuid == mirror_uuid) {
if (r < 0) {
CLS_ERR("error retrieving mirroring uuid: %s", cpp_strerror(r).c_str());
return r;
} else if (mirror_peer.uuid == mirror_uuid) {
CLS_ERR("peer uuid '%s' matches pool mirroring uuid",
mirror_uuid.c_str());
return -EINVAL;
Expand Down
4 changes: 2 additions & 2 deletions src/librbd/AioImageRequest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ uint64_t AioImageWrite<I>::append_journal_event(
const AioObjectRequests &requests, bool synchronous) {
I &image_ctx = this->m_image_ctx;

uint64_t tid;
uint64_t tid = 0;
uint64_t buffer_offset = 0;
assert(!this->m_image_extents.empty());
for (auto &extent : this->m_image_extents) {
Expand Down Expand Up @@ -561,7 +561,7 @@ uint64_t AioImageDiscard<I>::append_journal_event(
const AioObjectRequests &requests, bool synchronous) {
I &image_ctx = this->m_image_ctx;

uint64_t tid;
uint64_t tid = 0;
assert(!this->m_image_extents.empty());
for (auto &extent : this->m_image_extents) {
journal::EventEntry event_entry(journal::AioDiscardEvent(extent.first,
Expand Down
2 changes: 1 addition & 1 deletion src/librbd/image/CreateRequest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ Context *CreateRequest<I>::handle_negotiate_features(int *result) {
ldout(m_cct, 20) << __func__ << ": r=" << *result << dendl;

uint64_t all_features;
if (*result == 0) {
if (*result >= 0) {
bufferlist::iterator it = m_outbl.begin();
*result = cls_client::get_all_features_finish(&it, &all_features);
}
Expand Down
1 change: 1 addition & 0 deletions src/librbd/internal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3062,6 +3062,7 @@ void filter_out_mirror_watchers(ImageCtx *ictx,
if (r < 0) {
lderr(cct) << "error enabling mirroring for image "
<< img_pair.first << ": " << cpp_strerror(r) << dendl;
img_ctx->state->close();
return r;
}

Expand Down

0 comments on commit 5b97cce

Please sign in to comment.