Skip to content

Commit

Permalink
Merge pull request ceph#102 from dalgaaf/wip-da-sca-style-4-v2
Browse files Browse the repository at this point in the history
Fixes for more cppcheck issues (v2 of ceph#101)

Reviewed-by: Sage Weil <[email protected]>
  • Loading branch information
liewegas committed Mar 12, 2013
2 parents 579d4ad + 72c6226 commit 34f1984
Show file tree
Hide file tree
Showing 23 changed files with 39 additions and 73 deletions.
4 changes: 2 additions & 2 deletions src/auth/Auth.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,12 +209,12 @@ struct RotatingSecrets {
}
ExpiringCryptoKey& current() {
map<uint64_t, ExpiringCryptoKey>::iterator p = secrets.begin();
p++;
++p;
return p->second;
}
const ExpiringCryptoKey& current() const {
map<uint64_t, ExpiringCryptoKey>::const_iterator p = secrets.begin();
p++;
++p;
return p->second;
}
ExpiringCryptoKey& next() {
Expand Down
2 changes: 1 addition & 1 deletion src/auth/cephx/CephxKeyServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ class KeyServer : public KeyStore {
void export_keyring(KeyRing& keyring) {
for (map<EntityName, EntityAuth>::iterator p = data.secrets.begin();
p != data.secrets.end();
p++) {
++p) {
keyring.add(p->first, p->second);
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/client/Inode.cc
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ int Inode::caps_issued(int *implemented)
int i = 0;
for (map<int,Cap*>::iterator it = caps.begin();
it != caps.end();
it++)
++it)
if (cap_is_valid(it->second)) {
c |= it->second->issued;
i |= it->second->implemented;
Expand Down Expand Up @@ -198,7 +198,7 @@ bool Inode::caps_issued_mask(unsigned mask)
// try any cap
for (map<int,Cap*>::iterator it = caps.begin();
it != caps.end();
it++) {
++it) {
if (cap_is_valid(it->second)) {
if ((it->second->issued & mask) == mask) {
touch_cap(it->second);
Expand All @@ -211,7 +211,7 @@ bool Inode::caps_issued_mask(unsigned mask)
// bah.. touch them all
for (map<int,Cap*>::iterator it = caps.begin();
it != caps.end();
it++)
++it)
touch_cap(it->second);
return true;
}
Expand All @@ -223,7 +223,7 @@ int Inode::caps_used()
int w = 0;
for (map<int,int>::iterator p = cap_refs.begin();
p != cap_refs.end();
p++)
++p)
if (p->second)
w |= p->first;
return w;
Expand All @@ -234,7 +234,7 @@ int Inode::caps_file_wanted()
int want = 0;
for (map<int,int>::iterator p = open_by_mode.begin();
p != open_by_mode.end();
p++)
++p)
if (p->second)
want |= ceph_caps_for_mode(p->first);
return want;
Expand Down
6 changes: 3 additions & 3 deletions src/client/SyntheticClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class SyntheticClient {
int get_random_fh() {
int r = rand() % open_files.size();
set<int>::iterator it = open_files.begin();
while (r--) it++;
while (r--) ++it;
return *it;
}

Expand All @@ -133,7 +133,7 @@ class SyntheticClient {
assert(!subdirs.empty());
int r = ((rand() % subdirs.size()) + (rand() % subdirs.size())) / 2; // non-uniform distn
set<string>::iterator it = subdirs.begin();
while (r--) it++;
while (r--) ++it;

n1 = cwd;
n1.push_dentry( *it );
Expand All @@ -148,7 +148,7 @@ class SyntheticClient {
r %= contents.size();

map<string,struct stat*>::iterator it = contents.begin();
while (r--) it++;
while (r--) ++it;

n2 = cwd;
n2.push_dentry( it->first );
Expand Down
2 changes: 1 addition & 1 deletion src/client/hadoop/CephFSInterface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ JNIEXPORT jobjectArray JNICALL Java_org_apache_hadoop_fs_ceph_CephTalker_ceph_1g
int i = 0;
for (list<string>::iterator it = contents.begin();
it != contents.end();
it++) {
++it) {
env->SetObjectArrayElement(dirListingStringArray, i,
env->NewStringUTF(it->c_str()));
++i;
Expand Down
4 changes: 2 additions & 2 deletions src/cls/rgw/cls_rgw.cc
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ static int usage_iterate_range(cls_method_context_t hctx, uint64_t start, uint64
return 0;
}
}
iter--;
--iter;
start_key = iter->first;
} while (true);
return 0;
Expand Down Expand Up @@ -1071,7 +1071,7 @@ static int gc_iterate_entries(cls_method_context_t hctx, const string& marker,
i++;

}
iter--;
--iter;
start_key = iter->first;
} while (true);
return 0;
Expand Down
38 changes: 16 additions & 22 deletions src/rgw/rgw_rados.cc
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ int RGWRados::log_list_init(const string& prefix, RGWAccessHandle *handle)

int RGWRados::log_list_next(RGWAccessHandle handle, string *name)
{
log_list_state *state = (log_list_state *)handle;
log_list_state *state = static_cast<log_list_state *>(handle);
while (true) {
if (state->obit == state->io_ctx.objects_end()) {
delete state;
Expand Down Expand Up @@ -474,7 +474,7 @@ int RGWRados::log_show_init(const string& name, RGWAccessHandle *handle)

int RGWRados::log_show_next(RGWAccessHandle handle, rgw_log_entry *entry)
{
log_show_state *state = (log_show_state *)handle;
log_show_state *state = static_cast<log_show_state *>(handle);
off_t off = state->p.get_off();

ldout(cct, 10) << "log_show_next pos " << state->pos << " bl " << state->bl.length()
Expand Down Expand Up @@ -974,7 +974,6 @@ int RGWRados::list_placement_set(set<string>& names)
{
bufferlist header;
map<string, bufferlist> m;
string pool_name;

rgw_obj obj(params.domain_root, avail_pools);
int ret = omap_get_all(obj, header, m);
Expand Down Expand Up @@ -1048,13 +1047,12 @@ int RGWRados::put_obj_meta(void *ctx, rgw_obj& obj, uint64_t size,
std::string oid, key;
get_obj_bucket_and_oid_key(obj, bucket, oid, key);
librados::IoCtx io_ctx;
RGWRadosCtx *rctx = (RGWRadosCtx *)ctx;
RGWRadosCtx *rctx = static_cast<RGWRadosCtx *>(ctx);

int r = open_bucket_ctx(bucket, io_ctx);
if (r < 0)
return r;


io_ctx.locator_set_key(key);

ObjectWriteOperation op;
Expand Down Expand Up @@ -1259,7 +1257,6 @@ int RGWRados::copy_obj(void *ctx,
int ret;
uint64_t total_len, obj_size;
time_t lastmod;
map<string, bufferlist>::iterator iter;
rgw_obj shadow_obj = dest_obj;
string shadow_oid;

Expand Down Expand Up @@ -1291,7 +1288,7 @@ int RGWRados::copy_obj(void *ctx,

RGWObjManifest manifest;
RGWObjState *astate = NULL;
RGWRadosCtx *rctx = (RGWRadosCtx *)ctx;
RGWRadosCtx *rctx = static_cast<RGWRadosCtx *>(ctx);
ret = get_obj_state(rctx, src_obj, &astate);
if (ret < 0)
return ret;
Expand Down Expand Up @@ -1680,7 +1677,7 @@ int RGWRados::bucket_rebuild_index(rgw_bucket& bucket)

int RGWRados::defer_gc(void *ctx, rgw_obj& obj)
{
RGWRadosCtx *rctx = (RGWRadosCtx *)ctx;
RGWRadosCtx *rctx = static_cast<RGWRadosCtx *>(ctx);
rgw_bucket bucket;
std::string oid, key;
get_obj_bucket_and_oid_key(obj, bucket, oid, key);
Expand Down Expand Up @@ -1723,7 +1720,7 @@ int RGWRados::delete_obj_impl(void *ctx, rgw_obj& obj)
std::string oid, key;
get_obj_bucket_and_oid_key(obj, bucket, oid, key);
librados::IoCtx io_ctx;
RGWRadosCtx *rctx = (RGWRadosCtx *)ctx;
RGWRadosCtx *rctx = static_cast<RGWRadosCtx *>(ctx);
int r = open_bucket_ctx(bucket, io_ctx);
if (r < 0)
return r;
Expand Down Expand Up @@ -1907,7 +1904,7 @@ int RGWRados::get_attr(void *ctx, rgw_obj& obj, const char *name, bufferlist& de
librados::IoCtx io_ctx;
rgw_bucket actual_bucket = bucket;
string actual_obj = oid;
RGWRadosCtx *rctx = (RGWRadosCtx *)ctx;
RGWRadosCtx *rctx = static_cast<RGWRadosCtx *>(ctx);

if (actual_obj.size() == 0) {
actual_obj = bucket.name;
Expand Down Expand Up @@ -2093,7 +2090,7 @@ int RGWRados::set_attr(void *ctx, rgw_obj& obj, const char *name, bufferlist& bl
librados::IoCtx io_ctx;
rgw_bucket actual_bucket = bucket;
string actual_obj = oid;
RGWRadosCtx *rctx = (RGWRadosCtx *)ctx;
RGWRadosCtx *rctx = static_cast<RGWRadosCtx *>(ctx);

if (actual_obj.size() == 0) {
actual_obj = bucket.name;
Expand Down Expand Up @@ -2142,7 +2139,7 @@ int RGWRados::set_attrs(void *ctx, rgw_obj& obj,
get_obj_bucket_and_oid_key(obj, bucket, oid, key);
librados::IoCtx io_ctx;
string actual_obj = oid;
RGWRadosCtx *rctx = (RGWRadosCtx *)ctx;
RGWRadosCtx *rctx = static_cast<RGWRadosCtx *>(ctx);
rgw_bucket actual_bucket = bucket;

if (actual_obj.size() == 0) {
Expand Down Expand Up @@ -2242,7 +2239,7 @@ int RGWRados::prepare_get_obj(void *ctx, rgw_obj& obj,
int r = -EINVAL;
bufferlist etag;
time_t ctime;
RGWRadosCtx *rctx = (RGWRadosCtx *)ctx;
RGWRadosCtx *rctx = static_cast<RGWRadosCtx *>(ctx);
RGWRadosCtx *new_ctx = NULL;
RGWObjState *astate = NULL;
off_t ofs = 0;
Expand Down Expand Up @@ -2442,7 +2439,7 @@ int RGWRados::clone_objs_impl(void *ctx, rgw_obj& dst_obj,
std::string dst_oid, dst_key;
get_obj_bucket_and_oid_key(dst_obj, bucket, dst_oid, dst_key);
librados::IoCtx io_ctx;
RGWRadosCtx *rctx = (RGWRadosCtx *)ctx;
RGWRadosCtx *rctx = static_cast<RGWRadosCtx *>(ctx);
uint64_t size = 0;
string etag;
string content_type;
Expand Down Expand Up @@ -2581,7 +2578,7 @@ int RGWRados::get_obj(void *ctx, void **handle, rgw_obj& obj,
rgw_obj read_obj = obj;
uint64_t read_ofs = ofs;
uint64_t len, read_len;
RGWRadosCtx *rctx = (RGWRadosCtx *)ctx;
RGWRadosCtx *rctx = static_cast<RGWRadosCtx *>(ctx);
RGWRadosCtx *new_ctx = NULL;
bool reading_from_head = true;
ObjectReadOperation op;
Expand Down Expand Up @@ -2928,7 +2925,7 @@ int RGWRados::get_obj_iterate_cb(void *ctx, RGWObjState *astate,
off_t read_ofs, off_t len,
bool is_head_obj, void *arg)
{
RGWRadosCtx *rctx = (RGWRadosCtx *)ctx;
RGWRadosCtx *rctx = static_cast<RGWRadosCtx *>(ctx);
ObjectReadOperation op;
struct get_obj_data *d = (struct get_obj_data *)arg;

Expand Down Expand Up @@ -3041,7 +3038,7 @@ int RGWRados::iterate_obj(void *ctx, rgw_obj& obj,
rgw_obj read_obj = obj;
uint64_t read_ofs = ofs;
uint64_t len;
RGWRadosCtx *rctx = (RGWRadosCtx *)ctx;
RGWRadosCtx *rctx = static_cast<RGWRadosCtx *>(ctx);
RGWRadosCtx *new_ctx = NULL;
bool reading_from_head = true;
RGWObjState *astate = NULL;
Expand Down Expand Up @@ -3119,7 +3116,7 @@ int RGWRados::read(void *ctx, rgw_obj& obj, off_t ofs, size_t size, bufferlist&
std::string oid, key;
get_obj_bucket_and_oid_key(obj, bucket, oid, key);
librados::IoCtx io_ctx;
RGWRadosCtx *rctx = (RGWRadosCtx *)ctx;
RGWRadosCtx *rctx = static_cast<RGWRadosCtx *>(ctx);
RGWObjState *astate = NULL;
int r = open_bucket_ctx(bucket, io_ctx);
if (r < 0)
Expand Down Expand Up @@ -3824,8 +3821,7 @@ class IntentLogNameFilter : public RGWAccessListFilter
string prefix;
bool filter_exact_date;
public:
IntentLogNameFilter(const char *date, struct tm *tm) {
prefix = date;
IntentLogNameFilter(const char *date, struct tm *tm) : prefix(date) {
filter_exact_date = !(tm->tm_hour || tm->tm_min || tm->tm_sec); /* if time was specified and is not 00:00:00
we should look at objects from that date */
}
Expand Down Expand Up @@ -3870,9 +3866,7 @@ int RGWRados::remove_temp_objects(string date, string time)
}
time_t epoch = mktime(&tm);

string prefix, delim, marker;
vector<RGWObjEnt> objs;
map<string, bool> common_prefixes;

int max = 1000;
bool is_truncated;
Expand Down
8 changes: 0 additions & 8 deletions src/rgw/rgw_rest_s3.cc
Original file line number Diff line number Diff line change
Expand Up @@ -682,13 +682,6 @@ void RGWPostObj_ObjStore_S3::rebuild_key(string& key)

int RGWPostObj_ObjStore_S3::get_params()
{
string temp_line;
string param;
string old_param;
string param_value;

string whitespaces (" \t\f\v\n\r");

// get the part boundary
string req_content_type_str = s->env->get("CONTENT_TYPE", "");
string req_content_type;
Expand Down Expand Up @@ -824,7 +817,6 @@ int RGWPostObj_ObjStore_S3::get_params()
int RGWPostObj_ObjStore_S3::get_policy()
{
bufferlist encoded_policy;
string uid;

if (part_bl("policy", &encoded_policy)) {

Expand Down
2 changes: 0 additions & 2 deletions src/rgw/rgw_rest_usage.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ class RGWOp_Usage_Delete : public RGWRESTOp {
};

void RGWOp_Usage_Delete::execute() {
map<std::string, bool> categories;

string uid;
uint64_t start, end;

Expand Down
4 changes: 0 additions & 4 deletions src/rgw/rgw_user.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ int rgw_store_user_info(RGWRados *store, RGWUserInfo& info, RGWUserInfo *old_inf
{
bufferlist bl;
info.encode(bl);
string md5;
int ret;
map<string,bufferlist> attrs;

map<string, RGWAccessKey>::iterator iter;
for (iter = info.swift_keys.begin(); iter != info.swift_keys.end(); ++iter) {
Expand Down Expand Up @@ -267,8 +265,6 @@ int rgw_read_user_buckets(RGWRados *store, string user_id, RGWUserBuckets& bucke
}
}

list<string> buckets_list;

if (need_stats) {
map<string, RGWBucketEnt>& m = buckets.get_buckets();
int r = store->update_containers_stats(m);
Expand Down
6 changes: 3 additions & 3 deletions src/rgw/rgw_xml.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ find_first(string name)
return NULL;
}
static void xml_start(void *data, const char *el, const char **attr) {
RGWXMLParser *handler = (RGWXMLParser *)data;
RGWXMLParser *handler = static_cast<RGWXMLParser *>(data);

if (!handler->xml_start(el, attr))
handler->set_failure();
Expand Down Expand Up @@ -168,7 +168,7 @@ bool RGWXMLParser::xml_start(const char *el, const char **attr) {
}

static void xml_end(void *data, const char *el) {
RGWXMLParser *handler = (RGWXMLParser *)data;
RGWXMLParser *handler = static_cast<RGWXMLParser *>(data);

if (!handler->xml_end(el))
handler->set_failure();
Expand All @@ -184,7 +184,7 @@ bool RGWXMLParser::xml_end(const char *el) {

static void handle_data(void *data, const char *s, int len)
{
RGWXMLParser *handler = (RGWXMLParser *)data;
RGWXMLParser *handler = static_cast<RGWXMLParser *>(data);

handler->handle_data(s, len);
}
Expand Down
1 change: 0 additions & 1 deletion src/test/ObjectMap/test_keyvaluedb_iterators.cc
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,6 @@ class RmKeysTest : public IteratorTest
store->submit_transaction_sync(tx);

deque<string> key_deque;
pair<string,string> key;
KeyValueDB::WholeSpaceIterator iter = store->get_iterator();
iter->seek_to_first();

Expand Down
2 changes: 1 addition & 1 deletion src/test/ObjectMap/test_object_map.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ typename T::iterator rand_choose(T &cont) {

string num_str(unsigned i) {
char buf[100];
snprintf(buf, sizeof(buf), "%.10d", i);
snprintf(buf, sizeof(buf), "%.10u", i);
return string(buf);
}

Expand Down
Loading

0 comments on commit 34f1984

Please sign in to comment.