Skip to content

Commit 3ca9690

Browse files
committed
Fix warnings about missing assignment definitions in clang 10.0.0
The warnings caught legitimate code smells. Performance of store_key_t should improve.
1 parent 9a7ebbf commit 3ca9690

File tree

8 files changed

+21
-16
lines changed

8 files changed

+21
-16
lines changed

src/btree/keys.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ struct store_key_t {
6666
assign(_key.size(), _key.contents());
6767
}
6868

69+
store_key_t &operator=(const store_key_t &_key) {
70+
assign(_key.size(), _key.contents());
71+
return *this;
72+
}
73+
6974
explicit store_key_t(const btree_key_t *key) {
7075
assign(key->size, key->contents);
7176
}

src/clustering/table_contract/coordinator/calculate_contracts.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ void calculate_all_contracts(
549549
/* We want to break the key-space into sub-regions small enough that the contract,
550550
table config, and ack versions are all constant across the sub-region. First we
551551
iterate over all contracts: */
552-
for (const std::pair<contract_id_t, std::pair<region_t, contract_t> > &cpair :
552+
for (const std::pair<const contract_id_t, std::pair<region_t, contract_t> > &cpair :
553553
old_state.contracts) {
554554
/* Next iterate over all shards of the table config and find the ones that
555555
overlap the contract in question: */

src/rapidjson/document.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,10 +326,10 @@ struct GenericStringRef {
326326

327327
private:
328328
//! Disallow copy-assignment
329-
GenericStringRef operator=(const GenericStringRef&);
329+
GenericStringRef &operator=(const GenericStringRef&) = delete;
330330
//! Disallow construction from non-const array
331331
template<SizeType N>
332-
GenericStringRef(CharType (&str)[N]) /* = delete */;
332+
GenericStringRef(CharType (&str)[N]) = delete;
333333
};
334334

335335
//! Mark a character pointer as constant string

src/rapidjson/internal/biginteger.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ class BigInteger {
3838
std::memcpy(digits_, rhs.digits_, count_ * sizeof(Type));
3939
}
4040

41+
BigInteger &operator=(const BigInteger& rhs) {
42+
count_ = rhs.count_;
43+
std::memcpy(digits_, rhs.digits_, count_ * sizeof(Type));
44+
return *this;
45+
}
46+
4147
explicit BigInteger(uint64_t u) : count_(1) {
4248
digits_[0] = u;
4349
}

src/rdb_protocol/geo/s2/base/docid.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,8 @@ class DocId {
112112
explicit DocId(value_type _docid) { docid_ = _docid; }
113113
value_type docid() const { return docid_; } // ONLY use here
114114
value_type* docidptr() { return &docid_; } // ie in this file
115-
DocId& operator=(const DocId& x) {
116-
docid_ = x.docid_;
117-
return *this;
118-
}
115+
DocId& operator=(const DocId&) = default;
116+
DocId(const DocId&) = default;
119117
// These two are required for delta encoding
120118
value_type operator+(const DocId& x) const { return docid_ + x.docid_; }
121119
value_type operator-(const DocId& x) const { return docid_ - x.docid_; }
@@ -218,10 +216,8 @@ class DocId32Bit {
218216
}
219217
value_type docid() const { return docid_; } // ONLY use here
220218
value_type* docidptr() { return &docid_; } // ie in this file
221-
DocId32Bit& operator=(const DocId32Bit& x) {
222-
docid_ = x.docid_;
223-
return *this;
224-
}
219+
DocId32Bit(const DocId32Bit&) = default;
220+
DocId32Bit& operator=(const DocId32Bit&) = default;
225221
// These two are required for delta encoding
226222
value_type operator+(const DocId32Bit& x) const { return docid_ + x.docid_; }
227223
value_type operator-(const DocId32Bit& x) const { return docid_ - x.docid_; }

src/rdb_protocol/serialize_datum.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ void serialize_offset_table(write_message_t *wm,
116116
datum_t::type_t datum_type,
117117
const std::vector<size_tree_node_t> &elem_sizes,
118118
datum_offset_size_t offset_size) {
119-
rassert(datum_type == datum_t::R_OBJECT || datum_t::R_ARRAY);
119+
rassert(datum_type == datum_t::R_OBJECT || datum_type == datum_t::R_ARRAY);
120120
const size_t num_elements =
121121
datum_type == datum_t::R_OBJECT
122122
? elem_sizes.size() / 2

src/rpc/mailbox/raw_mailbox.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
raw_mailbox_t::address_t::address_t() :
99
peer(peer_id_t()), thread(-1), mailbox_id(0) { }
1010

11-
raw_mailbox_t::address_t::address_t(const address_t &a) :
12-
peer(a.peer), thread(a.thread), mailbox_id(a.mailbox_id) { }
13-
1411
bool raw_mailbox_t::address_t::is_nil() const {
1512
return peer.is_nil();
1613
}

src/rpc/mailbox/raw_mailbox.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,8 @@ class raw_mailbox_t : public home_thread_mixin_t {
5151
/* Constructs a nil address */
5252
address_t();
5353

54-
address_t(const address_t&);
54+
address_t(const address_t&) = default;
55+
address_t &operator=(const address_t&) = default;
5556

5657
/* Tests if the address is nil */
5758
bool is_nil() const;

0 commit comments

Comments
 (0)