Skip to content
Open
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
4 changes: 2 additions & 2 deletions apps/uab/loader/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ int main([[maybe_unused]] int argc, [[maybe_unused]] char **argv) // NOLINT
auto bundleArg = "--bundle=" + containerBundle.string();
auto pid = fork();
if (pid < 0) {
std::cerr << "fork() err: " << ::strerror(errno) << std::endl;
std::cerr << "fork() err: " << std::generic_category().message(errno) << std::endl;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For system call errors (such as those from fork()), std::system_category() is conceptually more appropriate than std::generic_category(). std::system_category() is specifically designed for errors reported by the operating system, whereas std::generic_category() is for portable, generic error codes (equivalent to std::errc). Using std::system_category() ensures that any system-specific error codes are correctly mapped to their corresponding error messages.

Suggested change
std::cerr << "fork() err: " << std::generic_category().message(errno) << std::endl;
std::cerr << "fork() err: " << std::system_category().message(errno) << std::endl;

return -1;
}

Expand All @@ -613,7 +613,7 @@ int main([[maybe_unused]] int argc, [[maybe_unused]] char **argv) // NOLINT

int wstatus{ 0 };
if (auto ret = ::waitpid(pid, &wstatus, 0); ret == -1) {
std::cerr << "waitpid() err:" << ::strerror(errno) << std::endl;
std::cerr << "waitpid() err:" << std::generic_category().message(errno) << std::endl;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For system call errors (such as those from waitpid()), std::system_category() is conceptually more appropriate than std::generic_category(). std::system_category() is specifically designed for errors reported by the operating system, whereas std::generic_category() is for portable, generic error codes (equivalent to std::errc). Using std::system_category() ensures that any system-specific error codes are correctly mapped to their corresponding error messages.

Suggested change
std::cerr << "waitpid() err:" << std::generic_category().message(errno) << std::endl;
std::cerr << "waitpid() err:" << std::system_category().message(errno) << std::endl;

return -1;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1443,8 +1443,9 @@ utils::error::Result<void> ContainerCfgBuilder::buildMountNetworkConf() noexcept
std::array<char, PATH_MAX + 1> buf{};
auto *rpath = realpath(resolvConf.string().c_str(), buf.data());
if (rpath == nullptr) {
return LINGLONG_ERR(
fmt::format("Failed to read symlink {}: {}", resolvConf, strerror(errno)));
return LINGLONG_ERR(fmt::format("Failed to read symlink {}: {}",
resolvConf,
std::generic_category().message(errno)));
Comment on lines +1446 to +1448

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For system call errors (such as those from realpath()), std::system_category() is conceptually more appropriate than std::generic_category(). std::system_category() is specifically designed for errors reported by the operating system, whereas std::generic_category() is for portable, generic error codes (equivalent to std::errc). Using std::system_category() ensures that any system-specific error codes are correctly mapped to their corresponding error messages.

                    return LINGLONG_ERR(fmt::format("Failed to read symlink {}: {}",
                                                    resolvConf,
                                                    std::system_category().message(errno)));

}
target = std::filesystem::path{ rpath };
}
Expand Down Expand Up @@ -2319,8 +2320,9 @@ ContainerCfgBuilder::mountBind(const ocppi::runtime::config::types::Mount &mount
}

if (::mount(mount.source->c_str(), mount.destination.c_str(), "", flags, nullptr) != 0) {
return LINGLONG_ERR(
fmt::format("failed to mount {}: {}", mount.source.value(), strerror(errno)));
return LINGLONG_ERR(fmt::format("failed to mount {}: {}",
mount.source.value(),
std::generic_category().message(errno)));
Comment on lines +2323 to +2325

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For system call errors (such as those from ::mount()), std::system_category() is conceptually more appropriate than std::generic_category(). std::system_category() is specifically designed for errors reported by the operating system, whereas std::generic_category() is for portable, generic error codes (equivalent to std::errc). Using std::system_category() ensures that any system-specific error codes are correctly mapped to their corresponding error messages.

        return LINGLONG_ERR(fmt::format("failed to mount {}: {}",
                                        mount.source.value(),
                                        std::system_category().message(errno)));

}

return LINGLONG_OK;
Expand Down
Loading