[Assorted-commits] SF.net SVN: assorted:[1215] ydb/trunk/src
Brought to you by:
yangzhang
From: <yan...@us...> - 2009-02-22 00:14:36
|
Revision: 1215 http://assorted.svn.sourceforge.net/assorted/?rev=1215&view=rev Author: yangzhang Date: 2009-02-22 00:14:14 +0000 (Sun, 22 Feb 2009) Log Message: ----------- fixed all warnings Modified Paths: -------------- ydb/trunk/src/Makefile ydb/trunk/src/main.lzz.clamp ydb/trunk/src/ser.h Modified: ydb/trunk/src/Makefile =================================================================== --- ydb/trunk/src/Makefile 2009-02-21 23:55:46 UTC (rev 1214) +++ ydb/trunk/src/Makefile 2009-02-22 00:14:14 UTC (rev 1215) @@ -42,13 +42,12 @@ LDLIBS := -lstx -lst -lresolv -lprotobuf -lgtest \ -lboost_program_options-gcc43-mt -lboost_thread-gcc43-mt \ -lboost_serialization-gcc43-mt $(PPROF) -# The -Wno- warnings are for boost. CXXFLAGS := $(OPT) -pthread $(GPROF) -Wall -Werror -Wextra -Woverloaded-virtual \ - -Wconversion -Wno-conversion -Wno-ignored-qualifiers \ + -Wconversion -Wignored-qualifiers \ -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings \ - -Winit-self -Wsign-promo -Wno-unused-parameter -Wc++0x-compat \ + -Winit-self -Wsign-promo -Wunused-parameter -Wc++0x-compat \ -Wparentheses -Wmissing-format-attribute -Wfloat-equal \ - -Wno-inline -Wsynth -Wno-old-style-cast -std=gnu++0x $(PB) $(CXXFLAGS) + -Winline -Wsynth -Wno-old-style-cast -std=gnu++0x $(PB) $(CXXFLAGS) PBCXXFLAGS := $(OPT) -Wall -Werror $(GPROF) all: $(TARGET) Modified: ydb/trunk/src/main.lzz.clamp =================================================================== --- ydb/trunk/src/main.lzz.clamp 2009-02-21 23:55:46 UTC (rev 1214) +++ ydb/trunk/src/main.lzz.clamp 2009-02-22 00:14:14 UTC (rev 1215) @@ -57,7 +57,7 @@ using namespace ydb::msg; #define GETMSG(buf) \ -checkeqnneg(st_read_fully(src, buf, len, timeout), (int) len); \ +checkeqnneg(st_read_fully(src, buf, len, timeout), int(len)); \ if (stop_time != nullptr) \ *stop_time = current_time_millis(); \ check(msg.ParseFromArray(buf, len)); @@ -94,7 +94,8 @@ /** * Convenience function for calculating percentages. */ -double pct(double sub, double tot) { return 100 * sub / tot; } +template<typename T> +double pct(T sub, T tot) { return 100 * double(sub) / double(tot); } /** * Convenience class for performing long-jumping break. @@ -300,10 +301,10 @@ * Helper for getting the cached ByteSize of a message. */ template <typename T> -int +size_t pb_size(const T &msg) { // GetCachedSize returns 0 if no cached size. - int len = msg.GetCachedSize(); + size_t len = msg.GetCachedSize(); return len == 0 ? msg.ByteSize() : len; } @@ -314,7 +315,7 @@ void ser(ostream &s, const T &msg) { - uint32_t len = htonl(pb_size(msg)); + uint32_t len = htonl(uint32_t(pb_size(msg))); s.write(reinterpret_cast<const char*>(&len), sizeof len); check(msg.SerializeToOstream(&s)); } @@ -741,7 +742,7 @@ { long long time_diff = stop_time - start_time; int count_diff = stop_count - start_count; - double rate = double(count_diff) * 1000 / time_diff; + double rate = count_diff * 1000 / double(time_diff); cout << action << " " << count_diff << " txns [" << start_count << ".." << stop_count << "] in " << time_diff << " ms [" @@ -1097,7 +1098,7 @@ * from process_txns. */ void -recover_joiner(st_netfd_t listener, const mii &map, const int &seqno, +recover_joiner(st_netfd_t listener, st_channel<shared_ptr<Recovery> > &send_states) { st_netfd_t joiner; @@ -1334,8 +1335,8 @@ ref(send_states), ref(backlog), init.txnseqno(), mypos, init.node_size()); st_joining join_proc(my_spawn(process_fn, "process_txns")); - st_joining join_rec(my_spawn(bind(recover_joiner, listener, ref(map), - ref(seqno), ref(send_states)), + st_joining join_rec(my_spawn(bind(recover_joiner, listener, + ref(send_states)), "recover_joiner")); try { Modified: ydb/trunk/src/ser.h =================================================================== --- ydb/trunk/src/ser.h 2009-02-21 23:55:46 UTC (rev 1214) +++ ydb/trunk/src/ser.h 2009-02-22 00:14:14 UTC (rev 1215) @@ -64,11 +64,12 @@ } } void show() { - cout << (void*) p_; + cout << static_cast<void*>(p_); for (size_t i = 0; i < a_.size(); ++i) - cout << " " << hex << setfill('0') << setw(2) << (int)(unsigned char)(a_.get()[i]); + cout << " " << hex << setfill('0') << setw(2) + << int(static_cast<unsigned char>(a_.get()[i])); cout << endl; - cout << (void*) p_; + cout << static_cast<void*>(p_); for (size_t i = 0; i < a_.size(); ++i) cout << " " << setfill(' ') << setw(2) << (i == pos() ? "^^" : ""); cout << endl; @@ -124,14 +125,14 @@ Txn(stream &s) : s_(s), r_(s.get_reader()), w_(s.get_writer()), off_(w_.pos()), op_(s), nop_(unset), seqno_(unset) {} - void Clear() { w_.reserve(0*50); nop_ = unset; seqno_ = unset; off_ = w_.pos(); } + void Clear() { nop_ = unset; seqno_ = unset; off_ = w_.pos(); } void set_seqno(int x) { w_.write(x); } int seqno() const { return seqno_ == unset ? seqno_ = r_.read<int>() : seqno_; } void start_op() { if (nop_ == unset) nop_ = 0; w_.skip<typeof(nop_)>(); } Op *add_op() { ++nop_; return &op_; } void fin_op() { w_.write(nop_, off_ + sizeof(int)); } int op_size() const { if (nop_ == unset) nop_ = r_.read<typeof(nop_)>(); return nop_; } - const Op &op(int o) const { return op_; } + const Op &op(int) const { return op_; } }; class TxnBatch @@ -145,7 +146,7 @@ mutable short ntxn_; public: TxnBatch(stream &s) : s_(s), r_(s.get_reader()), w_(s.get_writer()), off_(w_.pos()), txn_(s), ntxn_(unset) {} - void Clear() { w_.reserve(0*100); txn_.Clear(); ntxn_ = unset; off_ = w_.pos(); } + void Clear() { txn_.Clear(); ntxn_ = unset; off_ = w_.pos(); } void start_txn() { if (ntxn_ == unset) ntxn_ = 0; w_.skip<typeof(ntxn_)>(); } Txn *add_txn() { ++ntxn_; txn_.Clear(); return &txn_; } void fin_txn() { w_.write(ntxn_, off_); } @@ -154,33 +155,33 @@ ntxn_ = r_.read<typeof(ntxn_)>(); return ntxn_; } - const Txn &txn(int t) const { txn_.Clear(); return txn_; } - bool AppendToString(string *s) const { throw_operation_not_supported(); } - bool SerializeToString(string *s) const { throw_operation_not_supported(); } - bool SerializeToOstream(ostream *s) const { throw_operation_not_supported(); } - bool ParseFromArray(void *p, size_t len) { throw_operation_not_supported(); } + const Txn &txn(int) const { txn_.Clear(); return txn_; } + bool AppendToString(string*) const { throw_operation_not_supported(); } + bool SerializeToString(string*) const { throw_operation_not_supported(); } + bool SerializeToOstream(ostream*) const { throw_operation_not_supported(); } + bool ParseFromArray(void*, size_t) { throw_operation_not_supported(); } size_t GetCachedSize() const { throw_operation_not_supported(); } size_t ByteSize() const { throw_operation_not_supported(); } }; template<typename T> void start_txn(T &batch); -template<> void start_txn(ydb::pb::TxnBatch &batch) {} +template<> void start_txn(ydb::pb::TxnBatch &) {} template<> void start_txn(ydb::msg::TxnBatch &batch) { batch.start_txn(); } template<typename T> void fin_txn(T &batch); -template<> void fin_txn(ydb::pb::TxnBatch &batch) {} +template<> void fin_txn(ydb::pb::TxnBatch &) {} template<> void fin_txn(ydb::msg::TxnBatch &batch) { batch.fin_txn(); } template<typename T> void start_op(T &txn); -template<> void start_op(ydb::pb::Txn &txn) {} +template<> void start_op(ydb::pb::Txn &) {} template<> void start_op(ydb::msg::Txn &txn) { txn.start_op(); } template<typename T> void fin_op(T &txn); -template<> void fin_op(ydb::pb::Txn &txn) {} +template<> void fin_op(ydb::pb::Txn &) {} template<> void fin_op(ydb::msg::Txn &txn) { txn.fin_op(); } template<typename T> T *new_TxnBatch(stream &s); -template<> ydb::pb::TxnBatch *new_TxnBatch(stream &s) { return new ydb::pb::TxnBatch(); } +template<> ydb::pb::TxnBatch *new_TxnBatch(stream &) { return new ydb::pb::TxnBatch(); } template<> ydb::msg::TxnBatch *new_TxnBatch(stream &s) { return new ydb::msg::TxnBatch(s); } struct pb_types { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |