Index: trunk/willow/configure.in |
— | — | @@ -44,6 +44,20 @@ |
45 | 45 | testflag -Wno-unused |
46 | 46 | testflag -g |
47 | 47 | 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 |
48 | 62 | if test ! "$ac_cv_cxx_compiler_gnu" = "yes"; then |
49 | 63 | testflag -errtags |
50 | 64 | fi |
Index: trunk/willow/src/include/wthread.h |
— | — | @@ -175,17 +175,8 @@ |
176 | 176 | HOLDING(v1.m); |
177 | 177 | return v1.v | v2; |
178 | 178 | } |
| 179 | + |
179 | 180 | 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> |
190 | 181 | T1 operator == (atomic<T1> const &v1, T2 v2) { |
191 | 182 | HOLDING(v1.m); |
192 | 183 | return v1.v == v2; |
Index: trunk/willow/src/include/cache.h |
— | — | @@ -111,8 +111,8 @@ |
112 | 112 | } |
113 | 113 | |
114 | 114 | 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; |
117 | 117 | _statuscode = code; |
118 | 118 | } |
119 | 119 | |
Index: trunk/willow/src/include/polycaller.h |
— | — | @@ -14,6 +14,7 @@ |
15 | 15 | |
16 | 16 | #include <stdexcept> |
17 | 17 | #include <typeinfo> |
| 18 | +using std::type_info; |
18 | 19 | |
19 | 20 | #include "willow.h" |
20 | 21 | |
— | — | @@ -25,16 +26,6 @@ |
26 | 27 | polycaller_object_missing() : std::logic_error("polycaller called with no object") {} |
27 | 28 | }; |
28 | 29 | |
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 | | - |
39 | 30 | template<typename arg1, typename arg2, typename arg3> |
40 | 31 | struct polycaller_impl_base3 { |
41 | 32 | virtual ~polycaller_impl_base3(void) {} |
— | — | @@ -59,36 +50,46 @@ |
60 | 51 | }; |
61 | 52 | |
62 | 53 | 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; |
65 | 57 | |
| 58 | + polycaller(void) : tid(NULL), impl(NULL) {} |
| 59 | + ~polycaller() { |
| 60 | + delete impl; |
| 61 | + } |
| 62 | + |
66 | 63 | template<typename T> |
67 | 64 | polycaller(T &o, void (T::*f) (arg1, arg2, arg3)) { |
68 | 65 | assign(o, f); |
69 | 66 | } |
70 | 67 | |
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(); |
73 | 74 | return *this; |
74 | 75 | } |
75 | 76 | |
76 | 77 | 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) { |
79 | 80 | if (other.impl) |
80 | | - this->impl = other.impl->clone(); |
| 81 | + impl = other.impl->clone(); |
81 | 82 | } |
82 | 83 | |
83 | 84 | template<typename T> |
84 | 85 | 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); |
88 | 89 | return *this; |
89 | 90 | } |
90 | 91 | |
91 | 92 | void operator() (arg1 a, arg2 b, arg3 c) const { |
92 | | - this->impl->call(a, b, c); |
| 93 | + impl->call(a, b, c); |
93 | 94 | } |
94 | 95 | }; |
95 | 96 | |
— | — | @@ -116,25 +117,36 @@ |
117 | 118 | }; |
118 | 119 | |
119 | 120 | 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; |
122 | 124 | |
| 125 | + polycaller(void) : tid(NULL), impl(NULL) {} |
| 126 | + ~polycaller() { |
| 127 | + delete impl; |
| 128 | + } |
| 129 | + |
123 | 130 | 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) { |
125 | 134 | assign(o, f); |
126 | 135 | } |
127 | 136 | |
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(); |
131 | 143 | return *this; |
132 | 144 | } |
133 | 145 | |
134 | 146 | 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) { |
137 | 149 | if (other.impl) |
138 | | - this->impl = other.impl->clone(); |
| 150 | + impl = other.impl->clone(); |
139 | 151 | } |
140 | 152 | |
141 | 153 | template<typename T> |
— | — | @@ -174,36 +186,44 @@ |
175 | 187 | }; |
176 | 188 | |
177 | 189 | 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; |
180 | 193 | |
| 194 | + polycaller(void) : tid(NULL), impl(NULL) {} |
| 195 | + ~polycaller() { |
| 196 | + delete impl; |
| 197 | + } |
| 198 | + |
181 | 199 | template<typename T> |
182 | 200 | polycaller(T &o, void (T::*f) (arg1)) { |
183 | 201 | assign(o, f); |
184 | 202 | } |
185 | 203 | 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) { |
188 | 206 | if (other.impl) |
189 | 207 | this->impl = other.impl->clone(); |
190 | 208 | } |
191 | 209 | |
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(); |
195 | 215 | return *this; |
196 | 216 | } |
197 | 217 | |
198 | 218 | template<typename T> |
199 | 219 | 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; |
204 | 224 | } |
205 | 225 | |
206 | 226 | void operator() (arg1 a) const { |
207 | | - this->impl->call(a); |
| 227 | + impl->call(a); |
208 | 228 | } |
209 | 229 | }; |
210 | 230 | |
— | — | @@ -230,27 +250,36 @@ |
231 | 251 | }; |
232 | 252 | |
233 | 253 | 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) { |
238 | 261 | } |
239 | 262 | |
| 263 | + ~polycaller() { |
| 264 | + delete impl; |
| 265 | + } |
| 266 | + |
240 | 267 | 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) { |
243 | 271 | assign(o, f); |
244 | 272 | } |
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(); |
247 | 277 | return *this; |
248 | 278 | } |
249 | 279 | 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) { |
252 | 282 | if (other.impl) |
253 | 283 | impl = other.impl->clone(); |
254 | | - else impl = NULL; |
255 | 284 | } |
256 | 285 | |
257 | 286 | template<typename T> |
— | — | @@ -442,10 +471,10 @@ |
443 | 472 | |
444 | 473 | polycallback() : binder(NULL), _null(true) {} |
445 | 474 | polycallback(polycallback<> const &other) |
446 | | - : _null(other._null) { |
| 475 | + : binder(NULL) |
| 476 | + , _null(other._null) { |
447 | 477 | if (other.binder) |
448 | 478 | binder = other.binder->clone(); |
449 | | - else binder = NULL; |
450 | 479 | } |
451 | 480 | |
452 | 481 | polycallback& operator=(polycallback<> const &other) { |
Index: trunk/willow/src/include/radix.h |
— | — | @@ -74,19 +74,31 @@ |
75 | 75 | }; |
76 | 76 | |
77 | 77 | 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; |
85 | 95 | }; |
86 | 96 | |
87 | 97 | class radix { |
88 | 98 | public: |
89 | 99 | radix(); |
90 | | - ~radix(); |
| 100 | + virtual ~radix(); |
| 101 | + radix(radix const &); |
| 102 | + radix &operator= (radix const &); |
91 | 103 | |
92 | 104 | void set_dtor (void_fn_t); |
93 | 105 | radix_node *add (char const *); |
Index: trunk/willow/src/include/wlog.h |
— | — | @@ -28,7 +28,7 @@ |
29 | 29 | ll_error |
30 | 30 | }; |
31 | 31 | |
32 | | -struct logger { |
| 32 | +struct logger : noncopyable { |
33 | 33 | logger(); |
34 | 34 | |
35 | 35 | void syslog (bool, int facility = 0); |
Index: trunk/willow/src/include/willow.h |
— | — | @@ -103,8 +103,11 @@ |
104 | 104 | * Absolute values. |
105 | 105 | */ |
106 | 106 | 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) { |
109 | 112 | } |
110 | 113 | uint64_t n_httpreq_ok; /* requests which were sent to a backend */ |
111 | 114 | uint64_t n_httpreq_fail; /* requests which did not reach a backend */ |
— | — | @@ -246,9 +249,9 @@ |
247 | 250 | |
248 | 251 | template<typename charT, typename allocator> |
249 | 252 | 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) |
251 | 254 | { |
252 | | - assign(str, end - str); |
| 255 | + assign(str, send - str); |
253 | 256 | } |
254 | 257 | |
255 | 258 | template<typename charT, typename allocator> |
— | — | @@ -480,7 +483,7 @@ |
481 | 484 | * A buffer which uses /dev/shm buffers if possible (on Linux), so we can use |
482 | 485 | * sendfile() on the buffer. |
483 | 486 | */ |
484 | | -struct diobuf : freelist_allocator<diobuf> { |
| 487 | +struct diobuf : noncopyable, freelist_allocator<diobuf> { |
485 | 488 | diobuf(size_t size = 4096); |
486 | 489 | ~diobuf(void); |
487 | 490 | |
Index: trunk/willow/src/include/wnet.h |
— | — | @@ -124,11 +124,21 @@ |
125 | 125 | , free(free_) { |
126 | 126 | } |
127 | 127 | buffer_item(buffer_item const &o) |
128 | | - : len(o.len) |
| 128 | + : buf(NULL) |
| 129 | + , len(o.len) |
129 | 130 | , off(o.off) |
130 | 131 | , free(true) { |
131 | 132 | buf = (const char *)memcpy(new char[len], o.buf, len); |
132 | 133 | } |
| 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 | + } |
133 | 143 | |
134 | 144 | ~buffer_item() { |
135 | 145 | if (free) |
Index: trunk/willow/src/include/expr.h |
— | — | @@ -39,7 +39,7 @@ |
40 | 40 | using boost::shared_ptr; |
41 | 41 | |
42 | 42 | struct expression_error : runtime_error { |
43 | | - expression_error(char const *what) : runtime_error(what) {} |
| 43 | + expression_error(char const *err) : runtime_error(err) {} |
44 | 44 | }; |
45 | 45 | |
46 | 46 | struct stack_underflow : expression_error { |
Index: trunk/willow/src/include/confparse.h |
— | — | @@ -384,21 +384,23 @@ |
385 | 385 | |
386 | 386 | extern const int require_name; |
387 | 387 | |
388 | | -struct block_definer { |
| 388 | +struct block_definer : noncopyable { |
389 | 389 | block_definer(conf_definer &parent_, string const &name, int flags); |
390 | 390 | ~block_definer(); |
391 | 391 | |
392 | 392 | 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))); |
395 | 395 | return *this; |
396 | 396 | } |
| 397 | + |
397 | 398 | template<typename Vt, typename St> |
398 | 399 | block_definer &end(Vt vefn_, St sefn_) { |
399 | 400 | vefn = new Vt(vefn_); |
400 | 401 | sefn = new St(sefn_); |
401 | 402 | return *this; |
402 | 403 | } |
| 404 | + |
403 | 405 | template<typename St> |
404 | 406 | block_definer &end(St sefn_) { |
405 | 407 | sefn = new St(sefn_); |
— | — | @@ -409,6 +411,9 @@ |
410 | 412 | bool validate(tree_entry &e); |
411 | 413 | void set(tree_entry &e); |
412 | 414 | |
| 415 | +private: |
| 416 | + friend class conf_definer; |
| 417 | + |
413 | 418 | conf_definer &parent; |
414 | 419 | string name; |
415 | 420 | map<string, value_definer *> values; |
Index: trunk/willow/src/include/md5.h |
— | — | @@ -129,13 +129,13 @@ |
130 | 130 | memset(_opad, 0x5C, sizeof(_opad)); |
131 | 131 | } |
132 | 132 | |
133 | | - void key(unsigned char const *key, size_t keylen) { |
| 133 | + void key(unsigned char const *nkey, size_t keylen) { |
134 | 134 | if (keylen > block_size) { |
135 | | - hash h(key, keylen); |
| 135 | + hash h(nkey, keylen); |
136 | 136 | memcpy(_key, h.digest(), digest_size); |
137 | 137 | _keylen = digest_size; |
138 | 138 | } else { |
139 | | - memcpy(_key, key, keylen); |
| 139 | + memcpy(_key, nkey, keylen); |
140 | 140 | _keylen = keylen; |
141 | 141 | } |
142 | 142 | |
Index: trunk/willow/src/include/mbuffer.h |
— | — | @@ -18,11 +18,17 @@ |
19 | 19 | #include <cassert> |
20 | 20 | #include <string> |
21 | 21 | #include <cstddef> |
| 22 | +#include <stdexcept> |
22 | 23 | using std::size_t; |
23 | 24 | using std::basic_string; |
| 25 | +using std::logic_error; |
24 | 26 | |
25 | 27 | #include "willow.h" |
26 | 28 | |
| 29 | +struct marshalling_buffer_overflow : logic_error { |
| 30 | + marshalling_buffer_overflow() : logic_error("marshalling buffer overflow") {} |
| 31 | +}; |
| 32 | + |
27 | 33 | struct marshalling_buffer { |
28 | 34 | marshalling_buffer() |
29 | 35 | : _buf(NULL) |
— | — | @@ -37,13 +43,33 @@ |
38 | 44 | , _bufsz(sz) |
39 | 45 | , _delete(false) |
40 | 46 | {} |
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 | + |
42 | 63 | ~marshalling_buffer(void) { |
| 64 | + if (_delete) |
| 65 | + delete[] _buf; |
43 | 66 | } |
44 | 67 | |
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]; |
48 | 74 | } |
49 | 75 | |
50 | 76 | template<typename T> |
— | — | @@ -55,7 +81,9 @@ |
56 | 82 | template<typename T> |
57 | 83 | typename enable_if<is_char_type<T>, void>::type |
58 | 84 | append_bytes(T const *buf, size_t s) { |
59 | | - assert(_size + s <= _bufsz); |
| 85 | + if (_size + s > _bufsz) |
| 86 | + throw marshalling_buffer_overflow(); |
| 87 | + |
60 | 88 | memcpy(_buf + _size, buf, s); |
61 | 89 | _size += s; |
62 | 90 | } |
Index: trunk/willow/src/libwillow/htcp.cc |
— | — | @@ -228,11 +228,11 @@ |
229 | 229 | } |
230 | 230 | |
231 | 231 | void |
232 | | -htcp_encoder::key(string const &keyname, ustring const &key) |
| 232 | +htcp_encoder::key(string const &keyname, ustring const &nkey) |
233 | 233 | { |
234 | 234 | _sign = true; |
235 | 235 | _auth.ha_keyname = keyname; |
236 | | - _key = key; |
| 236 | + _key = nkey; |
237 | 237 | } |
238 | 238 | |
239 | 239 | htcp_opdata * |
— | — | @@ -294,13 +294,16 @@ |
295 | 295 | } |
296 | 296 | |
297 | 297 | bool |
298 | | -htcp_decoder::verify_signature(string const &keyname, ustring const &key, |
| 298 | +htcp_decoder::verify_signature(string const &nkeyname, ustring const &key, |
299 | 299 | sockaddr *src, sockaddr *dst) |
300 | 300 | { |
301 | 301 | marshalling_buffer buf; |
302 | | -ustring signature; |
| 302 | +ustring sig; |
303 | 303 | int oplen = _opheader.length() + _opdata->length(); |
304 | 304 | |
| 305 | + if (nkeyname != _auth.ha_keyname) |
| 306 | + return false; |
| 307 | + |
305 | 308 | buf.reserve(22 + oplen + socklen(src) + socklen(dst)); |
306 | 309 | htcp_encoder::encode_sockaddr(buf, src); |
307 | 310 | htcp_encoder::encode_sockaddr(buf, dst); |
— | — | @@ -313,12 +316,12 @@ |
314 | 317 | mac.run(buf.buffer(), buf.size()); |
315 | 318 | |
316 | 319 | hmac<md5>::digest_t digest = mac.digest(); |
317 | | - signature.assign(digest, digest + sizeof(digest)); |
| 320 | + sig.assign(digest, digest + sizeof(digest)); |
318 | 321 | |
319 | | - if (signature != _auth.ha_signature) |
| 322 | + if (sig != _auth.ha_signature) |
320 | 323 | return false; |
321 | 324 | |
322 | | - if (_auth.ha_sigexpire <= time(0)) |
| 325 | + if ((time_t)_auth.ha_sigexpire <= time(0)) |
323 | 326 | return false; |
324 | 327 | |
325 | 328 | return true; |
Index: trunk/willow/src/wreadlog/packet_decoder.cc |
— | — | @@ -22,11 +22,11 @@ |
23 | 23 | struct logent_buf { |
24 | 24 | uint32_t *r_reqtime; |
25 | 25 | uint16_t *r_clilen, *r_pathlen, *r_belen; |
26 | | - char *r_cliaddr; |
| 26 | + char const *r_cliaddr; |
27 | 27 | uint8_t *r_reqtype; |
28 | | - char *r_path; |
| 28 | + char const *r_path; |
29 | 29 | uint16_t *r_status; |
30 | | - char *r_beaddr; |
| 30 | + char const *r_beaddr; |
31 | 31 | uint8_t *r_cached; |
32 | 32 | uint32_t *r_docsize; |
33 | 33 | }; |
— | — | @@ -62,16 +62,16 @@ |
63 | 63 | bufp += (s); \ |
64 | 64 | } |
65 | 65 | 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); |
76 | 76 | if (buf + 4 >= end) |
77 | 77 | return false; |
78 | 78 | b.r_docsize = (uint32_t *)bufp; |
Index: trunk/willow/src/wgetstats/wgetstats.cc |
— | — | @@ -206,7 +206,7 @@ |
207 | 207 | bufp += 4; |
208 | 208 | hi = *(uint32_t *) bufp; |
209 | 209 | bufp += 4; |
210 | | - nc = hi << 32 | lo; |
| 210 | + nc = (uint64_t)hi << 32 | lo; |
211 | 211 | fprintf(stderr, "\tListener %.*s: %llu connections\n", |
212 | 212 | nlen, name, nc); |
213 | 213 | } |
Index: trunk/willow/src/whtcp/whtcp.cc |
— | — | @@ -143,7 +143,7 @@ |
144 | 144 | |
145 | 145 | ustring bkey; |
146 | 146 | unbase64_string it(key.begin()); |
147 | | - for (size_t i = 0; i < 64; ++i) { |
| 147 | + for (size_t n = 0; n < 512; ++n) { |
148 | 148 | bkey.push_back(*it++); |
149 | 149 | } |
150 | 150 | |
— | — | @@ -187,7 +187,6 @@ |
188 | 188 | timeval start, finish; |
189 | 189 | bool gflag = false, cflag = false; |
190 | 190 | string keystore, keyname; |
191 | | -ustring key; |
192 | 191 | |
193 | 192 | while ((i = getopt(argc, argv, "nqgS:K:c")) != -1) { |
194 | 193 | switch (i) { |
Index: trunk/willow/src/willow/cache.cc |
— | — | @@ -33,7 +33,7 @@ |
34 | 34 | } |
35 | 35 | |
36 | 36 | 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) |
38 | 38 | { |
39 | 39 | map<imstring, shared_ptr<cachedentity> >::iterator it; |
40 | 40 | if (!config.cache_memory) |
— | — | @@ -77,7 +77,7 @@ |
78 | 78 | } |
79 | 79 | |
80 | 80 | WDEBUG(format("[%s] not cached") % url); |
81 | | - if (!create) |
| 81 | + if (!createnew) |
82 | 82 | return shared_ptr<cachedentity>(); |
83 | 83 | |
84 | 84 | /* need to create new entity */ |
Index: trunk/willow/src/willow/radix.cc |
— | — | @@ -29,7 +29,7 @@ |
30 | 30 | struct radix_node **Xsp = Xstack; \ |
31 | 31 | struct radix_node *Xrn = (Xhead); \ |
32 | 32 | while ((Xnode = Xrn)) { \ |
33 | | - if (Xnode->prefix) |
| 33 | + if (Xnode->pfx) |
34 | 34 | |
35 | 35 | #define RADIX_WALK_ALL(Xhead, Xnode) \ |
36 | 36 | do { \ |
— | — | @@ -171,6 +171,15 @@ |
172 | 172 | } |
173 | 173 | } |
174 | 174 | |
| 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 | + |
175 | 184 | radix::radix(void) |
176 | 185 | : head(NULL) |
177 | 186 | , maxbits(128) |
— | — | @@ -179,6 +188,17 @@ |
180 | 189 | { |
181 | 190 | } |
182 | 191 | |
| 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 | + |
183 | 203 | radix::~radix(void) |
184 | 204 | { |
185 | 205 | clear(dtor); |
— | — | @@ -223,11 +243,11 @@ |
224 | 244 | addr = prefix->tochar(); |
225 | 245 | |
226 | 246 | while (node->bit < prefix->prefixlen) { |
227 | | - if (node->prefix) { |
| 247 | + if (node->pfx) { |
228 | 248 | stack[cnt++] = node; |
229 | 249 | } |
230 | 250 | |
231 | | - if (BIT_TEST (addr[node->bit >> 3], 0x80 >> (node->bit & 0x07))) { |
| 251 | + if (BIT_TEST(addr[node->bit >> 3], 0x80 >> (node->bit & 0x07))) { |
232 | 252 | node = node->r; |
233 | 253 | } else { |
234 | 254 | node = node->l; |
— | — | @@ -237,16 +257,16 @@ |
238 | 258 | break; |
239 | 259 | } |
240 | 260 | |
241 | | - if (inclusive && node && node->prefix) |
| 261 | + if (inclusive && node && node->pfx) |
242 | 262 | stack[cnt++] = node; |
243 | 263 | |
244 | 264 | if (cnt <= 0) { |
245 | | - return (NULL); |
| 265 | + return NULL; |
246 | 266 | } |
247 | 267 | |
248 | 268 | while (--cnt >= 0) { |
249 | 269 | 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)) { |
251 | 271 | return node; |
252 | 272 | } |
253 | 273 | } |
— | — | @@ -265,14 +285,14 @@ |
266 | 286 | radix_node *l = Xrn->l; |
267 | 287 | radix_node *r = Xrn->r; |
268 | 288 | |
269 | | - if (Xrn->prefix) { |
270 | | - delete Xrn->prefix; |
| 289 | + if (Xrn->pfx) { |
| 290 | + delete Xrn->pfx; |
271 | 291 | if (Xrn->data && func) |
272 | 292 | ((void (*)(void *))func) (Xrn->data); |
273 | 293 | } else { |
274 | 294 | assert (NULL == Xrn->data); |
275 | 295 | } |
276 | | - Xrn->prefix = NULL; |
| 296 | + Xrn->pfx = NULL; |
277 | 297 | delete Xrn; |
278 | 298 | num_active_node--; |
279 | 299 | if (l) { |
— | — | @@ -302,7 +322,7 @@ |
303 | 323 | return; |
304 | 324 | |
305 | 325 | RADIX_WALK (head, node) { |
306 | | - ((void (*)(prefix *, void *)) func) (node->prefix, node->data); |
| 326 | + ((void (*)(prefix *, void *)) func) (node->pfx, node->data); |
307 | 327 | } RADIX_WALK_END; |
308 | 328 | } |
309 | 329 | |
— | — | @@ -350,11 +370,11 @@ |
351 | 371 | if (node == NULL) |
352 | 372 | return NULL; |
353 | 373 | } |
354 | | - if (node->bit > pfx->prefixlen || node->prefix == NULL) |
| 374 | + if (node->bit > pfx->prefixlen || node->pfx == NULL) |
355 | 375 | return NULL; |
356 | 376 | 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)) |
359 | 379 | return node; |
360 | 380 | |
361 | 381 | return NULL; |
— | — | @@ -388,7 +408,7 @@ |
389 | 409 | if (head == NULL) { |
390 | 410 | node = new radix_node; |
391 | 411 | node->bit = pfx->prefixlen; |
392 | | - node->prefix = pfx; |
| 412 | + node->pfx = pfx; |
393 | 413 | node->parent = NULL; |
394 | 414 | node->l = node->r = NULL; |
395 | 415 | node->data = NULL; |
— | — | @@ -401,7 +421,7 @@ |
402 | 422 | prefixlen = pfx->prefixlen; |
403 | 423 | node = head; |
404 | 424 | |
405 | | - while (node->bit < prefixlen || node->prefix == NULL) { |
| 425 | + while (node->bit < prefixlen || node->pfx == NULL) { |
406 | 426 | if (node->bit < maxbits && BIT_TEST(addr[node->bit >> 3], 0x80 >> (node->bit & 0x07))) { |
407 | 427 | if (node->r == NULL) |
408 | 428 | break; |
— | — | @@ -413,9 +433,9 @@ |
414 | 434 | } |
415 | 435 | assert (node); |
416 | 436 | } |
417 | | - assert(node->prefix); |
| 437 | + assert(node->pfx); |
418 | 438 | |
419 | | - test_addr = node->prefix->tochar(); |
| 439 | + test_addr = node->pfx->tochar(); |
420 | 440 | /* find the first bit different */ |
421 | 441 | check_bit = (node->bit < prefixlen)? node->bit: prefixlen; |
422 | 442 | differ_bit = 0; |
— | — | @@ -445,17 +465,17 @@ |
446 | 466 | } |
447 | 467 | |
448 | 468 | if (differ_bit == prefixlen && node->bit == prefixlen) { |
449 | | - if (node->prefix) { |
| 469 | + if (node->pfx) { |
450 | 470 | return node; |
451 | 471 | } |
452 | | - node->prefix = pfx; |
| 472 | + node->pfx = pfx; |
453 | 473 | assert(node->data == NULL); |
454 | 474 | return node; |
455 | 475 | } |
456 | 476 | |
457 | 477 | new_node = new radix_node; |
458 | 478 | new_node->bit = pfx->prefixlen; |
459 | | - new_node->prefix = pfx; |
| 479 | + new_node->pfx = pfx; |
460 | 480 | new_node->parent = NULL; |
461 | 481 | new_node->l = new_node->r = NULL; |
462 | 482 | new_node->data = NULL; |
— | — | @@ -492,7 +512,7 @@ |
493 | 513 | } else { |
494 | 514 | glue = new radix_node; |
495 | 515 | glue->bit = differ_bit; |
496 | | - glue->prefix = NULL; |
| 516 | + glue->pfx = NULL; |
497 | 517 | glue->parent = node->parent; |
498 | 518 | glue->data = NULL; |
499 | 519 | num_active_node++; |
— | — | @@ -525,16 +545,16 @@ |
526 | 546 | assert (node); |
527 | 547 | |
528 | 548 | if (node->r && node->l) { |
529 | | - delete node->prefix; |
530 | | - node->prefix = NULL; |
| 549 | + delete node->pfx; |
| 550 | + node->pfx = NULL; |
531 | 551 | node->data = NULL; |
532 | 552 | return; |
533 | 553 | } |
534 | 554 | |
535 | 555 | if (node->r == NULL && node->l == NULL) { |
536 | 556 | parent = node->parent; |
537 | | - delete node->prefix; |
538 | | - node->prefix = NULL; |
| 557 | + delete node->pfx; |
| 558 | + node->pfx = NULL; |
539 | 559 | delete node; |
540 | 560 | num_active_node--; |
541 | 561 | if (parent == NULL) { |
— | — | @@ -552,7 +572,7 @@ |
553 | 573 | child = parent->r; |
554 | 574 | } |
555 | 575 | |
556 | | - if (parent->prefix) |
| 576 | + if (parent->pfx) |
557 | 577 | return; |
558 | 578 | |
559 | 579 | /* we need to remove parent too */ |
— | — | @@ -580,8 +600,8 @@ |
581 | 601 | parent = node->parent; |
582 | 602 | child->parent = parent; |
583 | 603 | |
584 | | - delete node->prefix; |
585 | | - node->prefix = NULL; |
| 604 | + delete node->pfx; |
| 605 | + node->pfx = NULL; |
586 | 606 | delete node; |
587 | 607 | num_active_node--; |
588 | 608 | |
— | — | @@ -619,6 +639,21 @@ |
620 | 640 | return 0; |
621 | 641 | } |
622 | 642 | |
| 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 | + |
623 | 658 | /* |
624 | 659 | * Lower 16 bits are reserved for consumers. |
625 | 660 | */ |
Index: trunk/willow/src/willow/wbackend.cc |
— | — | @@ -60,9 +60,9 @@ |
61 | 61 | % be_straddr % be_hash); |
62 | 62 | } |
63 | 63 | |
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) |
65 | 65 | : _lbtype(lbt) |
66 | | - , _name(name) |
| 66 | + , _name(name_) |
67 | 67 | , _failgroup(failgroup) |
68 | 68 | { |
69 | 69 | WDEBUG(format("creating backend_pool, lbt=%d") % (int) lbt); |
Index: trunk/willow/src/willow/confparse.cc |
— | — | @@ -515,18 +515,18 @@ |
516 | 516 | } |
517 | 517 | |
518 | 518 | block_definer & |
519 | | -block_definer::block(string const &name, int flags) |
| 519 | +block_definer::block(string const &name_, int flags_) |
520 | 520 | { |
521 | | - return parent.block(name, flags); |
| 521 | + return parent.block(name_, flags_); |
522 | 522 | } |
523 | 523 | |
524 | 524 | bool |
525 | 525 | block_definer::validate(tree_entry &e) |
526 | 526 | { |
527 | | -map<string, conf::value>::iterator it, end; |
| 527 | +map<string, conf::value>::iterator it, end_; |
528 | 528 | map<string, value_definer *>::iterator vit; |
529 | 529 | 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) { |
531 | 531 | vit = values.find(it->first); |
532 | 532 | if (vit == values.end()) |
533 | 533 | continue; |
— | — | @@ -545,9 +545,9 @@ |
546 | 546 | void |
547 | 547 | block_definer::set(tree_entry &e) |
548 | 548 | { |
549 | | -map<string, conf::value>::iterator it, end; |
| 549 | +map<string, conf::value>::iterator it, end_; |
550 | 550 | 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) { |
552 | 552 | vit = values.find(it->first); |
553 | 553 | if (vit == values.end()) |
554 | 554 | continue; |