From 71f4a9776d20b118225b0b6cc6ea7b4ffedb150f Mon Sep 17 00:00:00 2001 From: Gwangmu Lee Date: Wed, 4 Sep 2024 14:58:01 +0000 Subject: [PATCH] Resolved build warnings --- src/cli/CommandRun.hpp | 2 +- src/hooks/mpi/MpiHook.cpp | 2 +- src/hooks/mpi/test/test_SharedLibrary.cpp | 26 +++++++++++------------ src/hooks/ssh/test/test_SSHHook.cpp | 6 +++--- src/libsarus/test/test_Flock.cpp | 5 +++-- src/libsarus/test/test_HookUtility.cpp | 1 - src/libsarus/test/test_Utility.cpp | 4 ++-- src/runtime/Utility.cpp | 4 ++-- 8 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/cli/CommandRun.hpp b/src/cli/CommandRun.hpp index 877fa1f1..75f36782 100644 --- a/src/cli/CommandRun.hpp +++ b/src/cli/CommandRun.hpp @@ -420,7 +420,7 @@ class CommandRun : public Command { auto parser = libsarus::DeviceParser{conf->getRootfsDirectory(), conf->userIdentity}; auto siteDevices = conf->commandRun.deviceMounts; for (const auto& requestString : deviceMounts) { - auto deviceMount = std::move(parser.parseDeviceRequest(requestString)); + auto deviceMount = parser.parseDeviceRequest(requestString); auto previousSiteDevice = findMatchingSiteDevice(deviceMount, siteDevices); if (previousSiteDevice) { auto message = boost::format("Device %s already added by the system administrator at container path %s with access %s. " diff --git a/src/hooks/mpi/MpiHook.cpp b/src/hooks/mpi/MpiHook.cpp index 02b3db41..f40bb0ff 100644 --- a/src/hooks/mpi/MpiHook.cpp +++ b/src/hooks/mpi/MpiHook.cpp @@ -241,7 +241,7 @@ void MpiHook::injectHostLibraries(const std::vector& hostLibs, AbiCheckerFactory checkerFactory; for(const auto& lib : hostLibs) { - injectHostLibrary(lib, hostToContainerLibs, std::move(checkerFactory.create(checkerType))); + injectHostLibrary(lib, hostToContainerLibs, checkerFactory.create(checkerType)); } log("Successfully injected host's shared libs", libsarus::LogLevel::INFO); diff --git a/src/hooks/mpi/test/test_SharedLibrary.cpp b/src/hooks/mpi/test/test_SharedLibrary.cpp index 4aa7941f..432b88f4 100644 --- a/src/hooks/mpi/test/test_SharedLibrary.cpp +++ b/src/hooks/mpi/test/test_SharedLibrary.cpp @@ -117,51 +117,51 @@ TEST(SharedLibraryTestGroup, bestAbiMatch) { { auto candidates = std::vector{SharedLibrary{"/lib/libfoo.so.1"}, SharedLibrary{"/lib/libfoo.so"}, SharedLibrary{"/lib/libfoo.so.2"}, SharedLibrary{"/lib/libfoo.so.3"}}; auto best = sl2.pickNewestAbiCompatibleLibrary(candidates); - CHECK_EQUAL(best.getRealName(), "libfoo.so.2"); + CHECK_EQUAL(best.getRealName(), std::string("libfoo.so.2")); } { auto candidates = std::vector{SharedLibrary{"/lib/libfoo.so.2"}, SharedLibrary{"/lib/libfoo.so.2.4"}, SharedLibrary{"/lib/libfoo.so.2.3.4"}, SharedLibrary{"/lib/libfoo.so.2.3"}}; auto best = sl234.pickNewestAbiCompatibleLibrary(candidates); - CHECK_EQUAL(best.getRealName(), "libfoo.so.2.3.4"); + CHECK_EQUAL(best.getRealName(), std::string("libfoo.so.2.3.4")); } // newest older { auto candidates = std::vector{SharedLibrary{"/lib/libfoo.so.2"}, SharedLibrary{"/lib/libfoo.so.2.3.3"}, SharedLibrary{"/lib/libfoo.so.2.3.2"}}; auto best = sl234.pickNewestAbiCompatibleLibrary(candidates); - CHECK_EQUAL(best.getRealName(), "libfoo.so.2.3.3"); + CHECK_EQUAL(best.getRealName(), std::string("libfoo.so.2.3.3")); } { auto candidates = std::vector{SharedLibrary{"/lib/libfoo.so.2.1"}, SharedLibrary{"/lib/libfoo.so.2.2"}, SharedLibrary{"/lib/libfoo.so.2.4"}}; auto best = sl23.pickNewestAbiCompatibleLibrary(candidates); - CHECK_EQUAL(best.getRealName(), "libfoo.so.2.2"); + CHECK_EQUAL(best.getRealName(), std::string("libfoo.so.2.2")); } { auto candidates = std::vector{SharedLibrary{"/lib/libfoo.so.2.1.7"}, SharedLibrary{"/lib/libfoo.so.2.2.3"}}; auto best = sl234.pickNewestAbiCompatibleLibrary(candidates); - CHECK_EQUAL(best.getRealName(), "libfoo.so.2.2.3"); // minor is more important than patch + CHECK_EQUAL(best.getRealName(), std::string("libfoo.so.2.2.3")); // minor is more important than patch } { auto candidates = std::vector{SharedLibrary{"/lib/libfoo.so.2.3.3"}, SharedLibrary{"/lib/libfoo.so.2.3.6"}, SharedLibrary{"/lib/libfoo.so.2.3.5"}}; auto best = sl234.pickNewestAbiCompatibleLibrary(candidates); - CHECK_EQUAL(best.getRealName(), "libfoo.so.2.3.6"); // don't downgrade patch + CHECK_EQUAL(best.getRealName(), std::string("libfoo.so.2.3.6")); // don't downgrade patch } { auto candidates = std::vector{SharedLibrary{"/lib/libfoo.so.2"}, SharedLibrary{"/lib/libfoo.so.2.3.7"}, SharedLibrary{"/lib/libfoo.so.3"}}; auto best = sl234.pickNewestAbiCompatibleLibrary(candidates); - CHECK_EQUAL(best.getRealName(), "libfoo.so.2.3.7"); // newer patch is ok + CHECK_EQUAL(best.getRealName(), std::string("libfoo.so.2.3.7")); // newer patch is ok } // oldest newer { auto candidates = std::vector{SharedLibrary{"/lib/libfoo.so.3"}, SharedLibrary{"/lib/libfoo.so.2.4"}, SharedLibrary{"/lib/libfoo.so.2.4.6"}}; auto best = sl234.pickNewestAbiCompatibleLibrary(candidates); - CHECK_EQUAL(best.getRealName(), "libfoo.so.2.4.6"); + CHECK_EQUAL(best.getRealName(), std::string("libfoo.so.2.4.6")); } { auto candidates = std::vector{SharedLibrary{"/lib/libfoo.so.5"}, SharedLibrary{"/lib/libfoo.so.4"}, SharedLibrary{"/lib/libfoo.so.3.7"}}; auto best = sl234.pickNewestAbiCompatibleLibrary(candidates); - CHECK_EQUAL(best.getRealName(), "libfoo.so.3.7"); + CHECK_EQUAL(best.getRealName(), std::string("libfoo.so.3.7")); } // corner cases @@ -170,22 +170,22 @@ TEST(SharedLibraryTestGroup, bestAbiMatch) { { auto candidates = std::vector{SharedLibrary{"/lib/libfoo.so.2"}}; auto best = sl2.pickNewestAbiCompatibleLibrary(candidates); - CHECK_EQUAL(best.getRealName(), "libfoo.so.2"); // exact match with just major + CHECK_EQUAL(best.getRealName(), std::string("libfoo.so.2")); // exact match with just major } { auto candidates = std::vector{SharedLibrary{"/lib/libfoo.so.4"}}; auto best = sl2.pickNewestAbiCompatibleLibrary(candidates); - CHECK_EQUAL(best.getRealName(), "libfoo.so.4"); // only candidate non compatible still "best" + CHECK_EQUAL(best.getRealName(), std::string("libfoo.so.4")); // only candidate non compatible still "best" } { auto candidates = std::vector{SharedLibrary{"/lib/libfoo.so.1"}, SharedLibrary{"/lib/libfoo.so.3"}}; auto best = sl2.pickNewestAbiCompatibleLibrary(candidates); - CHECK_EQUAL(best.getRealName(), "libfoo.so.1"); // though incompatible, still newest older + CHECK_EQUAL(best.getRealName(), std::string("libfoo.so.1")); // though incompatible, still newest older } { auto candidates = std::vector{SharedLibrary{"/lib/libfoo.so.2.10"}, SharedLibrary{"/lib/libfoo.so.2.2"}}; auto best = SharedLibrary{"/lib/libfoo.so.2.20"}.pickNewestAbiCompatibleLibrary(candidates); - CHECK_EQUAL(best.getRealName(), "libfoo.so.2.10"); // check for typical string-comparison pitfalls + CHECK_EQUAL(best.getRealName(), std::string("libfoo.so.2.10")); // check for typical string-comparison pitfalls } } diff --git a/src/hooks/ssh/test/test_SSHHook.cpp b/src/hooks/ssh/test/test_SSHHook.cpp index e84ddf40..9e94c94c 100644 --- a/src/hooks/ssh/test/test_SSHHook.cpp +++ b/src/hooks/ssh/test/test_SSHHook.cpp @@ -10,13 +10,13 @@ #include #include +#include #include +#include +#include #include #include -#include -#include -#include #include #include "common/Config.hpp" diff --git a/src/libsarus/test/test_Flock.cpp b/src/libsarus/test/test_Flock.cpp index d395b5ae..7d66f04c 100644 --- a/src/libsarus/test/test_Flock.cpp +++ b/src/libsarus/test/test_Flock.cpp @@ -117,7 +117,7 @@ TEST(FlockTestGroup, convert_write_to_read) { TEST(FlockTestGroup, timeout_time_is_respected) { libsarus::Flock lock{fileToLock, libsarus::Flock::Type::writeLock}; - for (auto &timeout : {10, 100, 500, 1000, 2000}) { + for (auto &timeout : {100, 500, 1000, 2000}) { auto start = std::chrono::system_clock::now(); try { libsarus::Flock{fileToLock, libsarus::Flock::Type::writeLock, std::chrono::milliseconds{timeout}}; @@ -125,7 +125,8 @@ TEST(FlockTestGroup, timeout_time_is_respected) { } auto end = std::chrono::system_clock::now(); std::chrono::duration elapsed = end - start; - CHECK(timeout <= elapsed.count() <= 2 * timeout); + CHECK(timeout <= elapsed.count()); + CHECK(elapsed.count() <= 2 * timeout); } } diff --git a/src/libsarus/test/test_HookUtility.cpp b/src/libsarus/test/test_HookUtility.cpp index 450c5da0..d5718e37 100644 --- a/src/libsarus/test/test_HookUtility.cpp +++ b/src/libsarus/test/test_HookUtility.cpp @@ -40,7 +40,6 @@ TEST(HooksUtilityTestGroup, parseStateOfContainerFromStdin) { libsarus::filesystem::createFoldersIfNecessary(expectedBundleDir.getPath()); auto returnedBundleDir = boost::filesystem::path(); - pid_t returnedPid; aux::hook::writeOCIContainerStateToStdin(expectedBundleDir.getPath()); auto containerState = parseStateOfContainerFromStdin(); diff --git a/src/libsarus/test/test_Utility.cpp b/src/libsarus/test/test_Utility.cpp index 9dd6bf29..7416f544 100644 --- a/src/libsarus/test/test_Utility.cpp +++ b/src/libsarus/test/test_Utility.cpp @@ -162,7 +162,7 @@ TEST(UtilityTestGroup, setFilesystemUid) { CHECK_EQUAL(getgid(), rootIdentity.gid); CHECK_EQUAL(geteuid(), rootIdentity.uid); CHECK_EQUAL(getegid(), rootIdentity.gid); - CHECK_EQUAL(setfsuid(-1), unprivilegedIdentity.uid); + CHECK_EQUAL((uid_t)setfsuid(-1), unprivilegedIdentity.uid); // switch back to privileged fsuid libsarus::process::setFilesystemUid(rootIdentity); @@ -172,7 +172,7 @@ TEST(UtilityTestGroup, setFilesystemUid) { CHECK_EQUAL(getgid(), rootIdentity.gid); CHECK_EQUAL(geteuid(), rootIdentity.uid); CHECK_EQUAL(getegid(), rootIdentity.gid); - CHECK_EQUAL(setfsuid(-1), rootIdentity.uid); + CHECK_EQUAL((uid_t)setfsuid(-1), rootIdentity.uid); } TEST(UtilityTestGroup, executeCommand) { diff --git a/src/runtime/Utility.cpp b/src/runtime/Utility.cpp index 397d67b6..fc27a9ba 100644 --- a/src/runtime/Utility.cpp +++ b/src/runtime/Utility.cpp @@ -142,7 +142,7 @@ std::vector> generatePMIxMounts(std::shared_ptr auto slurmJobUid = hostEnvironment.at("SLURM_JOB_UID"); auto slurmStepId = hostEnvironment.at("SLURM_STEP_ID"); - if (boost::regex_match(slurmConfig, matches, boost::regex{"SlurmdSpoolDir\s*=\s(.*)"})) { + if (boost::regex_match(slurmConfig, matches, boost::regex{"SlurmdSpoolDir\\s*=\\s(.*)"})) { utility::logMessage(boost::format("Found SlurmdSpoolDir=%s") % matches[1], libsarus::LogLevel::DEBUG); auto slurmSpoolPath = boost::filesystem::path(matches[1]); auto slurmPmixPath = slurmSpoolPath / (boost::format("pmix.%s.%s") % slurmJobId % slurmStepId).str(); @@ -158,7 +158,7 @@ std::vector> generatePMIxMounts(std::shared_ptr } } - if (boost::regex_match(slurmConfig, matches, boost::regex{"TmpFS\s*=\s(.*)"})) { + if (boost::regex_match(slurmConfig, matches, boost::regex{"TmpFS\\s*=\\s(.*)"})) { utility::logMessage(boost::format("Found Slurm TmpFS=%s") % matches[1], libsarus::LogLevel::DEBUG); auto slurmTmpFS = boost::filesystem::path(matches[1]); auto mountPath = slurmTmpFS / (boost::format("spmix_appdir_%s_%s.%s") % slurmJobUid % slurmJobId % slurmStepId).str();