Skip to content

Commit 049e363

Browse files
authored
Comply with clang-tidy modernize-use-default-member-init (#266)
1 parent 3e1e8f1 commit 049e363

File tree

8 files changed

+12
-15
lines changed

8 files changed

+12
-15
lines changed

.clang-tidy

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ Checks: '
4242
-google-readability-avoid-underscore-in-googletest-name,
4343
-modernize-avoid-c-arrays,
4444
-modernize-use-nodiscard,
45-
-modernize-use-default-member-init,
4645
-modernize-use-trailing-return-type,
4746
-readability-convert-member-functions-to-static,
4847
-readability-identifier-length,

src/catalog/schema.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
namespace bustub {
2020

21-
Schema::Schema(const std::vector<Column> &columns) : tuple_is_inlined_(true) {
21+
Schema::Schema(const std::vector<Column> &columns) {
2222
uint32_t curr_offset = 0;
2323
for (uint32_t index = 0; index < columns.size(); index++) {
2424
Column column = columns[index];

src/include/catalog/schema.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ class Schema {
8989
std::vector<Column> columns_;
9090

9191
/** True if all the columns are inlined, false otherwise. */
92-
bool tuple_is_inlined_;
92+
bool tuple_is_inlined_{true};
9393

9494
/** Indices of all uninlined columns. */
9595
std::vector<uint32_t> uninlined_columns_;

src/include/concurrency/lock_manager.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ class LockManager {
3737

3838
class LockRequest {
3939
public:
40-
LockRequest(txn_id_t txn_id, LockMode lock_mode) : txn_id_(txn_id), lock_mode_(lock_mode), granted_(false) {}
40+
LockRequest(txn_id_t txn_id, LockMode lock_mode) : txn_id_(txn_id), lock_mode_(lock_mode) {}
4141

4242
txn_id_t txn_id_;
4343
LockMode lock_mode_;
44-
bool granted_;
44+
bool granted_{false};
4545
};
4646

4747
class LockRequestQueue {

src/include/concurrency/transaction.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,7 @@ class TransactionAbortException : public std::exception {
155155
class Transaction {
156156
public:
157157
explicit Transaction(txn_id_t txn_id, IsolationLevel isolation_level = IsolationLevel::REPEATABLE_READ)
158-
: state_(TransactionState::GROWING),
159-
isolation_level_(isolation_level),
158+
: isolation_level_(isolation_level),
160159
thread_id_(std::this_thread::get_id()),
161160
txn_id_(txn_id),
162161
prev_lsn_(INVALID_LSN),
@@ -256,7 +255,7 @@ class Transaction {
256255

257256
private:
258257
/** The current transaction state. */
259-
TransactionState state_;
258+
TransactionState state_{TransactionState::GROWING};
260259
/** The isolation level of the transaction. */
261260
IsolationLevel isolation_level_;
262261
/** The thread ID, used in single-threaded transactions. */

src/include/recovery/log_recovery.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class LogRecovery {
5050
/** Mapping the log sequence number to log file offset for undos. */
5151
std::unordered_map<lsn_t, int> lsn_mapping_;
5252

53-
int offset_ __attribute__((__unused__));
53+
int offset_ __attribute__((__unused__)); // NOLINT
5454
char *log_buffer_;
5555
};
5656

src/include/storage/disk/disk_manager.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,10 @@ class DiskManager {
9797
// stream to write db file
9898
std::fstream db_io_;
9999
std::string file_name_;
100-
int num_flushes_;
101-
int num_writes_;
102-
bool flush_log_;
103-
std::future<void> *flush_log_f_;
100+
int num_flushes_{0};
101+
int num_writes_{0};
102+
bool flush_log_{false};
103+
std::future<void> *flush_log_f_{nullptr};
104104
// With multiple buffer pool instances, need to protect file access
105105
std::mutex db_io_latch_;
106106
};

src/storage/disk/disk_manager.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ static char *buffer_used;
3030
* Constructor: open/create a single database file & log file
3131
* @input db_file: database file name
3232
*/
33-
DiskManager::DiskManager(const std::string &db_file)
34-
: file_name_(db_file), num_flushes_(0), num_writes_(0), flush_log_(false), flush_log_f_(nullptr) {
33+
DiskManager::DiskManager(const std::string &db_file) : file_name_(db_file) {
3534
std::string::size_type n = file_name_.rfind('.');
3635
if (n == std::string::npos) {
3736
LOG_DEBUG("wrong file format");

0 commit comments

Comments
 (0)