r17869 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r17868‎ | r17869 | r17870 >
Date:01:05, 23 November 2006
Author:river
Status:old
Tags:
Comment:
cleanups
Modified paths:
  • /trunk/willow/configure.in (modified) (history)
  • /trunk/willow/src/include/cache.h (modified) (history)
  • /trunk/willow/src/include/confparse.h (modified) (history)
  • /trunk/willow/src/include/expr.h (modified) (history)
  • /trunk/willow/src/include/mbuffer.h (modified) (history)
  • /trunk/willow/src/include/md5.h (modified) (history)
  • /trunk/willow/src/include/polycaller.h (modified) (history)
  • /trunk/willow/src/include/radix.h (modified) (history)
  • /trunk/willow/src/include/willow.h (modified) (history)
  • /trunk/willow/src/include/wlog.h (modified) (history)
  • /trunk/willow/src/include/wnet.h (modified) (history)
  • /trunk/willow/src/include/wthread.h (modified) (history)
  • /trunk/willow/src/libwillow/htcp.cc (modified) (history)
  • /trunk/willow/src/wgetstats/wgetstats.cc (modified) (history)
  • /trunk/willow/src/whtcp/whtcp.cc (modified) (history)
  • /trunk/willow/src/willow/cache.cc (modified) (history)
  • /trunk/willow/src/willow/confparse.cc (modified) (history)
  • /trunk/willow/src/willow/radix.cc (modified) (history)
  • /trunk/willow/src/willow/wbackend.cc (modified) (history)
  • /trunk/willow/src/wreadlog/packet_decoder.cc (modified) (history)

Diff [purge]

Index: trunk/willow/configure.in
@@ -44,6 +44,20 @@
4545 testflag -Wno-unused
4646 testflag -g
4747 testflag -mt
 48+dnl testflag -Weffc++
 49+testflag -Woverloaded-virtual
 50+testflag -Wformat=2
 51+testflag -Winit-self
 52+testflag -Wswitch-enum
 53+testflag -Wundef
 54+#testflag -Wshadow
 55+testflag -Wpointer-arith
 56+testflag -Wcast-qual
 57+testflag -Wcast-align
 58+testflag -Wwrite-strings
 59+testflag -Wredundant-decls
 60+testflag
 61+-Wunreachable-code
4862 if test ! "$ac_cv_cxx_compiler_gnu" = "yes"; then
4963 testflag -errtags
5064 fi
Index: trunk/willow/src/include/wthread.h
@@ -175,17 +175,8 @@
176176 HOLDING(v1.m);
177177 return v1.v | v2;
178178 }
 179+
179180 template<typename T1, typename T2>
180 -T1 operator && (atomic<T1> const &v1, T2 v2) {
181 - HOLDING(v1.m);
182 - return v1.v && v2;
183 -}
184 -template<typename T1, typename T2>
185 -T1 operator || (atomic<T1> const &v1, T2 v2) {
186 - HOLDING(v1.m);
187 - return v1.v || v2;
188 -}
189 -template<typename T1, typename T2>
190181 T1 operator == (atomic<T1> const &v1, T2 v2) {
191182 HOLDING(v1.m);
192183 return v1.v == v2;
Index: trunk/willow/src/include/cache.h
@@ -111,8 +111,8 @@
112112 }
113113
114114 void set_complete(void);
115 - void store_status(imstring const &status, int code) {
116 - _status = status;
 115+ void store_status(imstring const &nstatus, int code) {
 116+ _status = nstatus;
117117 _statuscode = code;
118118 }
119119
Index: trunk/willow/src/include/polycaller.h
@@ -14,6 +14,7 @@
1515
1616 #include <stdexcept>
1717 #include <typeinfo>
 18+using std::type_info;
1819
1920 #include "willow.h"
2021
@@ -25,16 +26,6 @@
2627 polycaller_object_missing() : std::logic_error("polycaller called with no object") {}
2728 };
2829
29 -template<typename thistype, typename impltype>
30 -struct polycaller_base {
31 - std::type_info const *tid;
32 - impltype *impl;
33 - polycaller_base() : tid(NULL), impl(NULL) {}
34 - virtual ~polycaller_base() {
35 - delete impl;
36 - }
37 -};
38 -
3930 template<typename arg1, typename arg2, typename arg3>
4031 struct polycaller_impl_base3 {
4132 virtual ~polycaller_impl_base3(void) {}
@@ -59,36 +50,46 @@
6051 };
6152
6253 template<typename arg1 = void, typename arg2 = void, typename arg3 = void>
63 -struct polycaller : polycaller_base<polycaller<arg1,arg2,arg3>, polycaller_impl_base3<arg1,arg2,arg3> > {
64 - polycaller(void) {}
 54+struct polycaller {
 55+ type_info const *tid;
 56+ polycaller_impl_base3<arg1, arg2, arg3> *impl;
6557
 58+ polycaller(void) : tid(NULL), impl(NULL) {}
 59+ ~polycaller() {
 60+ delete impl;
 61+ }
 62+
6663 template<typename T>
6764 polycaller(T &o, void (T::*f) (arg1, arg2, arg3)) {
6865 assign(o, f);
6966 }
7067
71 - polycaller& operator= (polycaller<arg1,arg2,arg3> &other) {
72 - this->impl = other.impl->clone();
 68+ polycaller& operator= (polycaller<arg1,arg2,arg3> const &other) {
 69+ delete impl;
 70+ impl = NULL;
 71+ tid = other.tid;
 72+ if (other.impl)
 73+ impl = other.impl->clone();
7374 return *this;
7475 }
7576
7677 polycaller(polycaller<arg1,arg2,arg3> const &other)
77 - : polycaller_base<polycaller<arg1,arg2,arg3>,polycaller_impl_base3<arg1,arg2,arg3> >() {
78 - this->tid = other.tid;
 78+ : tid(other.tid)
 79+ , impl(NULL) {
7980 if (other.impl)
80 - this->impl = other.impl->clone();
 81+ impl = other.impl->clone();
8182 }
8283
8384 template<typename T>
8485 polycaller& assign (T &o, void (T::*f) (arg1, arg2, arg3)) {
85 - delete this->impl;
86 - this->impl = new polycaller_impl3<T,arg1,arg2,arg3>(&o, f);
87 - this->tid = &typeid(T);
 86+ delete impl;
 87+ impl = new polycaller_impl3<T,arg1,arg2,arg3>(&o, f);
 88+ tid = &typeid(T);
8889 return *this;
8990 }
9091
9192 void operator() (arg1 a, arg2 b, arg3 c) const {
92 - this->impl->call(a, b, c);
 93+ impl->call(a, b, c);
9394 }
9495 };
9596
@@ -116,25 +117,36 @@
117118 };
118119
119120 template<typename arg1, typename arg2>
120 -struct polycaller<arg1,arg2,void> : polycaller_base<polycaller<arg1,arg2>, polycaller_impl_base2<arg1,arg2> > {
121 - polycaller(void) {}
 121+struct polycaller<arg1,arg2,void> {
 122+ type_info const *tid;
 123+ polycaller_impl_base2<arg1, arg2> *impl;
122124
 125+ polycaller(void) : tid(NULL), impl(NULL) {}
 126+ ~polycaller() {
 127+ delete impl;
 128+ }
 129+
123130 template<typename T>
124 - polycaller(T &o, void (T::*f) (arg1, arg2)) {
 131+ polycaller(T &o, void (T::*f) (arg1, arg2))
 132+ : tid(NULL)
 133+ , impl(NULL) {
125134 assign(o, f);
126135 }
127136
128 - polycaller& operator= (polycaller<arg1,arg2> &other) {
129 - delete this->impl;
130 - this->impl = other.impl->clone();
 137+ polycaller& operator= (polycaller<arg1,arg2> const &other) {
 138+ delete impl;
 139+ tid = other.tid;
 140+ impl = NULL;
 141+ if (other.impl)
 142+ impl = other.impl->clone();
131143 return *this;
132144 }
133145
134146 polycaller(polycaller<arg1,arg2> const &other)
135 - : polycaller_base<polycaller<arg1,arg2>,polycaller_impl_base2<arg1,arg2> >() {
136 - this->tid = other.tid;
 147+ : tid(other.tid)
 148+ , impl(NULL) {
137149 if (other.impl)
138 - this->impl = other.impl->clone();
 150+ impl = other.impl->clone();
139151 }
140152
141153 template<typename T>
@@ -174,36 +186,44 @@
175187 };
176188
177189 template<typename arg1>
178 -struct polycaller<arg1,void,void> : polycaller_base<polycaller<arg1,void>, polycaller_impl_base1<arg1> > {
179 - polycaller(void) {}
 190+struct polycaller<arg1,void,void> {
 191+ type_info const *tid;
 192+ polycaller_impl_base1<arg1> *impl;
180193
 194+ polycaller(void) : tid(NULL), impl(NULL) {}
 195+ ~polycaller() {
 196+ delete impl;
 197+ }
 198+
181199 template<typename T>
182200 polycaller(T &o, void (T::*f) (arg1)) {
183201 assign(o, f);
184202 }
185203 polycaller(polycaller<arg1> const &other)
186 - : polycaller_base<polycaller<arg1,void>, polycaller_impl_base1<arg1> >() {
187 - this->tid = other.tid;
 204+ : tid(other.tid)
 205+ , impl(NULL) {
188206 if (other.impl)
189207 this->impl = other.impl->clone();
190208 }
191209
192 - polycaller& operator= (polycaller<arg1> &other) {
193 - delete this->impl;
194 - this->impl = other.impl->clone();
 210+ polycaller& operator= (polycaller<arg1> const &other) {
 211+ delete impl;
 212+ impl = NULL;
 213+ if (other.impl)
 214+ impl = other.impl->clone();
195215 return *this;
196216 }
197217
198218 template<typename T>
199219 polycaller& assign (T &o, void (T::*f) (arg1)) {
200 - delete this->impl;
201 - this->impl = new polycaller_impl1<T,arg1>(&o, f);
202 - this->tid = &typeid(T);
203 - return *this;
 220+ delete impl;
 221+ impl = new polycaller_impl1<T,arg1>(&o, f);
 222+ tid = &typeid(T);
 223+ return *this;
204224 }
205225
206226 void operator() (arg1 a) const {
207 - this->impl->call(a);
 227+ impl->call(a);
208228 }
209229 };
210230
@@ -230,27 +250,36 @@
231251 };
232252
233253 template<>
234 -struct polycaller<void,void,void> : polycaller_base<polycaller<void,void,void>,polycaller_impl_base0> {
235 - polycaller(void) {
236 - tid = NULL;
237 - impl = NULL;
 254+struct polycaller<void,void,void> {
 255+ type_info const *tid;
 256+ polycaller_impl_base0 *impl;
 257+
 258+ polycaller(void)
 259+ : tid(NULL)
 260+ , impl(NULL) {
238261 }
239262
 263+ ~polycaller() {
 264+ delete impl;
 265+ }
 266+
240267 template<typename T>
241 - polycaller(T &o, void (T::*f) (void)) {
242 - impl = NULL;
 268+ polycaller(T &o, void (T::*f) (void))
 269+ : tid(NULL)
 270+ , impl(NULL) {
243271 assign(o, f);
244272 }
245 - polycaller& operator= (polycaller<void,void,void> &other) {
246 - impl = other.impl->clone();
 273+ polycaller& operator= (polycaller<void,void,void> const &other) {
 274+ tid = other.tid;
 275+ if (other.impl)
 276+ other.impl->clone();
247277 return *this;
248278 }
249279 polycaller(polycaller<void> const &other)
250 - : polycaller_base<polycaller<void,void>,polycaller_impl_base0> () {
251 - tid = other.tid;
 280+ : tid(other.tid)
 281+ , impl(NULL) {
252282 if (other.impl)
253283 impl = other.impl->clone();
254 - else impl = NULL;
255284 }
256285
257286 template<typename T>
@@ -442,10 +471,10 @@
443472
444473 polycallback() : binder(NULL), _null(true) {}
445474 polycallback(polycallback<> const &other)
446 - : _null(other._null) {
 475+ : binder(NULL)
 476+ , _null(other._null) {
447477 if (other.binder)
448478 binder = other.binder->clone();
449 - else binder = NULL;
450479 }
451480
452481 polycallback& operator=(polycallback<> const &other) {
Index: trunk/willow/src/include/radix.h
@@ -74,19 +74,31 @@
7575 };
7676
7777 struct radix_node {
78 - radix_node() { memset(this, 0, sizeof(*this)); }
79 - uint32_t bit;
80 - struct prefix *prefix;
81 - struct radix_node *l, *r;
82 - struct radix_node *parent;
83 - void *data;
84 - int flags;
 78+ radix_node()
 79+ : bit(0)
 80+ , pfx(0)
 81+ , l(0)
 82+ , r(0)
 83+ , parent(0)
 84+ , data(0)
 85+ , flags(0)
 86+ {}
 87+ radix_node(radix_node const &);
 88+
 89+ uint32_t bit;
 90+ prefix *pfx;
 91+ radix_node *l, *r;
 92+ radix_node *parent;
 93+ void *data;
 94+ int flags;
8595 };
8696
8797 class radix {
8898 public:
8999 radix();
90 - ~radix();
 100+ virtual ~radix();
 101+ radix(radix const &);
 102+ radix &operator= (radix const &);
91103
92104 void set_dtor (void_fn_t);
93105 radix_node *add (char const *);
Index: trunk/willow/src/include/wlog.h
@@ -28,7 +28,7 @@
2929 ll_error
3030 };
3131
32 -struct logger {
 32+struct logger : noncopyable {
3333 logger();
3434
3535 void syslog (bool, int facility = 0);
Index: trunk/willow/src/include/willow.h
@@ -103,8 +103,11 @@
104104 * Absolute values.
105105 */
106106 struct abs_t {
107 - abs_t() {
108 - memset(this, 0, sizeof(*this));
 107+ abs_t()
 108+ : n_httpreq_ok(0)
 109+ , n_httpreq_fail(0)
 110+ , n_httpresp_ok(0)
 111+ , n_httpresp_fail(0) {
109112 }
110113 uint64_t n_httpreq_ok; /* requests which were sent to a backend */
111114 uint64_t n_httpreq_fail; /* requests which did not reach a backend */
@@ -246,9 +249,9 @@
247250
248251 template<typename charT, typename allocator>
249252 void
250 -basic_imstring<charT, allocator>::assign(charT const *str, charT const *end)
 253+basic_imstring<charT, allocator>::assign(charT const *str, charT const *send)
251254 {
252 - assign(str, end - str);
 255+ assign(str, send - str);
253256 }
254257
255258 template<typename charT, typename allocator>
@@ -480,7 +483,7 @@
481484 * A buffer which uses /dev/shm buffers if possible (on Linux), so we can use
482485 * sendfile() on the buffer.
483486 */
484 -struct diobuf : freelist_allocator<diobuf> {
 487+struct diobuf : noncopyable, freelist_allocator<diobuf> {
485488 diobuf(size_t size = 4096);
486489 ~diobuf(void);
487490
Index: trunk/willow/src/include/wnet.h
@@ -124,11 +124,21 @@
125125 , free(free_) {
126126 }
127127 buffer_item(buffer_item const &o)
128 - : len(o.len)
 128+ : buf(NULL)
 129+ , len(o.len)
129130 , off(o.off)
130131 , free(true) {
131132 buf = (const char *)memcpy(new char[len], o.buf, len);
132133 }
 134+ buffer_item&
 135+ operator=(buffer_item const &other) {
 136+ buf = NULL;
 137+ len = other.len;
 138+ off = other.off;
 139+ free = true;
 140+ buf = (const char *)memcpy(new char[len], other.buf, len);
 141+ return *this;
 142+ }
133143
134144 ~buffer_item() {
135145 if (free)
Index: trunk/willow/src/include/expr.h
@@ -39,7 +39,7 @@
4040 using boost::shared_ptr;
4141
4242 struct expression_error : runtime_error {
43 - expression_error(char const *what) : runtime_error(what) {}
 43+ expression_error(char const *err) : runtime_error(err) {}
4444 };
4545
4646 struct stack_underflow : expression_error {
Index: trunk/willow/src/include/confparse.h
@@ -384,21 +384,23 @@
385385
386386 extern const int require_name;
387387
388 -struct block_definer {
 388+struct block_definer : noncopyable {
389389 block_definer(conf_definer &parent_, string const &name, int flags);
390390 ~block_definer();
391391
392392 template<typename Vt, typename St>
393 - block_definer &value(string const &name, Vt const &v, St const &s) {
394 - values.insert(make_pair(name, new value_definer(name, v, s)));
 393+ block_definer &value(string const &name_, Vt const &v, St const &s) {
 394+ values.insert(make_pair(name_, new value_definer(name_, v, s)));
395395 return *this;
396396 }
 397+
397398 template<typename Vt, typename St>
398399 block_definer &end(Vt vefn_, St sefn_) {
399400 vefn = new Vt(vefn_);
400401 sefn = new St(sefn_);
401402 return *this;
402403 }
 404+
403405 template<typename St>
404406 block_definer &end(St sefn_) {
405407 sefn = new St(sefn_);
@@ -409,6 +411,9 @@
410412 bool validate(tree_entry &e);
411413 void set(tree_entry &e);
412414
 415+private:
 416+ friend class conf_definer;
 417+
413418 conf_definer &parent;
414419 string name;
415420 map<string, value_definer *> values;
Index: trunk/willow/src/include/md5.h
@@ -129,13 +129,13 @@
130130 memset(_opad, 0x5C, sizeof(_opad));
131131 }
132132
133 - void key(unsigned char const *key, size_t keylen) {
 133+ void key(unsigned char const *nkey, size_t keylen) {
134134 if (keylen > block_size) {
135 - hash h(key, keylen);
 135+ hash h(nkey, keylen);
136136 memcpy(_key, h.digest(), digest_size);
137137 _keylen = digest_size;
138138 } else {
139 - memcpy(_key, key, keylen);
 139+ memcpy(_key, nkey, keylen);
140140 _keylen = keylen;
141141 }
142142
Index: trunk/willow/src/include/mbuffer.h
@@ -18,11 +18,17 @@
1919 #include <cassert>
2020 #include <string>
2121 #include <cstddef>
 22+#include <stdexcept>
2223 using std::size_t;
2324 using std::basic_string;
 25+using std::logic_error;
2426
2527 #include "willow.h"
2628
 29+struct marshalling_buffer_overflow : logic_error {
 30+ marshalling_buffer_overflow() : logic_error("marshalling buffer overflow") {}
 31+};
 32+
2733 struct marshalling_buffer {
2834 marshalling_buffer()
2935 : _buf(NULL)
@@ -37,13 +43,33 @@
3844 , _bufsz(sz)
3945 , _delete(false)
4046 {}
41 -
 47+
 48+ marshalling_buffer&
 49+ operator= (marshalling_buffer const &other) {
 50+ _delete = other._delete;
 51+ _bufsz = other._bufsz;
 52+ _size = other._size;
 53+ _buf = NULL;
 54+ if (_delete) {
 55+ _buf = new char[_bufsz];
 56+ memcpy(_buf, other._buf, _bufsz);
 57+ } else {
 58+ _buf = other._buf;
 59+ }
 60+ return *this;
 61+ }
 62+
4263 ~marshalling_buffer(void) {
 64+ if (_delete)
 65+ delete[] _buf;
4366 }
4467
45 - void reserve(size_t size) {
46 - _bufsz = size;
47 - _buf = new char[size];
 68+ void reserve(size_t nsize) {
 69+ _bufsz = nsize;
 70+ if (_delete)
 71+ delete[] _buf;
 72+ _delete = true;
 73+ _buf = new char[nsize];
4874 }
4975
5076 template<typename T>
@@ -55,7 +81,9 @@
5682 template<typename T>
5783 typename enable_if<is_char_type<T>, void>::type
5884 append_bytes(T const *buf, size_t s) {
59 - assert(_size + s <= _bufsz);
 85+ if (_size + s > _bufsz)
 86+ throw marshalling_buffer_overflow();
 87+
6088 memcpy(_buf + _size, buf, s);
6189 _size += s;
6290 }
Index: trunk/willow/src/libwillow/htcp.cc
@@ -228,11 +228,11 @@
229229 }
230230
231231 void
232 -htcp_encoder::key(string const &keyname, ustring const &key)
 232+htcp_encoder::key(string const &keyname, ustring const &nkey)
233233 {
234234 _sign = true;
235235 _auth.ha_keyname = keyname;
236 - _key = key;
 236+ _key = nkey;
237237 }
238238
239239 htcp_opdata *
@@ -294,13 +294,16 @@
295295 }
296296
297297 bool
298 -htcp_decoder::verify_signature(string const &keyname, ustring const &key,
 298+htcp_decoder::verify_signature(string const &nkeyname, ustring const &key,
299299 sockaddr *src, sockaddr *dst)
300300 {
301301 marshalling_buffer buf;
302 -ustring signature;
 302+ustring sig;
303303 int oplen = _opheader.length() + _opdata->length();
304304
 305+ if (nkeyname != _auth.ha_keyname)
 306+ return false;
 307+
305308 buf.reserve(22 + oplen + socklen(src) + socklen(dst));
306309 htcp_encoder::encode_sockaddr(buf, src);
307310 htcp_encoder::encode_sockaddr(buf, dst);
@@ -313,12 +316,12 @@
314317 mac.run(buf.buffer(), buf.size());
315318
316319 hmac<md5>::digest_t digest = mac.digest();
317 - signature.assign(digest, digest + sizeof(digest));
 320+ sig.assign(digest, digest + sizeof(digest));
318321
319 - if (signature != _auth.ha_signature)
 322+ if (sig != _auth.ha_signature)
320323 return false;
321324
322 - if (_auth.ha_sigexpire <= time(0))
 325+ if ((time_t)_auth.ha_sigexpire <= time(0))
323326 return false;
324327
325328 return true;
Index: trunk/willow/src/wreadlog/packet_decoder.cc
@@ -22,11 +22,11 @@
2323 struct logent_buf {
2424 uint32_t *r_reqtime;
2525 uint16_t *r_clilen, *r_pathlen, *r_belen;
26 - char *r_cliaddr;
 26+ char const *r_cliaddr;
2727 uint8_t *r_reqtype;
28 - char *r_path;
 28+ char const *r_path;
2929 uint16_t *r_status;
30 - char *r_beaddr;
 30+ char const *r_beaddr;
3131 uint8_t *r_cached;
3232 uint32_t *r_docsize;
3333 };
@@ -62,16 +62,16 @@
6363 bufp += (s); \
6464 }
6565 logent_buf b;
66 - b.r_reqtime = (uint32_t *) bufp; GET_BYTES(4);
67 - b.r_clilen = (uint16_t *) bufp; GET_BYTES(2);
68 - b.r_cliaddr = (char *) bufp; GET_BYTES(*b.r_clilen);
69 - b.r_reqtype = (uint8_t *) bufp; GET_BYTES(1);
70 - b.r_pathlen = (uint16_t *) bufp; GET_BYTES(2);
71 - b.r_path = (char *) bufp; GET_BYTES(*b.r_pathlen);
72 - b.r_status = (uint16_t *) bufp; GET_BYTES(2);
73 - b.r_belen = (uint16_t *) bufp; GET_BYTES(2);
74 - b.r_beaddr = (char *) bufp; GET_BYTES(*b.r_belen);
75 - b.r_cached = (uint8_t *) bufp; GET_BYTES(1);
 66+ b.r_reqtime = (uint32_t *) bufp; GET_BYTES(4);
 67+ b.r_clilen = (uint16_t *) bufp; GET_BYTES(2);
 68+ b.r_cliaddr = (char const *) bufp; GET_BYTES(*b.r_clilen);
 69+ b.r_reqtype = (uint8_t *) bufp; GET_BYTES(1);
 70+ b.r_pathlen = (uint16_t *) bufp; GET_BYTES(2);
 71+ b.r_path = (char const *) bufp; GET_BYTES(*b.r_pathlen);
 72+ b.r_status = (uint16_t *) bufp; GET_BYTES(2);
 73+ b.r_belen = (uint16_t *) bufp; GET_BYTES(2);
 74+ b.r_beaddr = (char const*) bufp; GET_BYTES(*b.r_belen);
 75+ b.r_cached = (uint8_t *) bufp; GET_BYTES(1);
7676 if (buf + 4 >= end)
7777 return false;
7878 b.r_docsize = (uint32_t *)bufp;
Index: trunk/willow/src/wgetstats/wgetstats.cc
@@ -206,7 +206,7 @@
207207 bufp += 4;
208208 hi = *(uint32_t *) bufp;
209209 bufp += 4;
210 - nc = hi << 32 | lo;
 210+ nc = (uint64_t)hi << 32 | lo;
211211 fprintf(stderr, "\tListener %.*s: %llu connections\n",
212212 nlen, name, nc);
213213 }
Index: trunk/willow/src/whtcp/whtcp.cc
@@ -143,7 +143,7 @@
144144
145145 ustring bkey;
146146 unbase64_string it(key.begin());
147 - for (size_t i = 0; i < 64; ++i) {
 147+ for (size_t n = 0; n < 512; ++n) {
148148 bkey.push_back(*it++);
149149 }
150150
@@ -187,7 +187,6 @@
188188 timeval start, finish;
189189 bool gflag = false, cflag = false;
190190 string keystore, keyname;
191 -ustring key;
192191
193192 while ((i = getopt(argc, argv, "nqgS:K:c")) != -1) {
194193 switch (i) {
Index: trunk/willow/src/willow/cache.cc
@@ -33,7 +33,7 @@
3434 }
3535
3636 shared_ptr<cachedentity>
37 -httpcache::find_cached(imstring const &url, bool create, bool &wasnew)
 37+httpcache::find_cached(imstring const &url, bool createnew, bool &wasnew)
3838 {
3939 map<imstring, shared_ptr<cachedentity> >::iterator it;
4040 if (!config.cache_memory)
@@ -77,7 +77,7 @@
7878 }
7979
8080 WDEBUG(format("[%s] not cached") % url);
81 - if (!create)
 81+ if (!createnew)
8282 return shared_ptr<cachedentity>();
8383
8484 /* need to create new entity */
Index: trunk/willow/src/willow/radix.cc
@@ -29,7 +29,7 @@
3030 struct radix_node **Xsp = Xstack; \
3131 struct radix_node *Xrn = (Xhead); \
3232 while ((Xnode = Xrn)) { \
33 - if (Xnode->prefix)
 33+ if (Xnode->pfx)
3434
3535 #define RADIX_WALK_ALL(Xhead, Xnode) \
3636 do { \
@@ -171,6 +171,15 @@
172172 }
173173 }
174174
 175+radix::radix(radix const &o)
 176+ : head(NULL)
 177+ , maxbits(o.maxbits)
 178+ , num_active_node(o.num_active_node)
 179+ , dtor(o.dtor)
 180+{
 181+ head = new radix_node(*o.head);
 182+}
 183+
175184 radix::radix(void)
176185 : head(NULL)
177186 , maxbits(128)
@@ -179,6 +188,17 @@
180189 {
181190 }
182191
 192+radix&
 193+radix::operator=(radix const &other)
 194+{
 195+ head = new radix_node(*other.head);
 196+ maxbits = other.maxbits;
 197+ num_active_node = other.num_active_node;
 198+ dtor = other.dtor;
 199+ return *this;
 200+}
 201+
 202+
183203 radix::~radix(void)
184204 {
185205 clear(dtor);
@@ -223,11 +243,11 @@
224244 addr = prefix->tochar();
225245
226246 while (node->bit < prefix->prefixlen) {
227 - if (node->prefix) {
 247+ if (node->pfx) {
228248 stack[cnt++] = node;
229249 }
230250
231 - if (BIT_TEST (addr[node->bit >> 3], 0x80 >> (node->bit & 0x07))) {
 251+ if (BIT_TEST(addr[node->bit >> 3], 0x80 >> (node->bit & 0x07))) {
232252 node = node->r;
233253 } else {
234254 node = node->l;
@@ -237,16 +257,16 @@
238258 break;
239259 }
240260
241 - if (inclusive && node && node->prefix)
 261+ if (inclusive && node && node->pfx)
242262 stack[cnt++] = node;
243263
244264 if (cnt <= 0) {
245 - return (NULL);
 265+ return NULL;
246266 }
247267
248268 while (--cnt >= 0) {
249269 node = stack[cnt];
250 - if (comp_with_mask(node->prefix->tochar(), prefix->tochar(), node->prefix->prefixlen)) {
 270+ if (comp_with_mask(node->pfx->tochar(), prefix->tochar(), node->pfx->prefixlen)) {
251271 return node;
252272 }
253273 }
@@ -265,14 +285,14 @@
266286 radix_node *l = Xrn->l;
267287 radix_node *r = Xrn->r;
268288
269 - if (Xrn->prefix) {
270 - delete Xrn->prefix;
 289+ if (Xrn->pfx) {
 290+ delete Xrn->pfx;
271291 if (Xrn->data && func)
272292 ((void (*)(void *))func) (Xrn->data);
273293 } else {
274294 assert (NULL == Xrn->data);
275295 }
276 - Xrn->prefix = NULL;
 296+ Xrn->pfx = NULL;
277297 delete Xrn;
278298 num_active_node--;
279299 if (l) {
@@ -302,7 +322,7 @@
303323 return;
304324
305325 RADIX_WALK (head, node) {
306 - ((void (*)(prefix *, void *)) func) (node->prefix, node->data);
 326+ ((void (*)(prefix *, void *)) func) (node->pfx, node->data);
307327 } RADIX_WALK_END;
308328 }
309329
@@ -350,11 +370,11 @@
351371 if (node == NULL)
352372 return NULL;
353373 }
354 - if (node->bit > pfx->prefixlen || node->prefix == NULL)
 374+ if (node->bit > pfx->prefixlen || node->pfx == NULL)
355375 return NULL;
356376 assert(node->bit == pfx->prefixlen);
357 - assert(node->bit == node->prefix->prefixlen);
358 - if (comp_with_mask(node->prefix->tochar(), pfx->tochar(), pfx->prefixlen))
 377+ assert(node->bit == node->pfx->prefixlen);
 378+ if (comp_with_mask(node->pfx->tochar(), pfx->tochar(), pfx->prefixlen))
359379 return node;
360380
361381 return NULL;
@@ -388,7 +408,7 @@
389409 if (head == NULL) {
390410 node = new radix_node;
391411 node->bit = pfx->prefixlen;
392 - node->prefix = pfx;
 412+ node->pfx = pfx;
393413 node->parent = NULL;
394414 node->l = node->r = NULL;
395415 node->data = NULL;
@@ -401,7 +421,7 @@
402422 prefixlen = pfx->prefixlen;
403423 node = head;
404424
405 - while (node->bit < prefixlen || node->prefix == NULL) {
 425+ while (node->bit < prefixlen || node->pfx == NULL) {
406426 if (node->bit < maxbits && BIT_TEST(addr[node->bit >> 3], 0x80 >> (node->bit & 0x07))) {
407427 if (node->r == NULL)
408428 break;
@@ -413,9 +433,9 @@
414434 }
415435 assert (node);
416436 }
417 - assert(node->prefix);
 437+ assert(node->pfx);
418438
419 - test_addr = node->prefix->tochar();
 439+ test_addr = node->pfx->tochar();
420440 /* find the first bit different */
421441 check_bit = (node->bit < prefixlen)? node->bit: prefixlen;
422442 differ_bit = 0;
@@ -445,17 +465,17 @@
446466 }
447467
448468 if (differ_bit == prefixlen && node->bit == prefixlen) {
449 - if (node->prefix) {
 469+ if (node->pfx) {
450470 return node;
451471 }
452 - node->prefix = pfx;
 472+ node->pfx = pfx;
453473 assert(node->data == NULL);
454474 return node;
455475 }
456476
457477 new_node = new radix_node;
458478 new_node->bit = pfx->prefixlen;
459 - new_node->prefix = pfx;
 479+ new_node->pfx = pfx;
460480 new_node->parent = NULL;
461481 new_node->l = new_node->r = NULL;
462482 new_node->data = NULL;
@@ -492,7 +512,7 @@
493513 } else {
494514 glue = new radix_node;
495515 glue->bit = differ_bit;
496 - glue->prefix = NULL;
 516+ glue->pfx = NULL;
497517 glue->parent = node->parent;
498518 glue->data = NULL;
499519 num_active_node++;
@@ -525,16 +545,16 @@
526546 assert (node);
527547
528548 if (node->r && node->l) {
529 - delete node->prefix;
530 - node->prefix = NULL;
 549+ delete node->pfx;
 550+ node->pfx = NULL;
531551 node->data = NULL;
532552 return;
533553 }
534554
535555 if (node->r == NULL && node->l == NULL) {
536556 parent = node->parent;
537 - delete node->prefix;
538 - node->prefix = NULL;
 557+ delete node->pfx;
 558+ node->pfx = NULL;
539559 delete node;
540560 num_active_node--;
541561 if (parent == NULL) {
@@ -552,7 +572,7 @@
553573 child = parent->r;
554574 }
555575
556 - if (parent->prefix)
 576+ if (parent->pfx)
557577 return;
558578
559579 /* we need to remove parent too */
@@ -580,8 +600,8 @@
581601 parent = node->parent;
582602 child->parent = parent;
583603
584 - delete node->prefix;
585 - node->prefix = NULL;
 604+ delete node->pfx;
 605+ node->pfx = NULL;
586606 delete node;
587607 num_active_node--;
588608
@@ -619,6 +639,21 @@
620640 return 0;
621641 }
622642
 643+radix_node::radix_node(radix_node const &o)
 644+ : bit(o.bit)
 645+ , pfx(NULL)
 646+ , l(NULL)
 647+ , r(NULL)
 648+ , parent(NULL)
 649+ , data(o.data)
 650+ , flags(o.flags)
 651+{
 652+ pfx = new prefix(*o.pfx);
 653+ l = new radix_node(*o.l);
 654+ r = new radix_node(*o.r);
 655+ parent = new radix_node(*o.parent);
 656+}
 657+
623658 /*
624659 * Lower 16 bits are reserved for consumers.
625660 */
Index: trunk/willow/src/willow/wbackend.cc
@@ -60,9 +60,9 @@
6161 % be_straddr % be_hash);
6262 }
6363
64 -backend_pool::backend_pool(string const &name, lb_type lbt, int failgroup)
 64+backend_pool::backend_pool(string const &name_, lb_type lbt, int failgroup)
6565 : _lbtype(lbt)
66 - , _name(name)
 66+ , _name(name_)
6767 , _failgroup(failgroup)
6868 {
6969 WDEBUG(format("creating backend_pool, lbt=%d") % (int) lbt);
Index: trunk/willow/src/willow/confparse.cc
@@ -515,18 +515,18 @@
516516 }
517517
518518 block_definer &
519 -block_definer::block(string const &name, int flags)
 519+block_definer::block(string const &name_, int flags_)
520520 {
521 - return parent.block(name, flags);
 521+ return parent.block(name_, flags_);
522522 }
523523
524524 bool
525525 block_definer::validate(tree_entry &e)
526526 {
527 -map<string, conf::value>::iterator it, end;
 527+map<string, conf::value>::iterator it, end_;
528528 map<string, value_definer *>::iterator vit;
529529 bool ret = true;
530 - for (it = e.item_values.begin(), end = e.item_values.end(); it != end; ++it) {
 530+ for (it = e.item_values.begin(), end_ = e.item_values.end(); it != end_; ++it) {
531531 vit = values.find(it->first);
532532 if (vit == values.end())
533533 continue;
@@ -545,9 +545,9 @@
546546 void
547547 block_definer::set(tree_entry &e)
548548 {
549 -map<string, conf::value>::iterator it, end;
 549+map<string, conf::value>::iterator it, end_;
550550 map<string, value_definer *>::iterator vit;
551 - for (it = e.item_values.begin(), end = e.item_values.end(); it != end; ++it) {
 551+ for (it = e.item_values.begin(), end_ = e.item_values.end(); it != end_; ++it) {
552552 vit = values.find(it->first);
553553 if (vit == values.end())
554554 continue;