From 1a09bec1c62a5068126735cc0915020bf487f4b1 Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Sat, 14 Jul 2012 23:35:11 -0700 Subject: [PATCH] Merge of cppccheck fixes. --- bootstrap.sh | 2 +- libtest/cmdline.cc | 2 +- libtest/core.cc | 7 +++++-- libtest/failed.cc | 4 ++-- libtest/fatal.cc | 2 +- libtest/is_local.cc | 11 +++++++++++ libtest/is_local.hpp | 6 ++++++ libtest/m4/mysql.m4 | 3 +++ libtest/main.cc | 10 ++++++++++ libtest/server_container.cc | 16 ++++++++-------- libtest/unittest.cc | 1 - 11 files changed, 48 insertions(+), 16 deletions(-) diff --git a/bootstrap.sh b/bootstrap.sh index 9818b5b4..240f6ac0 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -4,5 +4,5 @@ if test -f configure; then make clean; make merge-clean; make distclean; fi; rm -r -f autom4te.cache ./config/autorun.sh -./configure --disable-assert=no +./configure --enable-assert make diff --git a/libtest/cmdline.cc b/libtest/cmdline.cc index 1233f514..94d4cce4 100644 --- a/libtest/cmdline.cc +++ b/libtest/cmdline.cc @@ -741,7 +741,7 @@ void Application::create_argv(const char *args[]) built_argv[x++]= strdup(_exectuble_with_path.c_str()); - for (Options::const_iterator iter= _options.begin(); iter != _options.end(); iter++) + for (Options::const_iterator iter= _options.begin(); iter != _options.end(); ++iter) { built_argv[x++]= strdup((*iter).first.c_str()); if ((*iter).second.empty() == false) diff --git a/libtest/core.cc b/libtest/core.cc index fba81c03..0ebe3efd 100644 --- a/libtest/core.cc +++ b/libtest/core.cc @@ -42,8 +42,11 @@ namespace libtest { void create_core(void) { -#ifdef TARGET_OS_OSX - return; +#if defined(TARGET_OS_OSX) && TARGET_OS_OSX + if (TARGET_OS_OSX) + { + return; + } #endif if (getenv("YATL_COREDUMP")) { diff --git a/libtest/failed.cc b/libtest/failed.cc index 314a2e99..ae79e307 100644 --- a/libtest/failed.cc +++ b/libtest/failed.cc @@ -46,7 +46,7 @@ namespace libtest { struct failed_st { - failed_st(const std::string collection_arg, const std::string test_arg) : + failed_st(const std::string& collection_arg, const std::string& test_arg) : collection(collection_arg), test(test_arg) { } @@ -70,7 +70,7 @@ public: void print_failed_test(void) { - for (Failures::iterator iter= failures.begin(); iter != failures.end(); iter++) + for (Failures::iterator iter= failures.begin(); iter != failures.end(); ++iter) { Error << "\t" << (*iter).collection << " " << (*iter).test; } diff --git a/libtest/fatal.cc b/libtest/fatal.cc index d4459662..c61b5cfb 100644 --- a/libtest/fatal.cc +++ b/libtest/fatal.cc @@ -54,7 +54,7 @@ fatal::fatal(const char *file_arg, int line_arg, const char *func_arg, const cha strncpy(_mesg, last_error, sizeof(_mesg)); - snprintf(_error_message, sizeof(_error_message), "%s", last_error); + snprintf(_error_message, sizeof(_error_message), "%.*s", last_error_length, last_error); } static bool _disabled= false; diff --git a/libtest/is_local.cc b/libtest/is_local.cc index b03c2325..7ae7b7f4 100644 --- a/libtest/is_local.cc +++ b/libtest/is_local.cc @@ -45,5 +45,16 @@ bool test_is_local() return (getenv("LIBTEST_LOCAL")); } +static bool _is_massive= false; +void is_massive(bool arg) +{ + _is_massive= arg; +} + +bool is_massive() +{ + return _is_massive; +} + } // namespace libtest diff --git a/libtest/is_local.hpp b/libtest/is_local.hpp index c06bc9dd..08355533 100644 --- a/libtest/is_local.hpp +++ b/libtest/is_local.hpp @@ -41,4 +41,10 @@ namespace libtest { LIBTEST_API bool test_is_local(); +LIBTEST_API +void is_massive(bool); + +LIBTEST_API +bool is_massive(); + } // namespace libtest diff --git a/libtest/m4/mysql.m4 b/libtest/m4/mysql.m4 index ed61b40d..2edd3b86 100644 --- a/libtest/m4/mysql.m4 +++ b/libtest/m4/mysql.m4 @@ -1,3 +1,6 @@ +m4_include([libtest/m4/ax_lib_mysql.m4]) +m4_include([libtest/m4/ax_prog_mysqld.m4]) + AX_LIB_MYSQL([5.0]) AM_CONDITIONAL(HAVE_LIBMYSQL, test "x${found_mysql}" = "xyes") AS_IF([test "x${found_mysql}" = "xyes"], diff --git a/libtest/main.cc b/libtest/main.cc index 79f177c3..453d2966 100644 --- a/libtest/main.cc +++ b/libtest/main.cc @@ -187,11 +187,21 @@ int main(int argc, char *argv[]) } } + if ((bool(getenv("YATL_RUN_MASSIVE_TESTS"))) or opt_massive) + { + opt_massive= true; + } + if (opt_quiet) { close(STDOUT_FILENO); } + if (opt_massive) + { + is_massive(opt_massive); + } + char buffer[1024]; if (getenv("LIBTEST_TMP")) { diff --git a/libtest/server_container.cc b/libtest/server_container.cc index d8ef5d49..0448e209 100644 --- a/libtest/server_container.cc +++ b/libtest/server_container.cc @@ -287,17 +287,16 @@ bool server_startup_st::start_server(const std::string& server_type, in_port_t t server->build(argc, argv); +#if 0 if (false) { Out << "Pausing for startup, hit return when ready."; std::string gdb_command= server->base_command(); - std::string options; -#if 0 - Out << "run " << server->args(options); -#endif getchar(); } - else if (server->start() == false) + else +#endif + if (server->start() == false) { delete server; return false; @@ -397,17 +396,18 @@ bool server_startup_st::start_socket_server(const std::string& server_type, cons server->build(argc, argv); +#if 0 if (false) { Out << "Pausing for startup, hit return when ready."; std::string gdb_command= server->base_command(); std::string options; -#if 0 Out << "run " << server->args(options); -#endif getchar(); } - else if (server->start() == false) + else +#endif + if (server->start() == false) { Error << "Failed to start " << *server; delete server; diff --git a/libtest/unittest.cc b/libtest/unittest.cc index b68669f5..3d85b77d 100644 --- a/libtest/unittest.cc +++ b/libtest/unittest.cc @@ -179,7 +179,6 @@ static test_return_t var_drizzle_exists_test(void *) static test_return_t var_tmp_test(void *) { FILE *file= fopen("var/tmp/junk", "w+"); - char buffer[1024]; test_true(file); fclose(file); return TEST_SUCCESS; -- 2.30.2