[Assorted-commits] SF.net SVN: assorted:[1217] ydb/trunk/src
Brought to you by:
yangzhang
From: <yan...@us...> - 2009-02-22 06:33:46
|
Revision: 1217 http://assorted.svn.sourceforge.net/assorted/?rev=1217&view=rev Author: yangzhang Date: 2009-02-22 06:33:43 +0000 (Sun, 22 Feb 2009) Log Message: ----------- added extra warnings and fixed issues they pointed out Modified Paths: -------------- ydb/trunk/src/Makefile ydb/trunk/src/main.lzz.clamp ydb/trunk/src/p2.cc ydb/trunk/src/ser.cc ydb/trunk/src/ser.h Modified: ydb/trunk/src/Makefile =================================================================== --- ydb/trunk/src/Makefile 2009-02-22 06:33:36 UTC (rev 1216) +++ ydb/trunk/src/Makefile 2009-02-22 06:33:43 UTC (rev 1217) @@ -29,7 +29,7 @@ PPROF := -lprofiler endif ifneq ($(OPT),) - OPT := -O3 + OPT := -O3 -Wdisabled-optimization else OPT := -g3 endif @@ -42,12 +42,52 @@ LDLIBS := -lstx -lst -lresolv -lprotobuf -lgtest \ -lboost_program_options-gcc43-mt -lboost_thread-gcc43-mt \ -lboost_serialization-gcc43-mt $(PPROF) -CXXFLAGS := $(OPT) -pthread $(GPROF) -Wall -Werror -Wextra -Woverloaded-virtual \ - -Wconversion -Wignored-qualifiers \ - -Wpointer-arith -Wcast-qual -Wcast-align -Wwrite-strings \ - -Winit-self -Wsign-promo -Wunused-parameter -Wc++0x-compat \ - -Wparentheses -Wmissing-format-attribute -Wfloat-equal \ - -Winline -Wsynth -Wno-old-style-cast -std=gnu++0x $(PB) $(CXXFLAGS) + +CXXFLAGS := $(OPT) -pthread $(GPROF) \ + -Wall \ + -Werror \ + -Wextra \ + -Wstrict-null-sentinel \ + -Wno-old-style-cast \ + -Woverloaded-virtual \ + -Wsign-promo \ + -Wformat=2 \ + -Winit-self \ + -Wswitch-enum \ + -Wunused \ + -Wstrict-overflow \ + -Wfloat-equal \ + -Wundef \ + -Wunsafe-loop-optimizations \ + -Wpointer-arith \ + -Wcast-qual \ + -Wcast-align \ + -Wwrite-strings \ + -Wconversion \ + -Wlogical-op \ + -Wno-aggregate-return \ + -Wno-missing-declarations \ + -Wno-missing-field-initializers \ + -Wmissing-format-attribute \ + -Wpacked \ + -Wredundant-decls \ + -Winline \ + -Winvalid-pch \ + -Wlong-long \ + -Wvolatile-register-var \ + -std=gnu++0x \ + $(PB) \ + $(CXXFLAGS) + + # -Wmissing-noreturn \ + # -Weffc++ \ + # -pedantic \ + # -Wshadow \ + # -Wswitch-default \ + # -Wpadded \ + # -Wunreachable-code \ + # -Wstack-protector \ + PBCXXFLAGS := $(OPT) -Wall -Werror $(GPROF) all: $(TARGET) @@ -83,7 +123,7 @@ $(COMPILE.cc) $(PBHDRS) $(OUTPUT_OPTION) $< clean: - rm -f $(GENSRCS) $(GENHDRS) $(OBJS) $(TARGET) main.lzz *.clamp_h serperf + rm -f $(GENSRCS) $(GENHDRS) $(OBJS) $(TARGET) main.lzz *.clamp_h distclean: clean rm -f all.h all.h.gch Modified: ydb/trunk/src/main.lzz.clamp =================================================================== --- ydb/trunk/src/main.lzz.clamp 2009-02-22 06:33:36 UTC (rev 1216) +++ ydb/trunk/src/main.lzz.clamp 2009-02-22 06:33:43 UTC (rev 1217) @@ -457,8 +457,8 @@ len = ntohl(len); // Parse the message body. - if (len < 4096) { - char buf[len]; + if (len <= 4096) { + char buf[4096]; GETMSG(buf); } else { //cout << "receiving large msg; heap-allocating " << len << " bytes" << endl; @@ -1429,7 +1429,7 @@ * have marked themselves as interruptible. */ void handle_sig_sync() { - stfd fd = checkerr(st_netfd_open(sig_pipe[0])); + st_closing fd(checkerr(st_netfd_open(sig_pipe[0]))); while (true) { int sig; checkeqnneg(st_read(fd, &sig, sizeof sig, ST_UTIME_NO_TIMEOUT), Modified: ydb/trunk/src/p2.cc =================================================================== --- ydb/trunk/src/p2.cc 2009-02-22 06:33:36 UTC (rev 1216) +++ ydb/trunk/src/p2.cc 2009-02-22 06:33:43 UTC (rev 1217) @@ -64,7 +64,7 @@ end_ -= diff; } // read; advance end_ - STAT(readtime, readcnt, int res = ::read(fd(), end_, rem());) + STAT(readtime, readcnt, ssize_t res = ::read(fd(), end_, rem());) int e = errno; errno = 0; //cout << "read res " << res << endl; @@ -125,7 +125,7 @@ size_t rem() { return buf_.end() - end_; } arr getbuf(uint32_t req) { - uint32_t tot = req + sizeof req; + uint32_t tot = uint32_t(req + sizeof req); check(tot > 0); check(tot <= buf_.size()); //cout << "getbuf req " << req << endl; @@ -151,7 +151,7 @@ void write() { // perform the write - STAT(writetime, writecnt, int res = ::write(fd(), start_, end_ - start_);) + STAT(writetime, writecnt, ssize_t res = ::write(fd(), start_, end_ - start_);) if (res < 0) { close(fd()); throw exception(); } //cout << "write res " << res << " amt " << amt() << endl; // advance start_ @@ -182,7 +182,7 @@ void handle_write() { //cout << "writing" << endl; uint32_t npairs = batch_size; - uint32_t len = 2 * sizeof(uint32_t) * npairs; + uint32_t len = uint32_t(2 * sizeof(uint32_t) * npairs); arr a = w_.getbuf(len); buf_ = a; if (buf_ == nullptr) return; @@ -234,7 +234,7 @@ //if (verbose) cout << current_time_millis() << ": count " << counter_ << endl; if (counter_ > thresh) { long long end = current_time_millis(); - double rate = double(counter_) / (end - start_) * 1000; + double rate = counter_ / double(end - start_) * 1000; cout << "rate " << rate << " pairs/s " << rate / 5 << " tps; readcount " << readcount_ << endl; throw exception(); } Modified: ydb/trunk/src/ser.cc =================================================================== --- ydb/trunk/src/ser.cc 2009-02-22 06:33:36 UTC (rev 1216) +++ ydb/trunk/src/ser.cc 2009-02-22 06:33:43 UTC (rev 1217) @@ -28,7 +28,7 @@ uint32_t len = 0; str.append(sizeof len, '\0'); check(batch.AppendToString(&str)); - len = str.size() - sizeof len; + len = uint32_t(str.size() - sizeof len); copy((char*) &len, (char*) &len + sizeof len, str.begin()); os(str.data(), str.size()); } Modified: ydb/trunk/src/ser.h =================================================================== --- ydb/trunk/src/ser.h 2009-02-22 06:33:36 UTC (rev 1216) +++ ydb/trunk/src/ser.h 2009-02-22 06:33:43 UTC (rev 1217) @@ -4,6 +4,7 @@ #include <commons/array.h> #include <commons/exceptions.h> #include <commons/st/st.h> +#include <commons/utility.h> #include <iomanip> #include <iostream> #include "ydb.pb.h" @@ -26,6 +27,7 @@ class writer { + NONCOPYABLE(writer) private: commons::array<char> a_; char *p_; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |