summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/configuration.hpp2
-rw-r--r--src/events.hpp10
-rw-r--r--src/logger.hpp7
-rw-r--r--src/state/activating_state.cpp47
-rw-r--r--src/state/initial_state.hpp5
-rw-r--r--src/system.hpp2
-rw-r--r--src/utils.hpp5
7 files changed, 37 insertions, 41 deletions
diff --git a/src/configuration.hpp b/src/configuration.hpp
index c29e133..efdddf2 100644
--- a/src/configuration.hpp
+++ b/src/configuration.hpp
@@ -218,7 +218,7 @@ class Configuration
{
mp.mode = Configuration::Mode::proxy;
}
-#if LEGACY_MODE_ENABLED
+#ifdef LEGACY_MODE_ENABLED
else if (*value == 1)
{
mp.mode = Configuration::Mode::legacy;
diff --git a/src/events.hpp b/src/events.hpp
index 320d344..03d0c50 100644
--- a/src/events.hpp
+++ b/src/events.hpp
@@ -11,8 +11,6 @@ struct BasicEvent
{
}
- virtual ~BasicEvent() = default;
-
const char* eventName;
};
@@ -22,7 +20,7 @@ struct RegisterDbusEvent : public BasicEvent
std::shared_ptr<sdbusplus::asio::connection> bus,
std::shared_ptr<sdbusplus::asio::object_server> objServer) :
BasicEvent(__FUNCTION__),
- bus(bus), objServer(objServer)
+ bus(std::move(bus)), objServer(std::move(objServer))
{
}
@@ -40,14 +38,16 @@ struct MountEvent : public BasicEvent
}
MountEvent(const MountEvent&) = delete;
- MountEvent(MountEvent&& other) :
+
+ MountEvent(MountEvent&& other) noexcept :
BasicEvent(__FUNCTION__), target(std::move(other.target))
{
other.target = std::nullopt;
}
MountEvent& operator=(const MountEvent&) = delete;
- MountEvent& operator=(MountEvent&& other)
+
+ MountEvent& operator=(MountEvent&& other) noexcept
{
target = std::nullopt;
std::swap(target, other.target);
diff --git a/src/logger.hpp b/src/logger.hpp
index 3aef8e2..6086ec4 100644
--- a/src/logger.hpp
+++ b/src/logger.hpp
@@ -47,10 +47,9 @@ struct Critical
template <std::size_t Len>
constexpr const char* baseNameImpl(const char (&str)[Len], std::size_t pos)
{
- return pos == 0 ? str
- : (str[pos] == '/' || str[pos] == '\\')
- ? str + pos + 1
- : baseNameImpl(str, --pos);
+ return pos == 0 ? str
+ : (str[pos] == '/' || str[pos] == '\\') ? str + pos + 1
+ : baseNameImpl(str, --pos);
}
template <std::size_t Len>
diff --git a/src/state/activating_state.cpp b/src/state/activating_state.cpp
index 686de99..c22174f 100644
--- a/src/state/activating_state.cpp
+++ b/src/state/activating_state.cpp
@@ -20,7 +20,9 @@
#include <sdbusplus/asio/object_server.hpp>
ActivatingState::ActivatingState(interfaces::MountPointStateMachine& machine) :
- BasicStateT(machine){};
+ BasicStateT(machine)
+{
+}
std::unique_ptr<BasicState> ActivatingState::onEnter()
{
@@ -63,7 +65,7 @@ std::unique_ptr<BasicState> ActivatingState::activateProxyMode()
"/usr/sbin/nbd-client", machine.getConfig().nbdDevice));
if (!process->spawn(Configuration::MountPoint::toArgs(machine.getConfig()),
- [&machine = machine](int exitCode, bool isReady) {
+ [&machine = machine](int exitCode) {
LogMsg(Logger::Info, machine.getName(),
" process ended.");
machine.getExitCode() = exitCode;
@@ -117,7 +119,7 @@ std::unique_ptr<BasicState> ActivatingState::activateLegacyMode()
{
return mountSmbShare();
}
- else if (isHttpsUrl(machine.getTarget()->imgUrl))
+ if (isHttpsUrl(machine.getTarget()->imgUrl))
{
return mountHttpsShare();
}
@@ -201,7 +203,7 @@ std::unique_ptr<resource::Process>
}
}
- std::string nbd_client =
+ std::string nbdClient =
"/usr/sbin/nbd-client " +
boost::algorithm::join(
Configuration::MountPoint::toArgs(machine.getConfig()), " ");
@@ -213,7 +215,7 @@ std::unique_ptr<resource::Process>
// ... then connect nbd-client to served image
"--run",
- nbd_client,
+ nbdClient,
#if VM_VERBOSE_NBDKIT_LOGS
"--verbose", // swarm of debug logs - only for brave souls
@@ -222,14 +224,14 @@ std::unique_ptr<resource::Process>
if (!machine.getTarget()->rw)
{
- args.push_back("--readonly");
+ args.emplace_back("--readonly");
}
// Insert extra params
args.insert(args.end(), params.begin(), params.end());
- if (!process->spawn(args, [&machine = machine, secret = std::move(secret)](
- int exitCode, [[maybe_unused]] bool isReady) {
+ if (!process->spawn(args, [&machine = machine,
+ secret = std::move(secret)](int exitCode) {
LogMsg(Logger::Info, machine.getName(), " process ended.");
machine.getExitCode() = exitCode;
machine.emitSubprocessStoppedEvent();
@@ -312,17 +314,13 @@ bool ActivatingState::getImagePathFromUrl(const std::string& urlScheme,
*imagePath = imageUrl.substr(urlScheme.size() - 1);
return true;
}
- else
- {
- LogMsg(Logger::Error, "Invalid parameter provied");
- return false;
- }
- }
- else
- {
- LogMsg(Logger::Error, "Provided url does not match scheme");
+
+ LogMsg(Logger::Error, "Invalid parameter provied");
return false;
}
+
+ LogMsg(Logger::Error, "Provided url does not match scheme");
+ return false;
}
bool ActivatingState::isHttpsUrl(const std::string& imageUrl)
@@ -353,16 +351,13 @@ fs::path ActivatingState::getImagePath(const std::string& imageUrl)
if (isHttpsUrl(imageUrl) && getImagePathFromHttpsUrl(imageUrl, &imagePath))
{
- return fs::path(imagePath);
+ return {imagePath};
}
- else if (isCifsUrl(imageUrl) &&
- getImagePathFromCifsUrl(imageUrl, &imagePath))
+ if (isCifsUrl(imageUrl) && getImagePathFromCifsUrl(imageUrl, &imagePath))
{
- return fs::path(imagePath);
- }
- else
- {
- LogMsg(Logger::Error, "Unrecognized url's scheme encountered");
- return fs::path("");
+ return {imagePath};
}
+
+ LogMsg(Logger::Error, "Unrecognized url's scheme encountered");
+ return {""};
}
diff --git a/src/state/initial_state.hpp b/src/state/initial_state.hpp
index a1efeef..324f456 100644
--- a/src/state/initial_state.hpp
+++ b/src/state/initial_state.hpp
@@ -19,7 +19,7 @@ struct InitialState : public BasicStateT<InitialState>
const bool isLegacy =
(machine.getConfig().mode == Configuration::Mode::legacy);
-#if !LEGACY_MODE_ENABLED
+#ifndef LEGACY_MODE_ENABLED
if (isLegacy)
{
return std::make_unique<ReadyState>(machine,
@@ -183,7 +183,8 @@ struct InitialState : public BasicStateT<InitialState>
},
[&config = machine.getConfig()](
[[maybe_unused]] const int& property) -> int {
- return config.remainingInactivityTimeout.count();
+ return static_cast<int>(
+ config.remainingInactivityTimeout.count());
});
iface->initialize();
}
diff --git a/src/system.hpp b/src/system.hpp
index 22f9717..ea88e25 100644
--- a/src/system.hpp
+++ b/src/system.hpp
@@ -428,7 +428,7 @@ class Process : public std::enable_shared_from_this<Process>
" EC: ", child.exit_code(),
" Native: ", child.native_exit_code());
- onExit(child.exit_code(), dev.isReady());
+ onExit(child.exit_code());
});
return true;
}
diff --git a/src/utils.hpp b/src/utils.hpp
index 8eaebfa..587cc41 100644
--- a/src/utils.hpp
+++ b/src/utils.hpp
@@ -231,7 +231,7 @@ class VolatileFile
FileObject(const FileObject&) = delete;
FileObject& operator=(const FileObject&) = delete;
- ssize_t write(void* data, ssize_t nw)
+ ssize_t write(void* data, size_t nw)
{
return ::write(fd, data, nw);
}
@@ -271,7 +271,8 @@ class VolatileFile
{
std::size_t bytesToWrite =
std::min(secretLimit, (size - bytesWritten));
- file.write(buf.data(), bytesToWrite);
+ file.write(buf.data(),
+ static_cast<std::streamsize>(bytesToWrite));
bytesWritten += bytesToWrite;
}
}