Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit ce5cbe8

Browse files
chore: address compiler warnings (#2072)
* chore: resolve warnings, handle nodiscard, and add error logging * Update command_executor.h use macro PCLOSE to correctly map to _pclose on windows * fix typo: revert PCLOSE to _pclose for windows The PCLOSE macro was mistakenly defined as pclose for Windows. This commit fixes the typo, reverting it back to _pclose * chore: fix formatting --------- Co-authored-by: vansangpfiev <vansangpfiev@gmail.com>
1 parent d1dccf3 commit ce5cbe8

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

engine/controllers/process_manager.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@ void ProcessManager::destroy(
99
std::function<void(const HttpResponsePtr&)>&& callback) {
1010
auto loaded_engines = engine_service_->GetSupportedEngineNames();
1111
for (const auto& engine : loaded_engines.value()) {
12-
engine_service_->UnloadEngine(engine);
12+
auto result = engine_service_->UnloadEngine(engine);
13+
if (!result) {
14+
// Handle the error if any.
15+
// Log the Error
16+
LOG_ERROR << "Error unloading engine: " << result.error();
17+
continue;
18+
}
1319
}
1420
app().quit();
1521
Json::Value ret;

engine/services/hardware_service.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,14 @@ void HardwareService::UpdateHardwareInfos() {
323323
};
324324
for (auto const& he : b.value()) {
325325
if (!exists(he.uuid)) {
326-
db_service_->DeleteHardwareEntry(he.uuid);
326+
auto result = db_service_->DeleteHardwareEntry(he.uuid);
327+
if (!result) {
328+
// Handle the error if any.
329+
// Log the Error
330+
LOG_ERROR << "Error deleting hardware entry " << he.uuid << ": "
331+
<< result.error();
332+
continue;
333+
}
327334
}
328335
}
329336

engine/utils/command_executor.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class CommandExecutor {
2020
if (!pipe) {
2121
throw std::runtime_error("popen() failed!");
2222
}
23-
m_pipe = std::unique_ptr<FILE, decltype(&PCLOSE)>(pipe, PCLOSE);
23+
m_pipe = std::unique_ptr<FILE, void (*)(FILE*)>(pipe, [](FILE* file) { if (file) { PCLOSE(file); } });
2424
}
2525

2626
CommandExecutor(const CommandExecutor&) = delete;
@@ -46,5 +46,5 @@ class CommandExecutor {
4646
}
4747

4848
private:
49-
std::unique_ptr<FILE, decltype(&PCLOSE)> m_pipe{nullptr, PCLOSE};
49+
std::unique_ptr<FILE, void (*)(FILE*)> m_pipe{nullptr, [](FILE* file) { if (file) { PCLOSE(file); } }};
5050
};

0 commit comments

Comments
 (0)