Skip to content

Commit

Permalink
Fix the last warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Hilst committed Jan 11, 2025
1 parent 0bfe8ee commit 121594c
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 16 deletions.
6 changes: 4 additions & 2 deletions include/cloysterhpc/services/IService.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class IService {
bool handleException(const sdbus::Error& e, const std::string_view fn);

template <typename... Ts>
sdbus::ObjectPath callObjectFunction(
std::optional<sdbus::ObjectPath> callObjectFunction(
const std::string function, Ts... params)
{
try {
Expand All @@ -42,11 +42,12 @@ class IService {
} catch (sdbus::Error& e) {
if (!handleException(e, function))
throw;
return {};
}
}

template <typename... Ts>
MessageReply callObjectFunctionArray(
std::optional<MessageReply> callObjectFunctionArray(
const std::string function, Ts... params)
{
try {
Expand All @@ -58,6 +59,7 @@ class IService {
} catch (sdbus::Error& e) {
if (!handleException(e, function))
throw;
return {};
}
}

Expand Down
5 changes: 5 additions & 0 deletions src/cpu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
#include <cloysterhpc/cpu.h>

CPU::CPU()
: m_sockets(0)
, m_cores(0)
, m_threads(0)
, m_coresPerSocket(0)
, m_threadsPerCore(0)
{
// TODO: Implement a CPU detection algorithm
}
Expand Down
24 changes: 15 additions & 9 deletions src/services/IService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,12 @@ void IService::enable()

LOG_TRACE("service: enabling {}", m_name);

auto ret = callObjectFunctionArray("EnableUnitFiles", false, true)
.getPair<bool, EnableRType>();
const auto& [_install, retvec] = ret;
auto ret = callObjectFunctionArray("EnableUnitFiles", false, true);
if (!ret.has_value()) {
LOG_ERROR("callObjectFunctionArray returned none for service {}", m_name);
return;
}
const auto& [_install, retvec] = (*ret).getPair<bool, EnableRType>();

if (retvec.empty()) {
LOG_WARN("service {} already enabled", m_name);
Expand All @@ -52,10 +55,13 @@ void IService::disable()

LOG_TRACE("service: disabling {}", m_name);

auto ret = callObjectFunctionArray("DisableUnitFiles", false, true)
.get<EnableRType>();
auto ret = callObjectFunctionArray("DisableUnitFiles", false, true);
if (!ret.has_value()) {
LOG_ERROR("callObjectFunctionArray returned none, service {}", m_name);
return;
};

if (ret.empty()) {
if ((*ret).get<EnableRType>().empty()) {
LOG_WARN("service {} already disabled", m_name);
}
}
Expand All @@ -68,7 +74,7 @@ void IService::start()
}

LOG_TRACE("service: starting {}", m_name);
(void)callObjectFunction("StartUnit", "replace");
callObjectFunction("StartUnit", "replace");
}

void IService::restart()
Expand All @@ -79,7 +85,7 @@ void IService::restart()
}

LOG_TRACE("service: restarting {}", m_name);
(void)callObjectFunction("RestartUnit", "replace");
callObjectFunction("RestartUnit", "replace");
}

void IService::stop()
Expand All @@ -90,5 +96,5 @@ void IService::stop()
}

LOG_TRACE("service: stopping {}", m_name);
(void)callObjectFunction("StopUnit", "replace");
callObjectFunction("StopUnit", "replace");
}
4 changes: 2 additions & 2 deletions src/services/xcat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ void XCAT::patchInstall()
/* Required for EL 9.5
* Upstream PR: https://github.com/xcat2/xcat-core/pull/7489
*/
cloyster::runCommand("sed -i \"s/\-extensions\ usr_cert\ //g\" "
cloyster::runCommand("sed -i \"s/-extensions usr_cert //g\" "
"/opt/xcat/share/xcat/scripts/setup-local-client.sh");
cloyster::runCommand("sed -i \"s/\-extensions\ server //g\" "
cloyster::runCommand("sed -i \"s/-extensions server //g\" "
"/opt/xcat/share/xcat/scripts/setup-server-cert.sh");
cloyster::runCommand("xcatconfig -f");
}
Expand Down
2 changes: 0 additions & 2 deletions src/tempdir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ static char value_to_char(std::uint64_t value)

#define NOSONAR(code) code

#pragma warning disable S2245
static std::filesystem::path create_temporary_filename()
{
static std::random_device dev;
Expand All @@ -35,7 +34,6 @@ static std::filesystem::path create_temporary_filename()
std::string basename = fmt::format("temp{}", values.data());
return std::filesystem::path { "/tmp" } / basename; // NOSONAR
}
#pragma warning restore S2245

TempDir::TempDir()
{
Expand Down
2 changes: 1 addition & 1 deletion src/view/newtListMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ std::pair<int, std::vector<std::string>> Newt::multipleSelectionMenu(
auto* list = newtListbox(1, 3, m_maxListHeight, NEWT_FLAG_MULTIPLE);

for (const auto& [key, item, enabled] : items) {
newtListboxAppendEntry(list, item.c_str(), (void*)key.c_str());
newtListboxAppendEntry(list, item.c_str(), key.c_str());

if (enabled)
newtListboxSelectItem(list, key.c_str(), NEWT_FLAGS_SET);
Expand Down

0 comments on commit 121594c

Please sign in to comment.