Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix PFM build/fix warning about uninitialized use #356

Merged
merged 1 commit into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions include/lo2s/perf/event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,14 @@ class EventGuard

~EventGuard()
{
close(fd_);
if (fd_ != -1)
{
close(fd_);
}
}

protected:
int fd_;
int fd_ = -1;
};

} // namespace perf
Expand Down
14 changes: 6 additions & 8 deletions include/lo2s/perf/pfm.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@

#pragma once

#include "event_provider.hpp"
#include <lo2s/perf/event_description.hpp>
#include <lo2s/perf/event.hpp>

#include <cstring>
#include <optional>
Expand Down Expand Up @@ -57,7 +56,7 @@ class PFM4
pfm_terminate();
}

std::optional<EventDescription> pfm4_read_event(const std::string& ev_desc) const
std::optional<Event> pfm4_read_event(const std::string& ev_desc) const
{
pfm_perf_encode_arg_t arg;
struct perf_event_attr attr;
Expand All @@ -73,20 +72,19 @@ class PFM4
return std::nullopt;
}

EventDescription ev =
EventDescription(ev_desc, (perf_type_id)attr.type, attr.config, attr.config1);
Event ev = Event(ev_desc, (perf_type_id)attr.type, attr.config, attr.config1);

if (!event_is_openable(ev))
if (!ev.event_is_openable())
{
return std::nullopt;
}

return ev;
}

std::vector<EventDescription> get_pfm4_events() const
std::vector<Event> get_pfm4_events() const
{
std::vector<EventDescription> events;
std::vector<Event> events;

pfm_pmu_info_t pinfo;
pfm_event_info_t info;
Expand Down
Loading