1
0
mirror of https://github.com/ceph/ceph synced 2025-04-01 14:51:13 +00:00

Merge pull request from ceph/wip-coverity

Reviewed-by: Yehuda Sadeh <yehuda@inktank.com>
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
This commit is contained in:
Sage Weil 2013-05-09 12:47:47 -07:00
commit c191461636
12 changed files with 52 additions and 32 deletions

View File

@ -692,7 +692,8 @@ extern "C" int rbd_open(rados_ioctx_t p, const char *name, rbd_image_t *image,
librbd::ImageCtx *ictx = new librbd::ImageCtx(name, "", snap_name, io_ctx,
false);
int r = librbd::open_image(ictx);
*image = (rbd_image_t)ictx;
if (r >= 0)
*image = (rbd_image_t)ictx;
return r;
}
@ -704,7 +705,8 @@ extern "C" int rbd_open_read_only(rados_ioctx_t p, const char *name,
librbd::ImageCtx *ictx = new librbd::ImageCtx(name, "", snap_name, io_ctx,
true);
int r = librbd::open_image(ictx);
*image = (rbd_image_t)ictx;
if (r >= 0)
*image = (rbd_image_t)ictx;
return r;
}

View File

@ -10869,7 +10869,7 @@ void MDCache::dump_cache(const char *fn)
string t = tt.str();
r = safe_write(fd, t.c_str(), t.length());
if (r < 0)
return;
goto out;
for (CDir::map_t::iterator q = dir->items.begin();
q != dir->items.end();
@ -10880,12 +10880,13 @@ void MDCache::dump_cache(const char *fn)
string u = uu.str();
r = safe_write(fd, u.c_str(), u.length());
if (r < 0)
return;
goto out;
}
dir->check_rstats();
}
}
out:
::close(fd);
}

View File

@ -2624,6 +2624,7 @@ void Monitor::handle_command(MMonCommand *m)
} else if (string(args[0]) == "df") {
if (args.size() > 1) {
if (string(args[1]) != "detail") {
delete jf;
r = -EINVAL;
rs = "usage: df [detail]";
goto out;

View File

@ -4015,7 +4015,7 @@ int FileStore::_setattrs(coll_t cid, const hobject_t& oid, map<string,bufferptr>
r = _fsetattrs(fd, inline_to_set);
if (r < 0)
return r;
goto out_close;
if (!omap_remove.empty()) {
assert(g_conf->filestore_xattr_use_omap);

View File

@ -170,6 +170,7 @@ OSDService::OSDService(OSD *osd) :
scrubs_active(0),
watch_lock("OSD::watch_lock"),
watch_timer(osd->client_messenger->cct, watch_lock),
next_notif_id(0),
backfill_request_lock("OSD::backfill_request_lock"),
backfill_request_timer(g_ceph_context, backfill_request_lock, false),
last_tid(0),
@ -905,6 +906,7 @@ OSD::OSD(int id, Messenger *internal_messenger, Messenger *external_messenger,
heartbeat_dispatcher(this),
stat_lock("OSD::stat_lock"),
finished_lock("OSD::finished_lock"),
test_ops_hook(NULL),
op_wq(this, g_conf->osd_op_thread_timeout, &op_tp),
peering_wq(this, g_conf->osd_op_thread_timeout, &op_tp, 200),
map_lock("OSD::map_lock"),

View File

@ -192,25 +192,28 @@ static int do_get(IoCtx& io_ctx, const char *objname, const char *outfile, unsig
}
uint64_t offset = 0;
int ret;
while (true) {
bufferlist outdata;
int ret = io_ctx.read(oid, outdata, op_size, offset);
ret = io_ctx.read(oid, outdata, op_size, offset);
if (ret <= 0) {
return ret;
goto out;
}
ret = outdata.write_fd(fd);
if (ret < 0) {
cerr << "error writing to file: " << cpp_strerror(ret) << std::endl;
return ret;
goto out;
}
if (outdata.length() < op_size)
break;
offset += outdata.length();
}
ret = 0;
out:
if (fd != 1)
TEMP_FAILURE_RETRY(::close(fd));
return 0;
return ret;
}
static int do_copy(IoCtx& io_ctx, const char *objname, IoCtx& target_ctx, const char *target_obj)
@ -412,6 +415,7 @@ static int do_put(IoCtx& io_ctx, const char *objname, const char *infile, int op
ret = 0;
out:
TEMP_FAILURE_RETRY(close(fd));
delete[] buf;
return ret;
}

View File

@ -1301,7 +1301,7 @@ static int do_import(librbd::RBD &rbd, librados::IoCtx& io_ctx,
if (fd < 0) {
r = -errno;
cerr << "rbd: error opening " << path << std::endl;
return r;
goto done2;
}
r = fstat(fd, &stat_buf);
@ -1394,7 +1394,8 @@ static int do_import(librbd::RBD &rbd, librados::IoCtx& io_ctx,
pc.finish();
close(fd);
}
done2:
delete[] p;
return r;
}

View File

@ -399,24 +399,26 @@ static int read_input(const string& infile, bufferlist& bl)
#define READ_CHUNK 8196
int r;
int err;
do {
char buf[READ_CHUNK];
r = read(fd, buf, READ_CHUNK);
if (r < 0) {
int err = -errno;
err = -errno;
cerr << "error while reading input" << std::endl;
return err;
goto out;
}
bl.append(buf, r);
} while (r > 0);
err = 0;
out:
if (infile.size()) {
close(fd);
}
return 0;
return err;
}
template <class T>

View File

@ -173,7 +173,7 @@ class RGWBucket
private:
public:
RGWBucket() : store(NULL), failure(false) {}
RGWBucket() : store(NULL), handle(NULL), failure(false) {}
int init(RGWRados *storage, RGWBucketAdminOpState& op_state);
int create_bucket(string bucket_str, string& user_id, string& display_name);

View File

@ -2784,9 +2784,12 @@ struct get_obj_data : public RefCountedObject {
atomic_t err_code;
Throttle throttle;
get_obj_data(CephContext *_cct) : cct(_cct),
total_read(0), lock("get_obj_data"), data_lock("get_obj_data::data_lock"),
throttle(cct, "get_obj_data", cct->_conf->rgw_get_obj_window_size, false) {}
get_obj_data(CephContext *_cct)
: cct(_cct),
rados(NULL), ctx(NULL),
total_read(0), lock("get_obj_data"), data_lock("get_obj_data::data_lock"),
client_cb(NULL),
throttle(cct, "get_obj_data", cct->_conf->rgw_get_obj_window_size, false) {}
virtual ~get_obj_data() { }
void set_cancelled(int r) {
cancelled.set(1);

View File

@ -526,9 +526,12 @@ static void dump_user_info(Formatter *f, RGWUserInfo &info)
RGWAccessKeyPool::RGWAccessKeyPool(RGWUser* usr)
{
user = usr;
swift_keys = NULL;
access_keys = NULL;
if (!user) {
keys_allowed = false;
store = NULL;
return;
}
@ -987,13 +990,10 @@ int RGWAccessKeyPool::remove(RGWUserAdminOpState& op_state, std::string *err_msg
RGWSubUserPool::RGWSubUserPool(RGWUser *usr)
{
if (!usr)
subusers_allowed = false;
subusers_allowed = true;
subusers_allowed = (usr != NULL);
store = usr->get_store();
user = usr;
subuser_map = NULL;
}
RGWSubUserPool::~RGWSubUserPool()
@ -1276,10 +1276,8 @@ int RGWSubUserPool::modify(RGWUserAdminOpState& op_state, std::string *err_msg,
RGWUserCapPool::RGWUserCapPool(RGWUser *usr)
{
user = usr;
if (!user) {
caps_allowed = false;
}
caps = NULL;
caps_allowed = (user != NULL);
}
RGWUserCapPool::~RGWUserCapPool()
@ -1392,7 +1390,7 @@ int RGWUserCapPool::remove(RGWUserAdminOpState& op_state, std::string *err_msg,
return 0;
}
RGWUser::RGWUser() : caps(this), keys(this), subusers(this)
RGWUser::RGWUser() : store(NULL), info_stored(false), caps(this), keys(this), subusers(this)
{
init_default();
}

View File

@ -253,10 +253,16 @@ struct metadata_section {
epoch_t map_epoch;
pg_info_t info;
pg_log_t log;
metadata_section(__u8 struct_ver, epoch_t map_epoch, const pg_info_t &info,
const pg_log_t &log): struct_ver(struct_ver),
map_epoch(map_epoch), info(info), log(log) { }
metadata_section() { }
const pg_log_t &log)
: struct_ver(struct_ver),
map_epoch(map_epoch),
info(info),
log(log) { }
metadata_section()
: struct_ver(0),
map_epoch(0) { }
void encode(bufferlist& bl) const {
ENCODE_START(1, 1, bl);