Skip to content

Commit bf56720

Browse files
committed
Fix additional assertion message issues found by automated scan
- Fix typo: "Determninistic" -> "Deterministic" in hive_operations.cpp - Rename inconsistent parameter "s" to "subject" in legacy_asset.hpp - Add missing ("subject", size()) to authority_verification_tracer.cpp - Add ("subject", id) to check_authority tracer asserts in sign_state.hpp
1 parent 30a067b commit bf56720

4 files changed

Lines changed: 21 additions & 21 deletions

File tree

libraries/protocol/authority_verification_tracer.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ bool authority_verification_tracer::detect_cycle(std::string account) const
2020

2121
authority_verification_trace::path_entry& authority_verification_tracer::get_root_entry()
2222
{
23-
HIVE_PROTOCOL_AUTHORITY_ASSERT( not _trace.root.empty() && "get_root_entry()", "trace root is empty" );
23+
HIVE_PROTOCOL_AUTHORITY_ASSERT( not _trace.root.empty() && "get_root_entry()", "trace root is empty", ("subject", _trace.root.size()) );
2424
return _trace.root.back();
2525
}
2626

2727
const authority_verification_trace::path_entry& authority_verification_tracer::get_root_entry() const
2828
{
29-
HIVE_PROTOCOL_AUTHORITY_ASSERT( not _trace.root.empty() && "get_root_entry() const", "trace root is empty" );
29+
HIVE_PROTOCOL_AUTHORITY_ASSERT( not _trace.root.empty() && "get_root_entry() const", "trace root is empty", ("subject", _trace.root.size()) );
3030
return _trace.root.back();
3131
}
3232

@@ -49,7 +49,7 @@ void authority_verification_tracer::push_parent_entry()
4949

5050
void authority_verification_tracer::pop_parent_entry()
5151
{
52-
HIVE_PROTOCOL_AUTHORITY_ASSERT(not _current_authority_path.empty(), "Pop parent entry on empty stack!");
52+
HIVE_PROTOCOL_AUTHORITY_ASSERT(not _current_authority_path.empty(), "Pop parent entry on empty stack!", ("subject", _current_authority_path.size()));
5353
_current_authority_path.pop_back();
5454
}
5555

@@ -248,7 +248,7 @@ void authority_verification_tracer::on_leaving_account_entry( unsigned int effec
248248

249249
void authority_verification_tracer::trim_final_authority_path()
250250
{
251-
HIVE_PROTOCOL_AUTHORITY_ASSERT(not _trace.final_authority_path.empty(), "trim on empty final authority path!");
251+
HIVE_PROTOCOL_AUTHORITY_ASSERT(not _trace.final_authority_path.empty(), "trim on empty final authority path!", ("subject", _trace.final_authority_path.size()));
252252
_trace.final_authority_path.pop_back();
253253
}
254254

libraries/protocol/hive_operations.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ namespace hive { namespace protocol {
468468
props.validate< true >();
469469
validate_account_name( worker_account );
470470
const auto winput = work_input();
471-
HIVE_PROTOCOL_STRING_ASSERT( winput == work.input, "Determninistic input does not match recorded input",
471+
HIVE_PROTOCOL_STRING_ASSERT( winput == work.input, "Deterministic input does not match recorded input",
472472
("subject", work.input)("expected", winput)("actual", work.input)
473473
);
474474
work.validate();

libraries/protocol/include/hive/protocol/legacy_asset.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ inline void pack( Stream& s, const hive::protocol::legacy_hive_asset_symbol_type
7272
return;
7373
}
7474

75-
HIVE_PROTOCOL_ASSET_ASSERT( sym.ser == OBSOLETE_SYMBOL_SER, "Cannot serialize legacy symbol ${s}", ("s", sym.ser) );
75+
HIVE_PROTOCOL_ASSET_ASSERT( sym.ser == OBSOLETE_SYMBOL_SER, "Cannot serialize legacy symbol ${subject}", ("subject", sym.ser) );
7676

7777
if( hive::protocol::serialization_mode_controller::get_current_pack() == hive::protocol::pack_type::legacy )
7878
pack( s, sym.ser );
@@ -107,7 +107,7 @@ inline void unpack( Stream& s, hive::protocol::legacy_hive_asset_symbol_type& sy
107107
ser == OBSOLETE_SYMBOL_LEGACY_SER_4 ||
108108
ser == OBSOLETE_SYMBOL_LEGACY_SER_5 ||
109109
ser == OBSOLETE_SYMBOL_SER,
110-
"Cannot deserialize legacy symbol ${s}", ("s", ser) );
110+
"Cannot deserialize legacy symbol ${subject}", ("subject", ser) );
111111

112112
if( ser != OBSOLETE_SYMBOL_SER )
113113
wlog( "unpack legacy serialization ${s}", ("s", ser) );

libraries/protocol/include/hive/protocol/sign_state.hpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class sign_state
6060
{
6161
authority initial_auth;
6262
if constexpr (IS_TRACED) {
63-
HIVE_PROTOCOL_AUTHORITY_ASSERT(tracer && "check_authority 1");
63+
FC_ASSERT(tracer && "check_authority 1", "check_authority: tracer is null", ("id", id));
6464
try
6565
{
6666
initial_auth = get_current_authority( id );
@@ -78,7 +78,7 @@ class sign_state
7878
if( approved_by.find(id) != approved_by.end() )
7979
{
8080
if constexpr (IS_TRACED) {
81-
HIVE_PROTOCOL_AUTHORITY_ASSERT(tracer && "check_authority 2");
81+
FC_ASSERT(tracer && "check_authority 2", "check_authority: tracer is null", ("id", id));
8282
tracer->on_approved_authority( id, initial_auth.weight_threshold );
8383
}
8484

@@ -93,7 +93,7 @@ class sign_state
9393
bool success = check_authority_impl( initial_auth, 0 );
9494

9595
if constexpr (IS_TRACED) {
96-
HIVE_PROTOCOL_AUTHORITY_ASSERT(tracer && "check_authority 3");
96+
FC_ASSERT(tracer && "check_authority 3", "check_authority: tracer is null", ("id", id));
9797
// TODO: Provide appropriate set of flags.
9898
tracer->on_root_authority_finish(success, 0);
9999
}
@@ -108,7 +108,7 @@ class sign_state
108108
bool check_authority( const authority& auth, const string& id, const string& role )
109109
{
110110
if constexpr (IS_TRACED) {
111-
HIVE_PROTOCOL_AUTHORITY_ASSERT(tracer && "check_authority 4");
111+
FC_ASSERT(tracer && "check_authority 4", "check_authority: tracer is null", ("id", id));
112112
tracer->set_role(role);
113113
tracer->on_root_authority_start(id, auth.weight_threshold, 0);
114114
}
@@ -119,7 +119,7 @@ class sign_state
119119
bool success = check_authority_impl( auth, 0 );
120120

121121
if constexpr (IS_TRACED) {
122-
HIVE_PROTOCOL_AUTHORITY_ASSERT(tracer && "check_authority 5");
122+
FC_ASSERT(tracer && "check_authority 5", "check_authority: tracer is null", ("id", id));
123123
// TODO: Provide appropriate set of flags.
124124
tracer->on_root_authority_finish(success, 0);
125125
}
@@ -171,7 +171,7 @@ class sign_state
171171
size_t membership = 0;
172172

173173
if constexpr (IS_TRACED) {
174-
HIVE_PROTOCOL_AUTHORITY_ASSERT(tracer && "check_authority 6");
174+
FC_ASSERT(tracer && "check_authority 6");
175175
if( auth.key_auths.empty() && auth.account_auths.empty() )
176176
tracer->on_empty_auth();
177177
}
@@ -191,7 +191,7 @@ class sign_state
191191
total_weight += k.second;
192192

193193
if constexpr (IS_TRACED) {
194-
HIVE_PROTOCOL_AUTHORITY_ASSERT(tracer && "check_authority 7");
194+
FC_ASSERT(tracer && "check_authority 7");
195195
tracer->on_matching_key(k.first, k.second, auth.weight_threshold, depth,
196196
total_weight >= auth.weight_threshold);
197197
}
@@ -205,7 +205,7 @@ class sign_state
205205
}
206206

207207
if constexpr (IS_TRACED) {
208-
HIVE_PROTOCOL_AUTHORITY_ASSERT(tracer && "check_authority 8");
208+
FC_ASSERT(tracer && "check_authority 8");
209209
tracer->on_missing_matching_key();
210210
}
211211

@@ -216,7 +216,7 @@ class sign_state
216216
if( depth == limits.recursion )
217217
{
218218
if constexpr (IS_TRACED) {
219-
HIVE_PROTOCOL_AUTHORITY_ASSERT(tracer && "check_authority 9");
219+
FC_ASSERT(tracer && "check_authority 9");
220220
tracer->on_recursion_depth_limit_exceeded();
221221
}
222222

@@ -226,7 +226,7 @@ class sign_state
226226
if( limits.account_auths > 0 && account_auth_count >= limits.account_auths )
227227
{
228228
if constexpr (IS_TRACED) {
229-
HIVE_PROTOCOL_AUTHORITY_ASSERT(tracer && "check_authority 10");
229+
FC_ASSERT(tracer && "check_authority 10");
230230
tracer->on_account_processing_limit_exceeded();
231231
}
232232

@@ -237,7 +237,7 @@ class sign_state
237237

238238
authority account_auth;
239239
if constexpr (IS_TRACED) {
240-
HIVE_PROTOCOL_AUTHORITY_ASSERT(tracer && "check_authority 11");
240+
FC_ASSERT(tracer && "check_authority 11");
241241
try
242242
{
243243
account_auth = get_current_authority( a.first );
@@ -260,21 +260,21 @@ class sign_state
260260
if( total_weight >= auth.weight_threshold )
261261
{
262262
if constexpr (IS_TRACED) {
263-
HIVE_PROTOCOL_AUTHORITY_ASSERT(tracer && "check_authority 12");
263+
FC_ASSERT(tracer && "check_authority 12");
264264
tracer->on_leaving_account_entry( a.second, true /*parent_threshold_reached*/ );
265265
}
266266
return true;
267267
}
268268
}
269269
if constexpr (IS_TRACED) {
270-
HIVE_PROTOCOL_AUTHORITY_ASSERT(tracer && "check_authority 13");
270+
FC_ASSERT(tracer && "check_authority 13");
271271
tracer->on_leaving_account_entry( success ? a.second : 0, false /*parent_threshold_reached*/ );
272272
}
273273
}
274274
else
275275
{
276276
if constexpr (IS_TRACED) {
277-
HIVE_PROTOCOL_AUTHORITY_ASSERT(tracer && "check_authority 14");
277+
FC_ASSERT(tracer && "check_authority 14");
278278
tracer->on_approved_authority( a.first, a.second );
279279
}
280280

0 commit comments

Comments
 (0)