Skip to content

Commit

Permalink
refactor: use const for return values
Browse files Browse the repository at this point in the history
  • Loading branch information
hparzych committed Oct 10, 2023
1 parent 9ff8fed commit 1fceaf0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion ebpfdiscoverysrv/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static void runUnixSignalHandlerLoop() {
while (true) {
sigset_t sigset{getSigset()};
LOG_TRACE("Waiting for unix signals.");
int signo{sigwaitinfo(&sigset, nullptr)};
const auto signo{sigwaitinfo(&sigset, nullptr)};
if (signo == -1) {
LOG_CRITICAL("Failed to wait for unix signals: {}", std::strerror(errno));
std::abort();
Expand Down
6 changes: 3 additions & 3 deletions libebpfdiscovery/src/DiscoveryBpfLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void DiscoveryBpfLoader::load() {
LIBBPF_OPTS(bpf_object_open_opts, newOpenOpts);
openOpts = newOpenOpts;

if (int res{ensure_core_btf(&openOpts)}) {
if (const auto res{ensure_core_btf(&openOpts)}) {
throw std::runtime_error("Failed to fetch necessary BTF for CO-RE: " + std::string(strerror(-res)));
}

Expand All @@ -30,11 +30,11 @@ void DiscoveryBpfLoader::load() {
throw std::runtime_error("Failed to open BPF object.");
}

if (int res{discovery_bpf__load(skel)}) {
if (const auto res{discovery_bpf__load(skel)}) {
throw std::runtime_error("Failed to load BPF object: " + std::to_string(res));
}

if (int res{discovery_bpf__attach(skel)}) {
if (const auto res{discovery_bpf__attach(skel)}) {
throw std::runtime_error("Failed to attach BPF object: " + std::to_string(res));
}

Expand Down

0 comments on commit 1fceaf0

Please sign in to comment.