Skip to content

Commit 3e8aa68

Browse files
authored
Fix possibly dangling reference to a temporary warning (#476)
1 parent 1bd6901 commit 3e8aa68

6 files changed

Lines changed: 18 additions & 18 deletions

File tree

Development/nmos-cpp-node/node_implementation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1293,7 +1293,7 @@ void node_implementation_init(nmos::node_model& model, nmos::experimental::contr
12931293

12941294
utility::ostringstream_t role;
12951295
role << U("receiver-monitor-") << ++count;
1296-
const auto& receiver = nmos::find_resource(model.node_resources, receiver_id);
1296+
const auto receiver = nmos::find_resource(model.node_resources, receiver_id);
12971297
auto receiver_monitor = nmos::make_receiver_monitor(++oid, true, receivers_block_oid, role.str(), nmos::fields::label(receiver->data), nmos::fields::description(receiver->data), value_of({ { nmos::nc::details::make_touchpoint_nmos({nmos::ncp_touchpoint_resource_types::receiver, receiver_id}) } }));
12981298
// optionally indicate dependencies within the device model
12991299
nmos::set_object_dependency_paths(receiver_monitor, {{U("root"), U("receivers")}});
@@ -1314,7 +1314,7 @@ void node_implementation_init(nmos::node_model& model, nmos::experimental::contr
13141314

13151315
utility::ostringstream_t role;
13161316
role << U("sender-monitor-") << ++count;
1317-
const auto& sender = nmos::find_resource(model.node_resources, sender_id);
1317+
const auto sender = nmos::find_resource(model.node_resources, sender_id);
13181318
const auto sender_monitor = nmos::make_sender_monitor(++oid, true, nmos::root_block_oid, role.str(), nmos::fields::label(sender->data), nmos::fields::description(sender->data), value_of({ { nmos::nc::details::make_touchpoint_nmos({nmos::ncp_touchpoint_resource_types::sender, sender_id}) } }));
13191319

13201320
// add sender-monitor to root-block

Development/nmos/configuration_api.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ namespace nmos
7474
{
7575
// get resource based on the oid
7676
const auto& oid = nmos::fields::nc::oid(member);
77-
const auto& found = nmos::find_resource(resources, utility::s2us(std::to_string(oid)));
77+
const auto found = nmos::find_resource(resources, utility::s2us(std::to_string(oid)));
7878
if (resources.end() != found)
7979
{
8080
build_role_paths(resources, *found, role_path, role_paths);

Development/nmos/configuration_methods.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ namespace nmos
6868

6969
for (const auto& member : members)
7070
{
71-
const auto& found = find_resource(resources, utility::s2us(std::to_string(nmos::fields::nc::oid(member))));
71+
const auto found = find_resource(resources, utility::s2us(std::to_string(nmos::fields::nc::oid(member))));
7272

7373
if (resources.end() != found)
7474
{

Development/nmos/configuration_utils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ namespace nmos
326326
{
327327
// If constant oid then check oid from property holder and verify with oid from block member
328328
// Is this oid already in use?
329-
const auto& child = find_resource(resources, utility::s2us(std::to_string(oid)));
329+
const auto child = find_resource(resources, utility::s2us(std::to_string(oid)));
330330

331331
if (resources.end() != child)
332332
{
@@ -577,7 +577,7 @@ namespace nmos
577577

578578
while (utility::s2us(std::to_string(nmos::root_block_oid)) != oid.as_string())
579579
{
580-
const auto& found = nmos::find_resource(resources, utility::s2us(std::to_string(nmos::fields::nc::owner(found_resource.data))));
580+
const auto found = nmos::find_resource(resources, utility::s2us(std::to_string(nmos::fields::nc::owner(found_resource.data))));
581581
if (resources.end() == found)
582582
{
583583
break;

Development/nmos/control_protocol_utils.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ namespace nmos
366366
{
367367
// get resource based on the oid
368368
const auto& oid = nmos::fields::nc::oid(*member_found);
369-
const auto& found = nmos::find_resource(resources, utility::s2us(std::to_string(oid)));
369+
const auto found = nmos::find_resource(resources, utility::s2us(std::to_string(oid)));
370370
if (resources.end() != found)
371371
{
372372
return get_nc_block_member_descriptor(resources, *found, role_path_segments);
@@ -411,7 +411,7 @@ namespace nmos
411411
auto transition_counter = get_property(resources, oid, status_transition_counter_property_id, get_control_protocol_class_descriptor, gate).as_integer();
412412
set_property_and_notify(resources, oid, status_transition_counter_property_id, ++transition_counter, get_control_protocol_class_descriptor, gate);
413413
}
414-
const auto& found = find_resource(resources, utility::s2us(std::to_string(oid)));
414+
const auto found = find_resource(resources, utility::s2us(std::to_string(oid)));
415415
if (resources.end() != found)
416416
{
417417
if (nmos::nc::is_sender_monitor(parse_class_id(nmos::fields::nc::class_id(found->data))))
@@ -721,7 +721,7 @@ namespace nmos
721721
{
722722
// get resource based on the oid
723723
const auto& oid = nmos::fields::nc::oid(member);
724-
const auto& found = find_resource(resources, utility::s2us(std::to_string(oid)));
724+
const auto found = find_resource(resources, utility::s2us(std::to_string(oid)));
725725
if (resources.end() != found)
726726
{
727727
nc::get_member_descriptors(resources, *found, recurse, descriptors);
@@ -775,7 +775,7 @@ namespace nmos
775775
{
776776
// get resource based on the oid
777777
const auto& oid = nmos::fields::nc::oid(member);
778-
const auto& found = find_resource(resources, utility::s2us(std::to_string(oid)));
778+
const auto found = find_resource(resources, utility::s2us(std::to_string(oid)));
779779
if (resources.end() != found)
780780
{
781781
nc::find_members_by_role(resources, *found, role, match_whole_string, case_sensitive, recurse, descriptors);
@@ -823,7 +823,7 @@ namespace nmos
823823
{
824824
// get resource based on the oid
825825
const auto& oid = nmos::fields::nc::oid(member);
826-
const auto& found = find_resource(resources, utility::s2us(std::to_string(oid)));
826+
const auto found = find_resource(resources, utility::s2us(std::to_string(oid)));
827827
if (resources.end() != found)
828828
{
829829
nc::find_members_by_class_id(resources, *found, class_id_, include_derived, recurse, descriptors);
@@ -1025,7 +1025,7 @@ namespace nmos
10251025
if (!block_member_descriptor.is_null())
10261026
{
10271027
const auto& oid = nmos::fields::nc::oid(block_member_descriptor);
1028-
const auto& found = nmos::find_resource(resources, utility::s2us(std::to_string(oid)));
1028+
const auto found = nmos::find_resource(resources, utility::s2us(std::to_string(oid)));
10291029
if (resources.end() != found)
10301030
{
10311031
return found;
@@ -1113,7 +1113,7 @@ namespace nmos
11131113
web::json::value get_property(const resources& resources, nc_oid oid, const nc_property_id& property_id, get_control_protocol_class_descriptor_handler get_control_protocol_class_descriptor, slog::base_gate& gate)
11141114
{
11151115
// get resource based on the oid
1116-
const auto& found = find_resource(resources, utility::s2us(std::to_string(oid)));
1116+
const auto found = find_resource(resources, utility::s2us(std::to_string(oid)));
11171117
if (resources.end() != found)
11181118
{
11191119
// find the relevant nc_property_descriptor
@@ -1130,7 +1130,7 @@ namespace nmos
11301130

11311131
bool set_property_and_notify(resources& resources, nc_oid oid, const nc_property_id& property_id, const web::json::value& value, get_control_protocol_class_descriptor_handler get_control_protocol_class_descriptor, slog::base_gate& gate)
11321132
{
1133-
const auto& found = find_resource(resources, utility::s2us(std::to_string(oid)));
1133+
const auto found = find_resource(resources, utility::s2us(std::to_string(oid)));
11341134
if (resources.end() != found)
11351135
{
11361136
const auto& property = nc::find_property_descriptor(property_id, nc::details::parse_class_id(nmos::fields::nc::class_id(found->data)), get_control_protocol_class_descriptor);
@@ -1184,7 +1184,7 @@ namespace nmos
11841184
web::json::value get_property(const resources& resources, nc_oid oid, const utility::string_t& property_name, slog::base_gate& gate)
11851185
{
11861186
// get resource based on the oid
1187-
const auto& found = find_resource(resources, utility::s2us(std::to_string(oid)));
1187+
const auto found = find_resource(resources, utility::s2us(std::to_string(oid)));
11881188
if (resources.end() != found)
11891189
{
11901190
// find the relevant nc_property_descriptor
@@ -1323,7 +1323,7 @@ namespace nmos
13231323
// domain specific statuses offering an Inactive option MUST transition immediately to the Healthy state.
13241324
// Furthermore, after activation, as long as the monitor isn't being deactivated, it MUST delay the reporting
13251325
// of non Healthy states for the duration specified by statusReportingDelay, and then transition to any other appropriate state.
1326-
const auto& found = find_resource(resources, utility::s2us(std::to_string(oid)));
1326+
const auto found = find_resource(resources, utility::s2us(std::to_string(oid)));
13271327
if (resources.end() != found && nc::is_status_monitor(nc::details::parse_class_id(nmos::fields::nc::class_id(found->data))))
13281328
{
13291329
const auto& class_id = nc::details::parse_class_id(nmos::fields::nc::class_id(found->data));
@@ -1382,7 +1382,7 @@ namespace nmos
13821382

13831383
bool deactivate_monitor(resources& resources, nc_oid oid, get_control_protocol_class_descriptor_handler get_control_protocol_class_descriptor, slog::base_gate& gate)
13841384
{
1385-
const auto& found = find_resource(resources, utility::s2us(std::to_string(oid)));
1385+
const auto found = find_resource(resources, utility::s2us(std::to_string(oid)));
13861386
if (resources.end() != found && nc::is_status_monitor(nc::details::parse_class_id(nmos::fields::nc::class_id(found->data))))
13871387
{
13881388
const auto& class_id = nc::details::parse_class_id(nmos::fields::nc::class_id(found->data));

Development/nmos/test/configuration_utils_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ BST_TEST_CASE(testApplyBackupDataSet)
407407
};
408408

409409
// Capture initial state of device model so we can reset after each check
410-
const auto& root_resource = nmos::nc::find_resource_by_role_path(resources, value_of({ U("root") }).as_array());
410+
const auto root_resource = nmos::nc::find_resource_by_role_path(resources, value_of({ U("root") }).as_array());
411411
auto initial_backup_dataset = nmos::get_properties_by_path(resources, *root_resource, true, false, get_control_protocol_class_descriptor, get_control_protocol_datatype_descriptor, nullptr);
412412
auto& initial_object_properties_holders = nmos::fields::nc::values(nmos::fields::nc::value(initial_backup_dataset));
413413

0 commit comments

Comments
 (0)