Skip to content

Commit

Permalink
fix -Wmaybe-uninitialized for group and userspace EventGuards
Browse files Browse the repository at this point in the history
  • Loading branch information
Tessa Todorowski committed Oct 14, 2024
1 parent 7798068 commit 7b2bb17
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 21 deletions.
38 changes: 18 additions & 20 deletions src/perf/counter/group/reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,31 +97,29 @@ Reader<T>::Reader(ExecutionScope scope, bool enable_on_exec)
{
std::optional<EventGuard> counter = std::nullopt;
counter_ev.mut_attr().exclude_kernel = counter_collection_.leader.attr().exclude_kernel;
do

try
{
try
{
counter = counter_leader_.value().open_child(counter_ev, scope);
}
catch (const std::system_error& e)
counter.value() = counter_leader_.value().open_child(counter_ev, scope);
counters_.emplace_back(std::move(counter.value()));
}
catch (const std::system_error& e)
{
if (!counter.value().is_valid())
{
if (!counter.value().is_valid())
Log::error() << "failed to add counter '" << counter_ev.name()
<< "': " << e.code().message();

if (e.code().value() == EINVAL)
{
Log::error() << "failed to add counter '" << counter_ev.name()
<< "': " << e.code().message();

if (e.code().value() == EINVAL)
{
Log::error() << "opening " << counter_collection_.counters.size()
<< " counters at once might exceed the hardware limit of "
"simultaneously "
"openable counters.";
}
throw e;
Log::error() << "opening " << counter_collection_.counters.size()
<< " counters at once might exceed the hardware limit of "
"simultaneously "
"openable counters.";
}
counters_.emplace_back(std::move(counter.value()));
throw e;
}
} while (!counter.value().is_valid());
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/perf/counter/userspace/reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Reader<T>::Reader(ExecutionScope scope)

try
{
counter = event.open(scope);
counter.value() = event.open(scope);
counters_.emplace_back(std::move(counter.value()));
}
catch (const std::system_error& e)
Expand Down

0 comments on commit 7b2bb17

Please sign in to comment.