Resolve gcc warnings.
PATCH 1/2 Resolve gcc warnings.
I don't know what the ceph project's opinion towards warning cleanliness is, but given the paucity of warnings on my ubuntu 11.10 amd64 machine, I'm guessing it is a safe bet to keep things clean.
This series has two patches, one with the fixes that should have no functional change. The second, in rgw, I found a few warnings that pointed to code that looked obviously wrong. While I've smoke tested rbd and fuse with these changes, I haven't tested rgw. Thus the rgw fixes compile and pass any unit tests that might exist under 'make check', but are otherwise untested.
Regards,
Josh
From 9a60445de09a7c9de096cecb1b63638be52438c2 Mon Sep 17 00:00:00 2001
From: Josh Pieper <[email protected]>
Date: Fri, 11 Nov 2011 08:19:02 -0500
Subject: [PATCH 1/2] Resolve gcc warnings.
These should have no functional changes:
* Check errors from functions that currently cannot return any
* Initialize variables that gcc can't determine will be initialized in a following function call
* Remove unused variables
--- src/client/fuse_ll.cc | 6 +++++- src/include/encoding.h | 2 +- src/librados.cc | 2 ++ src/mount/mount.ceph.c | 2 -- src/msg/SimpleMessenger.cc | 2 -- src/msg/msg_types.cc | 2 -- src/os/IndexManager.cc | 2 +- src/osd/PG.cc | 3 --- src/osd/ReplicatedPG.cc | 2 -- 9 files changed, 9 insertions(+), 14 deletions(-)
src/client/fuse_ll.cc +5 -1
@@ -423,7 +423,11 @@ static void ceph_ll_readdir(fuse_req_t req, fuse_ino_t ino, size_t size, int r; r = client->readdir_r_cb(dirp, ceph_ll_add_dirent, &rc); - fuse_reply_buf(req, rc.buf, rc.pos); + if (r == 0) { + fuse_reply_buf(req, rc.buf, rc.pos); + } else { + fuse_reply_err(req, -r); + } delete[] rc.buf; }
src/include/encoding.h +1 -1
@@ -525,7 +525,7 @@ inline void decode(std::multimap<T,U>& m, bufferlist::iterator& p)decode (n, p); m.clear ();while (n--) { - typename std::pair<T,U> tu; + typename std::pair<T,U> tu = std::pair<T,U>();decode (tu.first, p); typename std::multimap<T,U>::iterator it = m.insert(tu);decode (it->second, p);
src/librados.cc +2 -0
@@ -4006,6 +4006,8 @@ extern "C" int rados_objects_list_next(rados_list_ctx_t listctx, const char **en if (h->list.empty()) { ret = lh->ctx->client->list(lh->lc, RADOS_LIST_MAX_ENTRIES); + if (ret < 0) + return ret; if (h->list.empty()) return -ENOENT; }
src/mount/mount.ceph.c +0 -2
@@ -86,7 +86,6 @@ static char *parse_options(const char *data, int *filesys_flags)int word_len;int skip;int pos =0 ; -char *newdata =0 ;char secret[MAX_SECRET_LEN ];char *saw_name =NULL ;char *saw_secret =NULL ;
@@ -99,7 +98,6 @@ static char *parse_options(const char *data, int *filesys_flags)if (*data ==0 )break ; next_keyword =strchr (data,',' ); - newdata =0 ;/* temporarily null terminate end of keyword=value pair */ if (next_keyword)
src/msg/SimpleMessenger.cc +0 -2
@@ -700,7 +700,6 @@ int SimpleMessenger::Pipe::accept() // this should roughly mirror pseudocode at // http://ceph.newdream.net/wiki/Messaging_protocol int reply_tag = 0; - bool replace = false; uint64_t existing_seq = -1; while (1) { rc = tcp_read(msgr->cct, sd, (char*)&connect, sizeof(connect), msgr->timeout);
@@ -893,7 +892,6 @@ int SimpleMessenger::Pipe::accept() } replace: - replace = true; if (connect.features & CEPH_FEATURE_RECONNECT_SEQ) { reply_tag = CEPH_MSGR_TAG_SEQ; existing_seq = existing->in_seq;
src/msg/msg_types.cc +0 -2
@@ -11,11 +11,9 @@ bool entity_addr_t::parse(const char *s, const char **end) const char *start = s; bool brackets = false; - bool ipv6 = false; if (*start == '[') { start++; brackets = true; - ipv6 = true; } // inet_pton() requires a null terminated input, so let's fill two
src/os/IndexManager.cc +1 -1
@@ -83,7 +83,7 @@ int IndexManager::build_index(coll_t c, const char *path, Index *index) { int r; if (g_conf->filestore_update_collections) { // Need to check the collection generation - uint32_t version; + uint32_t version = 0; r = get_version(path, &version); if (r < 0) return r;
src/osd/PG.cc +0 -3
@@ -4870,7 +4870,6 @@ PG::PriorSet::PriorSet(const OSDMap &osdmap, // interesting), or lost (down, but we won't wait for it). bool any_up_now = false; // any candidates up now bool any_down_now = false; // any candidates down now (that might have useful data) - bool any_lost_now = false; // any candidates lost now (that we will ignore) // consider ACTING osds for (unsigned i=0; i<interval.acting.size(); i++) {
@@ -4887,11 +4886,9 @@ PG::PriorSet::PriorSet(const OSDMap &osdmap, } else if (!pinfo) { dout(10) << "build_prior prior osd." << o << " no longer exists" << dendl; down.insert(o); - any_lost_now = true; } else if (pinfo->lost_at > interval.first) { dout(10) << "build_prior prior osd." << o << " is down, but lost_at " << pinfo->lost_at << dendl; down.insert(o); - any_lost_now = true; } else { dout(10) << "build_prior prior osd." << o << " is down" << dendl; down.insert(o);
src/osd/ReplicatedPG.cc +0 -2
@@ -2440,7 +2440,6 @@ void ReplicatedPG::do_osd_op_effects(OpContext *ctx) osd->client_messenger->send_message(notify_msg, s->con); } else { // unconnected - utime_t now = ceph_clock_now(g_ceph_context); entity_name_t name = i->first; notif->add_watcher(name, Watch::WATCHER_PENDING); }
@@ -4576,7 +4575,6 @@ void ReplicatedPG::mark_all_unfound_lost(int what) C_PG_MarkUnfoundLost *c = new C_PG_MarkUnfoundLost(this); utime_t mtime = ceph_clock_now(g_ceph_context); - eversion_t old_last_update = info.last_update; info.last_update.epoch = get_osdmap()->get_epoch(); map<hobject_t, Missing::item>::iterator m = missing.missing.begin(); map<hobject_t, Missing::item>::iterator mend = missing.missing.end();
Signature · 1 line
1.7.5.4