mirror of
https://github.com/ceph/ceph
synced 2025-01-03 01:22:53 +00:00
Merge pull request #12954 from dillaman/wip-rbd-coverity
rbd: correct coverity warnings Reviewed-by: Mykola Golub <mgolub@mirantis.com>
This commit is contained in:
commit
c4131810ef
@ -448,17 +448,18 @@ int get_pool_journal_names(const po::variables_map &vm,
|
||||
}
|
||||
}
|
||||
|
||||
if (pool_name->empty()) {
|
||||
if (pool_name != nullptr && pool_name->empty()) {
|
||||
*pool_name = at::DEFAULT_POOL_NAME;
|
||||
}
|
||||
|
||||
if (journal_name != nullptr && journal_name->empty() && !image_name.empty()) {
|
||||
if (pool_name != nullptr && journal_name != nullptr &&
|
||||
journal_name->empty() && !image_name.empty()) {
|
||||
// Try to get journal name from image info.
|
||||
librados::Rados rados;
|
||||
librados::IoCtx io_ctx;
|
||||
librbd::Image image;
|
||||
int r = init_and_open_image(*pool_name, image_name, "", true,
|
||||
&rados, &io_ctx, &image);
|
||||
int r = init_and_open_image(*pool_name, image_name, "", true, &rados,
|
||||
&io_ctx, &image);
|
||||
if (r < 0) {
|
||||
std::cerr << "rbd: failed to open image " << image_name
|
||||
<< " to get journal name: " << cpp_strerror(r) << std::endl;
|
||||
|
@ -160,7 +160,9 @@ static int do_merge_diff(const char *first, const char *second,
|
||||
|
||||
string f_from, f_to;
|
||||
string s_from, s_to;
|
||||
uint64_t f_size, s_size, pc_size;
|
||||
uint64_t f_size = 0;
|
||||
uint64_t s_size = 0;
|
||||
uint64_t pc_size;
|
||||
|
||||
__u8 f_tag = 0, s_tag = 0;
|
||||
uint64_t f_off = 0, f_len = 0;
|
||||
@ -199,7 +201,6 @@ static int do_merge_diff(const char *first, const char *second,
|
||||
|
||||
//We just handle the case like 'banner, [ftag], [ttag], stag, [wztag]*,etag',
|
||||
// and the (offset,length) in wztag must be ascending order.
|
||||
|
||||
r = parse_diff_header(fd, &f_tag, &f_from, &f_to, &f_size);
|
||||
if (r < 0) {
|
||||
std::cerr << "rbd: failed to parse first diff header" << std::endl;
|
||||
@ -323,6 +324,10 @@ static int do_merge_diff(const char *first, const char *second,
|
||||
if (delta > f_len)
|
||||
delta = f_len;
|
||||
r = accept_diff_body(fd, pd, f_tag, f_off, delta);
|
||||
if (r < 0) {
|
||||
std::cerr << "rbd: failed to merge diff chunk" << std::endl;
|
||||
goto done;
|
||||
}
|
||||
f_off += delta;
|
||||
f_len -= delta;
|
||||
|
||||
@ -361,11 +366,16 @@ static int do_merge_diff(const char *first, const char *second,
|
||||
assert(f_off >= s_off + s_len);
|
||||
if (s_len) {
|
||||
r = accept_diff_body(sd, pd, s_tag, s_off, s_len);
|
||||
if (r < 0) {
|
||||
std::cerr << "rbd: failed to merge diff chunk" << std::endl;
|
||||
goto done;
|
||||
}
|
||||
s_off += s_len;
|
||||
s_len = 0;
|
||||
s_tag = 0;
|
||||
} else
|
||||
} else {
|
||||
assert(f_end && s_end);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -470,6 +470,9 @@ int execute_set_limit(const po::variables_map &vm) {
|
||||
int r = utils::get_pool_image_snapshot_names(
|
||||
vm, at::ARGUMENT_MODIFIER_NONE, &arg_index, &pool_name, &image_name,
|
||||
&snap_name, utils::SNAPSHOT_PRESENCE_NONE, utils::SPEC_VALIDATION_NONE);
|
||||
if (r < 0) {
|
||||
return r;
|
||||
}
|
||||
|
||||
if (vm.count(at::LIMIT)) {
|
||||
limit = vm[at::LIMIT].as<uint64_t>();
|
||||
@ -509,6 +512,9 @@ int execute_clear_limit(const po::variables_map &vm) {
|
||||
int r = utils::get_pool_image_snapshot_names(
|
||||
vm, at::ARGUMENT_MODIFIER_NONE, &arg_index, &pool_name, &image_name,
|
||||
&snap_name, utils::SNAPSHOT_PRESENCE_NONE, utils::SPEC_VALIDATION_NONE);
|
||||
if (r < 0) {
|
||||
return r;
|
||||
}
|
||||
|
||||
librados::Rados rados;
|
||||
librados::IoCtx io_ctx;
|
||||
|
@ -283,6 +283,7 @@ private:
|
||||
break;
|
||||
default:
|
||||
derr << *pctx << ": invalid request command" << dendl;
|
||||
c->release();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user