Merge lp:~stewart/percona-playback/compiler-warnings-2 into lp:~percona-dev/percona-playback/light

Proposed by Stewart Smith
Status: Merged
Merged at revision: 126
Proposed branch: lp:~stewart/percona-playback/compiler-warnings-2
Merge into: lp:~percona-dev/percona-playback/light
Prerequisite: lp:~stewart/percona-playback/compiler-warnings
Diff against target: 515 lines (+98/-158)
10 files modified
m4/pandora_have_libmysqlclient.m4 (+2/-1)
src/common.h (+1/-1)
src/long_string.cc (+61/-61)
src/long_string.h (+1/-1)
src/mysql_client.cc (+7/-7)
src/options.cc (+16/-11)
src/query.cc (+5/-66)
src/queue.h (+1/-1)
src/slow_query_log_parser.h (+2/-2)
src/supervisor.cc (+2/-7)
To merge this branch: bzr merge lp:~stewart/percona-playback/compiler-warnings-2
Reviewer Review Type Date Requested Status
Laurynas Biveinis (community) Approve
Review via email: mp+77457@code.launchpad.net

Description of the change

even more compiler warning fixes. with this tree, we're down to just 6.

To post a comment you must log in.
Revision history for this message
Laurynas Biveinis (laurynas-biveinis) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'm4/pandora_have_libmysqlclient.m4'
--- m4/pandora_have_libmysqlclient.m4 2011-09-29 06:41:38 +0000
+++ m4/pandora_have_libmysqlclient.m4 2011-09-29 06:41:38 +0000
@@ -64,10 +64,11 @@
64 AS_IF([test "x$MYSQL_CONFIG" = "xISDIR"],[64 AS_IF([test "x$MYSQL_CONFIG" = "xISDIR"],[
65 IBASE="-I${with_mysql}"65 IBASE="-I${with_mysql}"
66 MYSQL_CONFIG="${with_mysql}/scripts/mysql_config"66 MYSQL_CONFIG="${with_mysql}/scripts/mysql_config"
67 ADDIFLAGS="$IBASE/include "67 ADDIFLAGS="$IBASE/include -isystem $IBASE/include"
68 ADDLDFLAGS="-L${with_mysql}/libmysql_r/.libs/ -L${with_mysql}/mysys/.libs -L${with_mysql}/mysys -L${with_mysql}/strings/.libs -L${with_mysql}/strings "68 ADDLDFLAGS="-L${with_mysql}/libmysql_r/.libs/ -L${with_mysql}/mysys/.libs -L${with_mysql}/mysys -L${with_mysql}/strings/.libs -L${with_mysql}/strings "
69 ],[69 ],[
70 MYSQL_INCLUDES=$(${MYSQL_CONFIG} --include)70 MYSQL_INCLUDES=$(${MYSQL_CONFIG} --include)
71 MYSQL_INCLUDES="$MYSQL_INCLUDES $(echo $MYSQL_INCLUDES|sed -e 's/-I/-isystem /')"
71 MYSQL_LIBS=$(${MYSQL_CONFIG} --libs_r)72 MYSQL_LIBS=$(${MYSQL_CONFIG} --libs_r)
72 ])73 ])
7374
7475
=== modified file 'src/common.h'
--- src/common.h 2011-09-29 06:41:38 +0000
+++ src/common.h 2011-09-29 06:41:38 +0000
@@ -29,7 +29,7 @@
29#include <boost/shared_ptr.hpp>29#include <boost/shared_ptr.hpp>
30#include <pthread.h>30#include <pthread.h>
3131
32#if DEBUG32#ifdef DEBUG
33//DEBUG33//DEBUG
3434
35#include <cassert>35#include <cassert>
3636
=== modified file 'src/long_string.cc'
--- src/long_string.cc 2011-09-29 06:41:38 +0000
+++ src/long_string.cc 2011-09-29 06:41:38 +0000
@@ -123,35 +123,35 @@
123 m_length= 0;123 m_length= 0;
124 m_data[m_length]= 0;124 m_data[m_length]= 0;
125}125}
126void String::set(const char* data)126void String::set(const char* str)
127{127{
128 clear();128 clear();
129 add_last(data);129 add_last(str);
130}130}
131void String::set(const char* data, std::size_t length)131void String::set(const char* str, std::size_t len)
132{132{
133 clear();133 clear();
134 add_last(data, length);134 add_last(str, len);
135}135}
136void String::set(std::string const &data)136void String::set(std::string const &str)
137{137{
138 clear();138 clear();
139 add_last(data);139 add_last(str);
140}140}
141void String::set(String const &data)141void String::set(String const &str)
142{142{
143 clear();143 clear();
144 add_last(data);144 add_last(str);
145}145}
146void String::remove_first(std::size_t length)146void String::remove_first(std::size_t len)
147{147{
148 CHECK_C_STRING_LENGTH(m_data, m_length);148 CHECK_C_STRING_LENGTH(m_data, m_length);
149 if (m_length < length)149 if (m_length < len)
150 throw Too_Short_String(m_max, m_length, length);150 throw Too_Short_String(m_max, m_length, len);
151 else151 else
152 {152 {
153 m_length -= length;153 m_length -= len;
154 memmove(m_data, m_data + length, m_length);154 memmove(m_data, m_data + len, m_length);
155 m_data[m_length]= 0;155 m_data[m_length]= 0;
156 }156 }
157}157}
@@ -169,30 +169,30 @@
169 CHECK_C_STRING(value);169 CHECK_C_STRING(value);
170 add_last(value, strlen(value));170 add_last(value, strlen(value));
171}171}
172void String::add_last(const char* value, std::size_t length)172void String::add_last(const char* value, std::size_t len)
173{173{
174 CHECK_C_STRING_LENGTH(m_data, m_length);174 CHECK_C_STRING_LENGTH(m_data, m_length);
175 if((m_max - m_length) < length)175 if((m_max - m_length) < len)
176 {176 {
177 std::cerr << "Too_Long_String, current:\n" << (*this);177 std::cerr << "Too_Long_String, current:\n" << (*this);
178 std::cerr << "\nlength: " << m_length << " max: " << m_max;178 std::cerr << "\nlength: " << m_length << " max: " << m_max;
179 std::cerr << "\nadd_last: " << length << "\n" << std::flush;179 std::cerr << "\nadd_last: " << len << "\n" << std::flush;
180 throw Too_Long_String(m_max, m_length, length);180 throw Too_Long_String(m_max, m_length, len);
181 }181 }
182 memcpy(m_data + m_length, value, length);182 memcpy(m_data + m_length, value, len);
183 m_length += length;183 m_length += len;
184 m_data[ m_length ]= 0;184 m_data[ m_length ]= 0;
185 CHECK_C_STRING_LENGTH(m_data, m_length);185 CHECK_C_STRING_LENGTH(m_data, m_length);
186}186}
187void String::add_last(std::string const &data)187void String::add_last(std::string const &str)
188{188{
189 CHECK_C_STRING_LENGTH(m_data, m_length);189 CHECK_C_STRING_LENGTH(m_data, m_length);
190 add_last(data.c_str(), data.length());190 add_last(str.c_str(), str.length());
191}191}
192void String::add_last(String const &data)192void String::add_last(String const &str)
193{193{
194 CHECK_C_STRING_LENGTH(m_data, m_length);194 CHECK_C_STRING_LENGTH(m_data, m_length);
195 add_last(data.data(), data.length());195 add_last(str.data(), str.length());
196}196}
197std::size_t String::index(char c, std::size_t from) const197std::size_t String::index(char c, std::size_t from) const
198{198{
@@ -279,12 +279,12 @@
279 return p != s.length();279 return p != s.length();
280}280}
281281
282String_Null_Error::String_Null_Error(const char* method_name)282String_Null_Error::String_Null_Error(const char* where)
283{283{
284 m_method_name= method_name;284 m_method_name= where;
285 m_method_name_c_str= m_method_name.c_str();285 m_method_name_c_str= m_method_name.c_str();
286 m_reason= "Impossible call method ";286 m_reason= "Impossible call method ";
287 m_reason += method_name;287 m_reason += where;
288 m_reason += " when Nullable_String is null";288 m_reason += " when Nullable_String is null";
289 m_reason_c_str= m_reason.c_str();289 m_reason_c_str= m_reason.c_str();
290}290}
@@ -300,8 +300,8 @@
300{300{
301}301}
302302
303Nullable_String::Nullable_String(std::size_t max) :303Nullable_String::Nullable_String(std::size_t max_size) :
304 String(max), m_null(true)304 String(max_size), m_null(true)
305{305{
306}306}
307Nullable_String::Nullable_String(Nullable_String const &other) :307Nullable_String::Nullable_String(Nullable_String const &other) :
@@ -349,7 +349,7 @@
349 else349 else
350 return String::data();350 return String::data();
351}351}
352void Nullable_String::length(std::size_t const &length)352void Nullable_String::length(std::size_t const &len)
353{353{
354 if (m_null)354 if (m_null)
355 {355 {
@@ -357,7 +357,7 @@
357 throw String_Null_Error("length");357 throw String_Null_Error("length");
358 }358 }
359 else359 else
360 return String::length(length);360 return String::length(len);
361}361}
362std::size_t Nullable_String::length() const362std::size_t Nullable_String::length() const
363{363{
@@ -387,47 +387,47 @@
387 m_null= false;387 m_null= false;
388 String::clear();388 String::clear();
389}389}
390void Nullable_String::set(const char* data)390void Nullable_String::set(const char* str)
391{391{
392 CHECK_NULLABLE_C_STRING(data);392 CHECK_NULLABLE_C_STRING(str);
393 clear();393 clear();
394 add_last(data);394 add_last(str);
395}395}
396void Nullable_String::set(const char* data, std::size_t length)396void Nullable_String::set(const char* str, std::size_t l)
397{397{
398 clear();398 clear();
399 add_last(data, length);399 add_last(str, l);
400}400}
401void Nullable_String::set(std::string const &data)401void Nullable_String::set(std::string const &str)
402{402{
403 clear();403 clear();
404 add_last(data);404 add_last(str);
405}405}
406void Nullable_String::set(Nullable_String const &other)406void Nullable_String::set(Nullable_String const &other)
407{407{
408 clear();408 clear();
409 add_last(other);409 add_last(other);
410}410}
411void Nullable_String::remove_first(std::size_t length)411void Nullable_String::remove_first(std::size_t n)
412{412{
413 if (m_null)413 if (m_null)
414 throw String_Null_Error("remove_first");414 throw String_Null_Error("remove_first");
415 else415 else
416 String::remove_first(length);416 String::remove_first(n);
417}417}
418void Nullable_String::add_last(const char* value)418void Nullable_String::add_last(const char* value)
419{419{
420 if (value)420 if (value)
421 add_last(value, strlen(value));421 add_last(value, strlen(value));
422}422}
423void Nullable_String::add_last(const char* value, std::size_t length)423void Nullable_String::add_last(const char* value, std::size_t len)
424{424{
425 if (value)425 if (value)
426 {426 {
427 if (is_null())427 if (is_null())
428 throw String_Null_Error("add_last");428 throw String_Null_Error("add_last");
429 else429 else
430 get_string().add_last(value, length);430 get_string().add_last(value, len);
431 }431 }
432}432}
433void Nullable_String::add_last(std::string const &value)433void Nullable_String::add_last(std::string const &value)
434434
=== modified file 'src/long_string.h'
--- src/long_string.h 2011-09-29 06:41:38 +0000
+++ src/long_string.h 2011-09-29 06:41:38 +0000
@@ -200,7 +200,7 @@
200 static void apply(Reader &action, Nullable_String &value)200 static void apply(Reader &action, Nullable_String &value)
201 {201 {
202 action.begin_compound(value);202 action.begin_compound(value);
203 action.member( (const char*)"m_null", value.m_null );203 action.member("m_null", value.m_null );
204 if (!value.is_null())204 if (!value.is_null())
205 {205 {
206 superclass(action, value.get_string());206 superclass(action, value.get_string());
207207
=== modified file 'src/mysql_client.cc'
--- src/mysql_client.cc 2011-07-11 07:34:56 +0000
+++ src/mysql_client.cc 2011-09-29 06:41:38 +0000
@@ -215,20 +215,20 @@
215 {215 {
216 if (::verbose_error())216 if (::verbose_error())
217 {217 {
218 Nullable_String &error= r.error;218 Nullable_String &err= r.error;
219 if (error.is_null())219 if (err.is_null())
220 {220 {
221 error.set("");221 err.set("");
222 }222 }
223 int old_length= (error.is_null() ? 0 : error.length());223 int old_length= (err.is_null() ? 0 : err.length());
224 int new_length= snprintf(error.data() + old_length224 int new_length= snprintf(err.data() + old_length
225 , error.max() - old_length225 , err.max() - old_length
226 , "%s(%d): %s"226 , "%s(%d): %s"
227 , (old_length == 0 ? "" : "\n")227 , (old_length == 0 ? "" : "\n")
228 , mysql_errno(handle())228 , mysql_errno(handle())
229 , mysql_error(handle()));229 , mysql_error(handle()));
230 assert(new_length > 0);230 assert(new_length > 0);
231 error.length(old_length + new_length);231 err.length(old_length + new_length);
232 }232 }
233 }233 }
234private:234private:
235235
=== modified file 'src/options.cc'
--- src/options.cc 2011-09-29 06:41:38 +0000
+++ src/options.cc 2011-09-29 06:41:38 +0000
@@ -31,12 +31,16 @@
31#include <sys/types.h>31#include <sys/types.h>
32#include <errno.h>32#include <errno.h>
3333
34std::size_t quiet_verbose_callback(char*, std::size_t, Query const &,
35 Query_Result const &);
34std::size_t status_verbose_callback(char* buffer, std::size_t length,36std::size_t status_verbose_callback(char* buffer, std::size_t length,
35 Query const &q, Query_Result const &r);37 Query const &q, Query_Result const &r);
36std::size_t full_verbose_callback(char* buffer, std::size_t length,38std::size_t full_verbose_callback(char* buffer, std::size_t length,
37 Query const &q, Query_Result const &r);39 Query const &q, Query_Result const &r);
38std::size_t custom_verbose_callback(char* buffer, std::size_t length,40std::size_t custom_verbose_callback(char* buffer, std::size_t length,
39 Query const &q, Query_Result const &r);41 Query const &q, Query_Result const &r);
42std::size_t error_verbose_callback(char* buffer, std::size_t length,
43 Query const &q, Query_Result const &r);
4044
41static const char* query_type_str(Query const &a_query)45static const char* query_type_str(Query const &a_query)
42{46{
@@ -288,18 +292,18 @@
288 }292 }
289 else293 else
290 {294 {
291 Verbose_Callback_Fill *fill= 0;295 Verbose_Callback_Fill *cb_fill= 0;
292 if (!custom_verbose_callback_vector.empty())296 if (!custom_verbose_callback_vector.empty())
293 {297 {
294 fill= custom_verbose_callback_vector.back().get()->fill();298 cb_fill= custom_verbose_callback_vector.back().get()->fill();
295 }299 }
296 if (0 == fill)300 if (0 == cb_fill)
297 {301 {
298 custom_verbose_callback_vector.push_back(Verbose_Callback_Pointer(new Verbose_Callback_Fill()));302 custom_verbose_callback_vector.push_back(Verbose_Callback_Pointer(new Verbose_Callback_Fill()));
299 fill= custom_verbose_callback_vector.back().get()->fill();303 cb_fill= custom_verbose_callback_vector.back().get()->fill();
300 }304 }
301 assert(fill);305 assert(cb_fill);
302 fill->add(*mask);306 cb_fill->add(*mask);
303 }307 }
304 }308 }
305 }309 }
@@ -322,12 +326,13 @@
322 return message.str();326 return message.str();
323}327}
324Too_Long_Argument::Too_Long_Argument(std::string const &argument_name328Too_Long_Argument::Too_Long_Argument(std::string const &argument_name
325 , std::string const &limitation329 , std::string const &arg_limitation
326 , std::string const &received) :330 , std::string const &arg_received) :
327Error(generate_message_Too_Long_Argument(argument_name, limitation, received))331Error(generate_message_Too_Long_Argument(argument_name, arg_limitation,
332 arg_received))
328, m_name(argument_name)333, m_name(argument_name)
329 , m_limitation(limitation)334 , m_limitation(arg_limitation)
330 , m_received(received)335 , m_received(arg_received)
331{336{
332}337}
333std::string const& Too_Long_Argument::name() const338std::string const& Too_Long_Argument::name() const
334339
=== modified file 'src/query.cc'
--- src/query.cc 2011-09-29 06:41:38 +0000
+++ src/query.cc 2011-09-29 06:41:38 +0000
@@ -153,68 +153,7 @@
153 */153 */
154typedef int Query_Parse_State;154typedef int Query_Parse_State;
155155
156const char * to_c_str(Enum_Query_Parse parse)156static Query_Parse_State query_parse_state(Enum_Query_Detect detect, Enum_Query_Type type, Enum_Query_Parse parse)
157{
158#define CONVERT(s) case(s): return #s ;
159 switch(parse)
160 {
161 CONVERT(ZERO);
162 CONVERT(ZERO_BACK);
163 CONVERT(SLASH);
164 CONVERT(C_COMMENT);
165 CONVERT(C_COMMENT_BACK);
166 CONVERT(C_COMMENT_STAR);
167 CONVERT(MINUS);
168 CONVERT(MINUS_COMMENT);
169 CONVERT(MINUS_COMMENT_BACK);
170 CONVERT(SHARP_COMMENT);
171 CONVERT(SHARP_COMMENT_BACK);
172 CONVERT(U);
173 CONVERT(US);
174 CONVERT(USE);
175 CONVERT(UP);
176 CONVERT(UPD);
177 CONVERT(UPDA);
178 CONVERT(UPDAT);
179 CONVERT(UPDATE);
180 CONVERT(D);
181 CONVERT(DE);
182 CONVERT(DEL);
183 CONVERT(DELE);
184 CONVERT(DELET);
185 CONVERT(DELETE);
186 CONVERT(I);
187 CONVERT(IN);
188 CONVERT(INS);
189 CONVERT(INSE);
190 CONVERT(INSER);
191 CONVERT(INSERT);
192 CONVERT(S);
193 CONVERT(SE);
194 CONVERT(SET);
195 CONVERT(SEL);
196 CONVERT(SELE);
197 CONVERT(SELEC);
198 CONVERT(SELECT);
199 CONVERT(SH);
200 CONVERT(SHO);
201 CONVERT(SHOW);
202 CONVERT(SINGLE_QUOTE);
203 CONVERT(SINGLE_QUOTE_BACK);
204 CONVERT(DOUBLE_QUOTE);
205 CONVERT(DOUBLE_QUOTE_BACK);
206 CONVERT(FINAL);
207 default:
208 return "Enum_Query_Parse: unknown value";
209 };
210#undef CONVERT
211}
212std::ostream& operator<<(std::ostream &s, Enum_Query_Parse parse)
213{
214 return s << to_c_str(parse);
215}
216
217Query_Parse_State query_parse_state(Enum_Query_Detect detect, Enum_Query_Type type, Enum_Query_Parse parse)
218{157{
219 return static_cast<Query_Parse_State>(detect) + (static_cast<Query_Parse_State>(type) << 8) + (static_cast<Query_Parse_State>(parse) << 16);158 return static_cast<Query_Parse_State>(detect) + (static_cast<Query_Parse_State>(type) << 8) + (static_cast<Query_Parse_State>(parse) << 16);
220}159}
@@ -223,7 +162,7 @@
223{162{
224 return query_parse_state(detect, eQuery_Type_Unknown, ZERO);163 return query_parse_state(detect, eQuery_Type_Unknown, ZERO);
225}164}
226Enum_Query_Detect query_detect(Query_Parse_State state)165static Enum_Query_Detect query_detect(Query_Parse_State state)
227{166{
228 return static_cast<Enum_Query_Detect>(state & 0xFF);167 return static_cast<Enum_Query_Detect>(state & 0xFF);
229}168}
@@ -231,14 +170,14 @@
231{170{
232 return static_cast<Enum_Query_Type>((state >> 8) & 0xFF);171 return static_cast<Enum_Query_Type>((state >> 8) & 0xFF);
233}172}
234Enum_Query_Parse query_parse(Query_Parse_State state)173static Enum_Query_Parse query_parse(Query_Parse_State state)
235{174{
236 return static_cast<Enum_Query_Parse>((state >> 16) & 0xFF);175 return static_cast<Enum_Query_Parse>((state >> 16) & 0xFF);
237}176}
238std::size_t query_parse_stupid(Query_Parse_State &state, const char* data, std::size_t length)177static std::size_t query_parse_stupid(Query_Parse_State &state, const char* data, std::size_t length)
239{178{
240 assert(eQuery_Detect_Stupid == query_detect(state));179 assert(eQuery_Detect_Stupid == query_detect(state));
241 const char* result= (const char*)memchr(data, ';', length);180 const char* result= static_cast<const char*>(memchr(data, ';', length));
242 if (result == NULL)181 if (result == NULL)
243 return length;182 return length;
244 else183 else
245184
=== modified file 'src/queue.h'
--- src/queue.h 2011-09-29 06:41:38 +0000
+++ src/queue.h 2011-09-29 06:41:38 +0000
@@ -413,7 +413,7 @@
413 std::cout << s.str() << std::flush;*/413 std::cout << s.str() << std::flush;*/
414 m_queue.clear();414 m_queue.clear();
415 }415 }
416 bool can_push(T* a_item)416 bool can_push(T*)
417 {417 {
418 /*std::ostringstream s;418 /*std::ostringstream s;
419 s << *this << " : " << this << " CAN_PUSH: QUEUE SIZE IS ";419 s << *this << " : " << this << " CAN_PUSH: QUEUE SIZE IS ";
420420
=== modified file 'src/slow_query_log_parser.h'
--- src/slow_query_log_parser.h 2011-07-11 14:41:36 +0000
+++ src/slow_query_log_parser.h 2011-09-29 06:41:38 +0000
@@ -51,9 +51,9 @@
51 {51 {
52 m_scheduler->start();52 m_scheduler->start();
53 }53 }
54 bool run(Query const &query)54 bool run(Query const &q)
55 {55 {
56 return m_scheduler->run(query);56 return m_scheduler->run(q);
57 }57 }
58 void flush()58 void flush()
59 {59 {
6060
=== modified file 'src/supervisor.cc'
--- src/supervisor.cc 2011-07-11 07:34:56 +0000
+++ src/supervisor.cc 2011-09-29 06:41:38 +0000
@@ -22,11 +22,6 @@
22#include "options.h"22#include "options.h"
23#include "worker.h"23#include "worker.h"
2424
25void connection_trace(void */* a_context */, Error const &a_error)
26{
27 std::cerr << a_error << std::endl;
28}
29
30static void *s_context= 0;25static void *s_context= 0;
31static troubles s_troubles= 0;26static troubles s_troubles= 0;
32void set_troubles(void *a_context, troubles a_function)27void set_troubles(void *a_context, troubles a_function)
@@ -106,9 +101,9 @@
106 }101 }
107 void complete(Worker *a_worker)102 void complete(Worker *a_worker)
108 {103 {
109 bool complete= (0 == --m_active) && (m_flush || m_stop);104 bool is_complete= (0 == --m_active) && (m_flush || m_stop);
110 m_join.push(a_worker);105 m_join.push(a_worker);
111 if (complete)106 if (is_complete)
112 {107 {
113 m_join.flush();108 m_join.flush();
114 }109 }

Subscribers

People subscribed via source and target branches