Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

librbd: resolve static analyser warnings #12863

Merged
merged 1 commit into from Jan 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 13 additions & 10 deletions src/cls/rbd/cls_rbd.cc
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
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
Expand Up @@ -412,7 +412,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
Expand Up @@ -3029,6 +3029,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