Merge pull request #5857 from ceph/wip-da-SCA-20150812

SCA and compiler warning fixes

Reviewed-by: Kefu Chai <kchai@redhat.com>
This commit is contained in:
Kefu Chai 2015-09-17 18:54:24 +08:00
commit b8dc21e8b6
16 changed files with 35 additions and 31 deletions

1
src/.gitignore vendored
View File

@ -25,6 +25,7 @@ Makefile
/ceph-mon
/ceph-osd
/ceph-syn
/ceph.tmpe
/ceph.conf
/ceph_bench_log
/ceph-objectstore-tool

View File

@ -4560,12 +4560,6 @@ void Client::handle_cap_grant(MetaSession *session, Inode *in, Cap *cap, MClient
int Client::check_permissions(Inode *in, int flags, int uid, int gid)
{
// initial number of group entries, defaults to posix standard of 16
// PAM implementations may provide more than 16 groups....
#if HAVE_GETGROUPLIST
int initial_group_count = 16;
#endif
gid_t *sgids = NULL;
int sgid_count = 0;
if (getgroups_cb) {
@ -4578,7 +4572,9 @@ int Client::check_permissions(Inode *in, int flags, int uid, int gid)
#if HAVE_GETGROUPLIST
else {
//use PAM to get the group list
sgid_count = initial_group_count;
// initial number of group entries, defaults to posix standard of 16
// PAM implementations may provide more than 16 groups....
sgid_count = 16;
sgids = (gid_t*)malloc(sgid_count * sizeof(gid_t));
if (sgids == NULL) {
ldout(cct, 3) << "allocating group memory failed" << dendl;
@ -4588,6 +4584,7 @@ int Client::check_permissions(Inode *in, int flags, int uid, int gid)
pw = getpwuid(uid);
if (pw == NULL) {
ldout(cct, 3) << "getting user entry failed" << dendl;
free(sgids);
return -EACCES;
}
while (1) {
@ -4597,11 +4594,13 @@ int Client::check_permissions(Inode *in, int flags, int uid, int gid)
if (getgrouplist(pw->pw_name, gid, sgids, &sgid_count) == -1) {
#endif
// we need to resize the group list and try again
sgids = (gid_t*)realloc(sgids, sgid_count * sizeof(gid_t));
if (sgids == NULL) {
void *_realloc = NULL;
if ((_realloc = realloc(sgids, sgid_count * sizeof(gid_t))) == NULL) {
ldout(cct, 3) << "allocating group memory failed" << dendl;
free(sgids);
return -EACCES;
}
sgids = (gid_t*)_realloc;
continue;
}
// list was successfully retrieved

View File

@ -40,7 +40,7 @@ class BufferlistSource : public snappy::Source {
}
virtual void Skip(size_t n) {
if (n + pb_off == pb->length()) {
pb++;
++pb;
pb_off = 0;
} else {
pb_off += n;

View File

@ -289,7 +289,7 @@ ErasureCodeShecTableCache::putDecodingTableToCache(int* decoding_matrix,
// allocate a new buffer
lru_list_t::iterator it_end = decode_tbls_lru->end();
it_end--;
--it_end;
lru_entry_t &map_value =
(*decode_tbls_map)[signature] =

View File

@ -8167,7 +8167,7 @@ void MDCache::_open_ino_parent_opened(inodeno_t ino, int ret)
_open_ino_traverse_dir(ino, info, 0);
} else {
if (ret >= 0) {
mds_rank_t checked_rank;
mds_rank_t checked_rank = mds_rank_t(ret);
info.check_peers = true;
info.auth_hint = checked_rank;
info.checked.erase(checked_rank);

View File

@ -139,8 +139,12 @@ MDSDaemon::MDSDaemon(const std::string &n, Messenger *m, MonClient *mc) :
MDSDaemon::~MDSDaemon() {
Mutex::Locker lock(mds_lock);
if (mds_rank) {delete mds_rank ; mds_rank = NULL; }
if (objecter) {delete objecter ; objecter = NULL; }
delete mds_rank;
mds_rank = NULL;
delete objecter;
objecter = NULL;
delete mdsmap;
mdsmap = NULL;
delete authorize_handler_service_registry;
delete authorize_handler_cluster_registry;

View File

@ -91,13 +91,14 @@ void ConfigKeyService::store_list(stringstream &ss)
bool ConfigKeyService::service_dispatch(MonOpRequestRef op)
{
Message *m = op->get_req();
assert(m != NULL);
dout(10) << __func__ << " " << *m << dendl;
if (!in_quorum()) {
dout(1) << __func__ << " not in quorum -- ignore message" << dendl;
return false;
}
assert(m != NULL);
assert(m->get_type() == MSG_MON_COMMAND);
MMonCommand *cmd = static_cast<MMonCommand*>(m);

View File

@ -2024,7 +2024,7 @@ int KeyValueStore::_zero(coll_t cid, const ghobject_t& oid, uint64_t offset,
r = check_get_rc(header->cid, header->oid, r, lookup_keys.size() == values.size());
if (r < 0)
return r;
for(set<string>::iterator it = lookup_keys.begin(); it != lookup_keys.end(); it++)
for(set<string>::iterator it = lookup_keys.begin(); it != lookup_keys.end(); ++it)
{
pair<uint64_t, uint64_t> p = off_len[*it];
values[*it].zero(p.first, p.second);

View File

@ -284,7 +284,7 @@ void ObjectStore::Transaction::_build_actions_from_tbl()
assert(ocid2 == ocid);
assert(oid2 == oid);
collection_move(ncid, ocid, oid);
collection_move_rename(ocid, oid, ncid, oid);
}
break;

View File

@ -463,7 +463,7 @@ int NewStore::OnodeHashLRU::trim(int max)
int num = onode_map.size() - max;
lru_list_t::iterator p = lru.end();
if (num)
p--;
--p;
while (num > 0) {
Onode *o = &*p;
int refs = o->nref.read();
@ -2486,7 +2486,7 @@ void NewStore::_kv_sync_thread()
if (!g_conf->newstore_sync_submit_transaction) {
for (std::deque<TransContext *>::iterator it = kv_committing.begin();
it != kv_committing.end();
it++) {
++it) {
db->submit_transaction((*it)->t);
}
}
@ -2496,7 +2496,7 @@ void NewStore::_kv_sync_thread()
KeyValueDB::Transaction txc_cleanup_sync = db->get_transaction();
for (std::deque<TransContext *>::iterator it = wal_cleaning.begin();
it != wal_cleaning.end();
it++) {
++it) {
wal_transaction_t& wt =*(*it)->wal_txn;
// cleanup the data in overlays
for (list<wal_op_t>::iterator p = wt.ops.begin(); p != wt.ops.end(); ++p) {

View File

@ -8826,7 +8826,7 @@ void OSD::set_pool_last_map_marked_full(OSDMap *o, epoch_t &e)
{
map<int64_t, epoch_t> &pool_last_map_marked_full = superblock.pool_last_map_marked_full;
for (map<int64_t, pg_pool_t>::const_iterator it = o->get_pools().begin();
it != o->get_pools().end(); it++) {
it != o->get_pools().end(); ++it) {
bool exist = pool_last_map_marked_full.count(it->first);
if (it->second.has_flag(pg_pool_t::FLAG_FULL) && !exist)
pool_last_map_marked_full[it->first] = e;

View File

@ -12368,7 +12368,7 @@ void ReplicatedPG::setattrs_maybe_cache(
{
if (pool.info.require_rollback()) {
for (map<string, bufferlist>::iterator it = attrs.begin();
it != attrs.end(); it++ ) {
it != attrs.end(); ++it) {
op->pending_attrs[obc][it->first] = it->second;
}
}

View File

@ -1019,7 +1019,7 @@ void Objecter::handle_osd_map(MOSDMap *m)
bool was_pausewr = osdmap->test_flag(CEPH_OSDMAP_PAUSEWR) || cluster_full || _osdmap_has_pool_full();
map<int64_t, bool> pool_full_map;
for (map<int64_t, pg_pool_t>::const_iterator it = osdmap->get_pools().begin();
it != osdmap->get_pools().end(); it++)
it != osdmap->get_pools().end(); ++it)
pool_full_map[it->first] = it->second.has_flag(pg_pool_t::FLAG_FULL);
@ -2421,7 +2421,7 @@ bool Objecter::_osdmap_pool_full(const int64_t pool_id) const
bool Objecter::_osdmap_has_pool_full() const
{
for (map<int64_t, pg_pool_t>::const_iterator it = osdmap->get_pools().begin();
it != osdmap->get_pools().end(); it++) {
it != osdmap->get_pools().end(); ++it) {
if (it->second.has_flag(pg_pool_t::FLAG_FULL))
return true;
}
@ -2440,7 +2440,7 @@ bool Objecter::_osdmap_full_flag() const
void Objecter::update_pool_full_map(map<int64_t, bool>& pool_full_map)
{
for (map<int64_t, pg_pool_t>::const_iterator it = osdmap->get_pools().begin();
it != osdmap->get_pools().end(); it++) {
it != osdmap->get_pools().end(); ++it) {
if (pool_full_map.find(it->first) == pool_full_map.end()) {
pool_full_map[it->first] = it->second.has_flag(pg_pool_t::FLAG_FULL);
} else {

View File

@ -181,7 +181,6 @@ void RGWObjectExpirer::process_single_shard(const string& shard,
void RGWObjectExpirer::inspect_all_shards(const utime_t& last_run, const utime_t& round_start)
{
bool is_next_available;
utime_t shard_marker;
CephContext *cct = store->ctx();
@ -194,7 +193,7 @@ void RGWObjectExpirer::inspect_all_shards(const utime_t& last_run, const utime_t
ldout(store->ctx(), 20) << "proceeding shard = " << shard << dendl;
process_single_shard(shard, last_run, round_start);
} while (is_next_available);
}
return;
}

View File

@ -142,7 +142,7 @@ class SyntheticWorkload {
for (set<pair<uint64_t, uint64_t> >::iterator it = compress_jobs.begin();
it != compress_jobs.end();) {
prev = it;
it++;
++it;
ASSERT_EQ(0, async_compressor->get_compress_data(prev->first, data, blocking, &finished));
if (finished) {
c_reap++;
@ -157,7 +157,7 @@ class SyntheticWorkload {
for (set<pair<uint64_t, uint64_t> >::iterator it = decompress_jobs.begin();
it != decompress_jobs.end();) {
prev = it;
it++;
++it;
ASSERT_EQ(0, async_compressor->get_decompress_data(prev->first, data, blocking, &finished));
if (finished) {
d_reap++;

View File

@ -396,7 +396,7 @@ TEST_F(TestInternal, MetadatConfig) {
map<string, bufferlist> pairs;
r = librbd::metadata_list(ictx, "", 0, &pairs);
ASSERT_EQ(0, r);
ASSERT_EQ(5, pairs.size());
ASSERT_EQ(5u, pairs.size());
r = librbd::metadata_remove(ictx, "abcd");
ASSERT_EQ(0, r);
r = librbd::metadata_remove(ictx, "xyz");
@ -404,7 +404,7 @@ TEST_F(TestInternal, MetadatConfig) {
pairs.clear();
r = librbd::metadata_list(ictx, "", 0, &pairs);
ASSERT_EQ(0, r);
ASSERT_EQ(3, pairs.size());
ASSERT_EQ(3u, pairs.size());
string val;
r = librbd::metadata_get(ictx, it->first, &val);
ASSERT_EQ(0, r);