Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix clang-tidy warnings #95

Merged
merged 1 commit into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bridge/src/service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ bool service::shutdown(tateyama::framework::environment& env) {
return true;
}

static thread_local std::unique_ptr<Worker> worker_for_this_thread{};

bool service::operator()(std::shared_ptr<tateyama::api::server::request> req, std::shared_ptr<tateyama::api::server::response> res) { //NOLINT(readability-function-cognitive-complexity)
static thread_local std::unique_ptr<Worker> worker_for_this_thread{};

auto payload = req->payload();
std::istringstream ifs(std::string{payload});
boost::archive::binary_iarchive ia(ifs);
Expand Down
2 changes: 1 addition & 1 deletion examples/cli/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "stubImpl.h"
#include "transactionImpl.h"

DEFINE_string(dbname, ogawayama::common::param::SHARED_MEMORY_NAME, "database name"); // NOLINT
DEFINE_string(dbname, std::string(ogawayama::common::param::SHARED_MEMORY_NAME), "database name"); // NOLINT
DEFINE_string(statement, "", "SQL statement"); // NOLINT
DEFINE_string(query, "", "SQL query"); // NOLINT
DEFINE_int32(schema, -1, "object id for recieve_message()"); // NOLINT
Expand Down
6 changes: 4 additions & 2 deletions include/ogawayama/stub/api.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ class Connection : public manager::message::Receiver {
/**
* @brief destructs this object.
*/
~Connection();
virtual ~Connection();

Connection(const Connection&) = delete;
Connection& operator=(const Connection&) = delete;
Expand Down Expand Up @@ -419,7 +419,9 @@ class Stub {


namespace ogawayama::common::param {
static const std::string SHARED_MEMORY_NAME = "tsurugi";
using namespace std::string_view_literals;

static const std::string_view SHARED_MEMORY_NAME = "tsurugi"sv;
} // namespace ogawayama::common::param

using StubPtr = std::unique_ptr<ogawayama::stub::Stub>;
Expand Down
9 changes: 7 additions & 2 deletions src/ogawayama/stub/connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

#include <iostream>
#include <exception>

#include <boost/foreach.hpp>
#define BOOST_BIND_GLOBAL_PLACEHOLDERS // to retain the current behavior
Expand All @@ -37,7 +38,11 @@ Connection::Impl::Impl(Stub::Impl* manager, std::string_view session_id, std::si

Connection::Impl::~Impl()
{
transport_.close();
try {
transport_.close();
} catch (std::exception &ex) {
std::cerr << ex.what() << std::endl;
}
}

ErrorCode Connection::Impl::hello()
Expand Down Expand Up @@ -315,7 +320,7 @@ ErrorCode get_index_metadata(std::string_view name, std::size_t id, boost::prope
if (auto rv = get_indexes(name, indexes); rv != ERROR_CODE::OK) {
return rv;
}
if (indexes->get(id, index) != manager::metadata::ErrorCode::OK) {
if (indexes->get(static_cast<std::int64_t>(id), index) != manager::metadata::ErrorCode::OK) {
return ERROR_CODE::FILE_IO_ERROR; // indexes->get() failed
}
return ERROR_CODE::OK;
Expand Down
9 changes: 8 additions & 1 deletion src/ogawayama/stub/result_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
* limitations under the License.
*/

#include <iostream>
#include <exception>

#include "result_setImpl.h"

namespace ogawayama::stub {
Expand All @@ -28,7 +31,11 @@ ResultSet::Impl::Impl(Transaction::Impl* manager, std::unique_ptr<tateyama::comm
}

ResultSet::Impl::~Impl() {
manager_->receive_body(query_index_);
try {
manager_->receive_body(query_index_);
} catch (std::exception &ex) {
std::cerr << ex.what() << std::endl;
}
}

/**
Expand Down
12 changes: 9 additions & 3 deletions src/ogawayama/stub/transaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

#include <iostream>
#include <exception>
#include <array>
#include <cstdint>

Expand All @@ -30,9 +32,13 @@ Transaction::Impl::Impl(Connection::Impl* manager, tateyama::bootstrap::wire::tr

Transaction::Impl::~Impl()
{
if (alive_) {
rollback();
alive_ = false;
try {
if (alive_) {
rollback();
alive_ = false;
}
} catch (std::exception &ex) {
std::cerr << ex.what() << std::endl;
}
}

Expand Down
9 changes: 8 additions & 1 deletion src/tateyama/transport/client_wire.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
*/
#pragma once

#include <iostream>
#include <exception>

#include "wire.h"

namespace tateyama::common::wire {
Expand All @@ -30,7 +33,11 @@ class session_wire_container
: envelope_(envelope), managed_shm_ptr_(envelope_->managed_shared_memory_.get()) {
}
~resultset_wires_container() {
set_closed();
try {
set_closed();
} catch (std::exception &ex) {
std::cerr << ex.what() << std::endl;
}
}

resultset_wires_container(const resultset_wires_container&) = delete;
Expand Down