Skip to content

Commit

Permalink
fix clang-tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
empiredan committed Nov 8, 2024
1 parent c4ba8fc commit 33db8c6
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 35 deletions.
1 change: 1 addition & 0 deletions src/common/duplication_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,6 @@ struct duplication_constants

USER_DEFINED_ENUM_FORMATTER(duplication_fail_mode::type)
USER_DEFINED_ENUM_FORMATTER(duplication_status::type)

} // namespace replication
} // namespace dsn
16 changes: 6 additions & 10 deletions src/meta/duplication/meta_duplication_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,11 +468,9 @@ void meta_duplication_service::create_follower_app_for_duplication(
dup,
app,
duplication_constants::kDuplicationEnvMasterCreateFollowerAppStatusCreating,
std::bind(&meta_duplication_service::on_follower_app_creating_for_duplication,
this,
dup,
std::placeholders::_1,
std::placeholders::_2));
[this, dup](error_code err, configuration_create_app_response &&resp) {
on_follower_app_creating_for_duplication(dup, err, std::move(resp));
});
}

void meta_duplication_service::mark_follower_app_created_for_duplication(
Expand All @@ -482,11 +480,9 @@ void meta_duplication_service::mark_follower_app_created_for_duplication(
dup,
app,
duplication_constants::kDuplicationEnvMasterCreateFollowerAppStatusCreated,
std::bind(&meta_duplication_service::on_follower_app_created_for_duplication,
this,
dup,
std::placeholders::_1,
std::placeholders::_2));
[this, dup](error_code err, configuration_create_app_response &&resp) {
on_follower_app_created_for_duplication(dup, err, std::move(resp));
});
}

void meta_duplication_service::do_create_follower_app_for_duplication(
Expand Down
6 changes: 3 additions & 3 deletions src/rpc/rpc_stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,16 @@ class rpc_write_stream : public binary_writer
}
}

virtual ~rpc_write_stream() { flush(); }
~rpc_write_stream() override { flush(); }

virtual void flush() override
void flush() override
{
binary_writer::flush();
commit_buffer();
}

private:
virtual void create_new_buffer(size_t size, /*out*/ blob &bb) override
void create_new_buffer(size_t size, /*out*/ blob &bb) override
{
commit_buffer();

Expand Down
36 changes: 18 additions & 18 deletions src/utils/binary_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,33 +32,32 @@
#include "utils/blob.h"

namespace dsn {
int binary_writer::_reserved_size_per_buffer_static = 256;

binary_writer::binary_writer(int reserveBufferSize)
const int binary_writer::kReservedSizePerBuffer = 256;

binary_writer::binary_writer() : binary_writer(0) {}

binary_writer::binary_writer(int reserved_buffer_size)
: _current_buffer(nullptr),
_current_offset(0),
_current_buffer_length(0),
_total_size(0),
_reserved_size_per_buffer((reserved_buffer_size == 0) ? kReservedSizePerBuffer
: reserved_buffer_size)
{
_total_size = 0;
_buffers.reserve(1);
_reserved_size_per_buffer = (reserveBufferSize == 0) ? _reserved_size_per_buffer_static
: reserveBufferSize;
_current_buffer = nullptr;
_current_offset = 0;
_current_buffer_length = 0;
}

binary_writer::binary_writer(blob &buffer)
: _buffers({buffer}),
_current_buffer(const_cast<char *>(buffer.data())),
_current_offset(0),
_current_buffer_length(buffer.length()),
_total_size(0),
_reserved_size_per_buffer(kReservedSizePerBuffer)
{
_total_size = 0;
_buffers.reserve(1);
_reserved_size_per_buffer = _reserved_size_per_buffer_static;

_buffers.push_back(buffer);
_current_buffer = (char *)buffer.data();
_current_offset = 0;
_current_buffer_length = buffer.length();
}

binary_writer::~binary_writer() {}

void binary_writer::flush() { commit(); }

void binary_writer::create_buffer(size_t size)
Expand Down Expand Up @@ -200,4 +199,5 @@ bool binary_writer::backup(int count)
_total_size -= count;
return true;
}

} // namespace dsn
7 changes: 4 additions & 3 deletions src/utils/binary_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ namespace dsn {
class binary_writer
{
public:
binary_writer(int reserved_buffer_size = 0);
binary_writer();
binary_writer(int reserved_buffer_size);
binary_writer(blob &buffer);
virtual ~binary_writer();
virtual ~binary_writer() = default;

virtual void flush();

Expand Down Expand Up @@ -95,7 +96,7 @@ class binary_writer

int _total_size;
int _reserved_size_per_buffer;
static int _reserved_size_per_buffer_static;
static const int kReservedSizePerBuffer;
};

//--------------- inline implementation -------------------
Expand Down
2 changes: 1 addition & 1 deletion src/utils/fmt_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@
}

#define USER_DEFINED_ENUM_FORMATTER(type) \
inline auto format_as(type e)->int { return e; }
inline int format_as(type e) { return e; }

0 comments on commit 33db8c6

Please sign in to comment.