Skip to content

Commit

Permalink
Merge pull request #13208 from ceph/wip-dalgaaf-sca-20170131
Browse files Browse the repository at this point in the history
misc: SCA and Coverity Fixes

Reviewed-by: Sage Weil <sage@redhat.com>
  • Loading branch information
liewegas committed Feb 9, 2017
2 parents f95627f + ce5493c commit 3af6e99
Show file tree
Hide file tree
Showing 15 changed files with 50 additions and 47 deletions.
2 changes: 1 addition & 1 deletion src/cls/rgw/cls_rgw.cc
Expand Up @@ -3414,7 +3414,7 @@ static int rgw_cls_lc_list_entries(cls_method_context_t hctx, bufferlist *in, bu
return ret;
map<string, bufferlist>::iterator it;
pair<string, int> entry;
for (it = vals.begin(); it != vals.end(); it++) {
for (it = vals.begin(); it != vals.end(); ++it) {
iter = it->second.begin();
try {
::decode(entry, iter);
Expand Down
1 change: 1 addition & 0 deletions src/common/Checksummer.h
Expand Up @@ -223,6 +223,7 @@ class Checksummer {
if (bad_csum) {
*bad_csum = v;
}
Alg::fini(&state);
return pos;
}
++pv;
Expand Down
8 changes: 4 additions & 4 deletions src/kv/MemDB.cc
Expand Up @@ -81,7 +81,7 @@ void MemDB::_save()
while (iter != m_map.end()) {
dout(10) << __func__ << " Key:"<< iter->first << dendl;
_encode(iter, bl);
iter++;
++iter;
}
bl.write_fd(fd);

Expand Down Expand Up @@ -484,7 +484,7 @@ int MemDB::MDBWholeSpaceIteratorImpl::next()
return -1;
}
free_last();
m_iter++;
++m_iter;
if (m_iter != m_map_p->end()) {
fill_current();
return 0;
Expand All @@ -502,7 +502,7 @@ int MemDB::MDBWholeSpaceIteratorImpl:: prev()
}
free_last();
if (m_iter != m_map_p->begin()) {
m_iter--;
--m_iter;
fill_current();
return 0;
} else {
Expand Down Expand Up @@ -536,7 +536,7 @@ int MemDB::MDBWholeSpaceIteratorImpl::seek_to_last(const std::string &k)
free_last();
if (k.empty()) {
m_iter = m_map_p->end();
m_iter--;
--m_iter;
} else {
m_iter = m_map_p->lower_bound(k);
}
Expand Down
2 changes: 0 additions & 2 deletions src/libradosstriper/RadosStriperImpl.cc
Expand Up @@ -676,7 +676,6 @@ int libradosstriper::RadosStriperImpl::aio_generic_stat
// nothing is really started so cancel everything
delete multi_completion;
delete cdata;
delete stat_completion;
return rc;
}
// use a regular AioCompletion for the getxattr async call
Expand All @@ -692,7 +691,6 @@ int libradosstriper::RadosStriperImpl::aio_generic_stat
// the async stat is ongoing, so we need to go on
// we mark the getxattr as failed in the data object
cdata->m_getxattrRC = rc;
delete getxattr_completion;
multi_completion->complete_request(rc);
multi_completion->put();
return rc;
Expand Down
2 changes: 1 addition & 1 deletion src/mds/Mantle.cc
Expand Up @@ -117,7 +117,7 @@ int Mantle::balance(const string &script,
/* push values into this mds's table; setfield assigns key/pops val */
for (map<string, double>::const_iterator it = metrics[i].begin();
it != metrics[i].end();
it++) {
++it) {
lua_pushnumber(L, it->second);
lua_setfield(L, -2, it->first.c_str());
}
Expand Down
2 changes: 1 addition & 1 deletion src/mon/OSDMonitor.cc
Expand Up @@ -8282,7 +8282,7 @@ bool OSDMonitor::_check_become_tier(
if (tier_pool->has_tiers()) {
*ss << "pool '" << tier_pool_name << "' has following tier(s) already:";
for (set<uint64_t>::iterator it = tier_pool->tiers.begin();
it != tier_pool->tiers.end(); it++)
it != tier_pool->tiers.end(); ++it)
*ss << "'" << osdmap.get_pool_name(*it) << "',";
*ss << " multiple tiers are not yet supported.";
*err = -EINVAL;
Expand Down
2 changes: 1 addition & 1 deletion src/msg/async/rdma/RDMAConnectedSocketImpl.cc
Expand Up @@ -309,7 +309,7 @@ ssize_t RDMAConnectedSocketImpl::read_buffers(char* buf, size_t len)
}

if (c != buffers.end() && (*c)->over())
c++;
++c;
buffers.erase(buffers.begin(), c);
ldout(cct, 25) << __func__ << " got " << read << " bytes, buffers size: " << buffers.size() << dendl;
return read;
Expand Down
2 changes: 1 addition & 1 deletion src/osdc/ObjectCacher.cc
Expand Up @@ -1027,7 +1027,7 @@ void ObjectCacher::bh_write_scattered(list<BufferHead*>& blist)
if (bh->snapc.seq > snapc.seq)
snapc = bh->snapc;
if (bh->last_write > last_write)
bh->last_write = bh->last_write;
last_write = bh->last_write;
}

C_WriteCommit *oncommit = new C_WriteCommit(this, ob->oloc.pool, ob->get_soid(), ranges);
Expand Down
10 changes: 5 additions & 5 deletions src/rgw/rgw_common.cc
Expand Up @@ -1491,15 +1491,15 @@ static int match_internal(boost::string_ref pattern, boost::string_ref input, in
if (*it1 == '*' && (it1 + 1) == pattern.end() && it2 == input.end())
return 0;
if (function(*it1, *it2) || *it1 == '?') {
it1++;
it2++;
++it1;
++it2;
continue;
}
if (*it1 == '*') {
if (function(*(it1 + 1), *it2))
it1++;
++it1;
else
it2++;
++it2;
continue;
}
return 0;
Expand Down Expand Up @@ -1550,4 +1550,4 @@ int match(const string& pattern, const string& input, int flag)
last_pos_pattern = cur_pos_pattern + 1;
last_pos_input = cur_pos_input + 1;
}
}
}
2 changes: 1 addition & 1 deletion src/rgw/rgw_compression.cc
Expand Up @@ -107,7 +107,7 @@ int RGWGetObj_Decompress::handle_data(bufferlist& bl, off_t bl_ofs, off_t bl_len
tmp_out.copy(0, q_len, out_bl);
else
out_bl.append(tmp_out);
first_block++;
++first_block;
}

if (first_data && partial_content && out_bl.length() != 0)
Expand Down
10 changes: 5 additions & 5 deletions src/rgw/rgw_lc.cc
Expand Up @@ -274,7 +274,7 @@ int RGWLC::bucket_lc_process(string& shard_id)
}

map<string, int>& prefix_map = config.get_prefix_map();
for(map<string, int>::iterator prefix_iter = prefix_map.begin(); prefix_iter != prefix_map.end(); prefix_iter++) {
for(map<string, int>::iterator prefix_iter = prefix_map.begin(); prefix_iter != prefix_map.end(); ++prefix_iter) {
if (prefix_iter->first.empty()) {
default_config = true;
default_days = prefix_iter->second;
Expand All @@ -298,12 +298,12 @@ int RGWLC::bucket_lc_process(string& shard_id)
vector<RGWObjEnt>::iterator obj_iter;
int pos = 0;
utime_t now = ceph_clock_now();
for (obj_iter = objs.begin(); obj_iter != objs.end(); obj_iter++) {
for (obj_iter = objs.begin(); obj_iter != objs.end(); ++obj_iter) {
bool prefix_match = false;
int match_days = 0;
map<string, int>& prefix_map = config.get_prefix_map();

for(map<string, int>::iterator prefix_iter = prefix_map.begin(); prefix_iter != prefix_map.end(); prefix_iter++) {
for(map<string, int>::iterator prefix_iter = prefix_map.begin(); prefix_iter != prefix_map.end(); ++prefix_iter) {
if (prefix_iter->first.empty()) {
continue;
}
Expand Down Expand Up @@ -343,7 +343,7 @@ int RGWLC::bucket_lc_process(string& shard_id)
}
} while (is_truncated);
} else {
for(map<string, int>::iterator prefix_iter = prefix_map.begin(); prefix_iter != prefix_map.end(); prefix_iter++) {
for(map<string, int>::iterator prefix_iter = prefix_map.begin(); prefix_iter != prefix_map.end(); ++prefix_iter) {
if (prefix_iter->first.empty()) {
continue;
}
Expand All @@ -366,7 +366,7 @@ int RGWLC::bucket_lc_process(string& shard_id)
int days = prefix_iter->second;
utime_t now = ceph_clock_now();

for (obj_iter = objs.begin(); obj_iter != objs.end(); obj_iter++) {
for (obj_iter = objs.begin(); obj_iter != objs.end(); ++obj_iter) {
if (obj_has_expired(now - ceph::real_clock::to_time_t((*obj_iter).mtime), days)) {
RGWObjectCtx rctx(store);
rgw_obj obj(bucket_info.bucket, (*obj_iter).key.name);
Expand Down
44 changes: 24 additions & 20 deletions src/rgw/rgw_main.cc
Expand Up @@ -250,6 +250,7 @@ int main(int argc, const char **argv)
RGWFrontendConfig *config = new RGWFrontendConfig(f);
int r = config->init();
if (r < 0) {
delete config;
cerr << "ERROR: failed to init config: " << f << std::endl;
return EINVAL;
}
Expand Down Expand Up @@ -458,26 +459,7 @@ int main(int argc, const char **argv)
RGWFrontendConfig *config = fiter->second;
string framework = config->get_framework();
RGWFrontend *fe = NULL;
#if defined(WITH_RADOSGW_ASIO_FRONTEND)
if ((framework == "asio") &&
cct->check_experimental_feature_enabled("rgw-asio-frontend")) {
int port;
config->get_val("port", 80, &port);
std::string uri_prefix;
config->get_val("prefix", "", &uri_prefix);
RGWProcessEnv env{ store, &rest, olog, port, uri_prefix };
fe = new RGWAsioFrontend(env);
}
#endif /* WITH_RADOSGW_ASIO_FRONTEND */
#if defined(WITH_RADOSGW_FCGI_FRONTEND)
if (framework == "fastcgi" || framework == "fcgi") {
std::string uri_prefix;
config->get_val("prefix", "", &uri_prefix);
RGWProcessEnv fcgi_pe = { store, &rest, olog, 0, uri_prefix };

fe = new RGWFCGXFrontend(fcgi_pe, config);
}
#endif /* WITH_RADOSGW_FCGI_FRONTEND */
if (framework == "civetweb" || framework == "mongoose") {
int port;
config->get_val("port", 80, &port);
Expand All @@ -488,7 +470,7 @@ int main(int argc, const char **argv)

fe = new RGWCivetWebFrontend(env, config);
}
if (framework == "loadgen") {
else if (framework == "loadgen") {
int port;
config->get_val("port", 80, &port);
std::string uri_prefix;
Expand All @@ -498,10 +480,32 @@ int main(int argc, const char **argv)

fe = new RGWLoadGenFrontend(env, config);
}
#if defined(WITH_RADOSGW_ASIO_FRONTEND)
else if ((framework == "asio") &&
cct->check_experimental_feature_enabled("rgw-asio-frontend")) {
int port;
config->get_val("port", 80, &port);
std::string uri_prefix;
config->get_val("prefix", "", &uri_prefix);
RGWProcessEnv env{ store, &rest, olog, port, uri_prefix };
fe = new RGWAsioFrontend(env);
}
#endif /* WITH_RADOSGW_ASIO_FRONTEND */
#if defined(WITH_RADOSGW_FCGI_FRONTEND)
else if (framework == "fastcgi" || framework == "fcgi") {
std::string uri_prefix;
config->get_val("prefix", "", &uri_prefix);
RGWProcessEnv fcgi_pe = { store, &rest, olog, 0, uri_prefix };

fe = new RGWFCGXFrontend(fcgi_pe, config);
}
#endif /* WITH_RADOSGW_FCGI_FRONTEND */

if (fe == NULL) {
dout(0) << "WARNING: skipping unknown framework: " << framework << dendl;
continue;
}

dout(0) << "starting handler: " << fiter->first << dendl;
int r = fe->init();
if (r < 0) {
Expand Down
4 changes: 2 additions & 2 deletions src/rgw/rgw_rados.cc
Expand Up @@ -1288,7 +1288,7 @@ void RGWPeriod::update(const RGWZoneGroupMap& map)
{
ldout(cct, 20) << __func__ << " realm " << realm_id << " period " << id << dendl;
for (std::map<string, RGWZoneGroup>::const_iterator iter = map.zonegroups.begin();
iter != map.zonegroups.end(); iter++) {
iter != map.zonegroups.end(); ++iter) {
period_map.zonegroups_by_api[iter->second.api_name] = iter->second;
period_map.zonegroups[iter->second.get_name()] = iter->second;
}
Expand Down Expand Up @@ -3608,7 +3608,7 @@ int RGWRados::replace_region_with_zonegroup()
}
}
for (map<string, RGWZone>::const_iterator iter = zonegroup.zones.begin(); iter != zonegroup.zones.end();
iter ++) {
++iter) {
ldout(cct, 0) << "Converting zone" << iter->first << dendl;
RGWZoneParams zoneparams(iter->first, iter->first);
zoneparams.set_id(iter->first);
Expand Down
4 changes: 2 additions & 2 deletions src/rgw/rgw_token.h
Expand Up @@ -109,7 +109,7 @@ namespace rgw {
::decode(name, bl);
::decode(version, bl);
::decode(typestr, bl);
type = to_type(typestr.c_str());
type = to_type(typestr);
::decode(id, bl);
::decode(key, bl);
DECODE_FINISH(bl);
Expand All @@ -135,7 +135,7 @@ namespace rgw {
string typestr;
JSONDecoder::decode_json("version", version, obj);
JSONDecoder::decode_json("type", typestr, obj);
type = to_type(typestr.c_str());
type = to_type(typestr);
JSONDecoder::decode_json("id", id, obj);
JSONDecoder::decode_json("key", key, obj);
}
Expand Down
2 changes: 1 addition & 1 deletion src/rgw/rgw_torrent.cc
Expand Up @@ -160,7 +160,7 @@ int seed::sha1_process()

SHA1 h;
list<bufferlist>::iterator iter = torrent_bl.begin();
for (; iter != torrent_bl.end(); iter++)
for (; iter != torrent_bl.end(); ++iter)
{
bufferlist &bl_info = *iter;
sha1(&h, bl_info, (*iter).length());
Expand Down

0 comments on commit 3af6e99

Please sign in to comment.