Skip to content

Commit d328193

Browse files
committed
fix clang-tidy issues
1 parent a15cbf8 commit d328193

File tree

3 files changed

+27
-17
lines changed

3 files changed

+27
-17
lines changed

src/daemon/main.cpp

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -391,30 +391,39 @@ int main(const int argc, const char** const argv)
391391
setupLogging(pipe_write_fd, should_daemonize, argc, argv);
392392

393393
spdlog::info("OCVSMD started (ver='{}.{}').", VERSION_MAJOR, VERSION_MINOR);
394+
int result = EXIT_SUCCESS;
394395
{
395-
Application application;
396-
if (const auto failure_str = application.init())
396+
try
397397
{
398-
spdlog::critical("Failed to init application: {}", failure_str.value());
399-
400-
// Report the failure to the parent process (if daemonized; otherwise goes to stderr).
401-
writeString(pipe_write_fd, "Failed to init application: ");
402-
writeString(pipe_write_fd, failure_str.value().c_str());
403-
::exit(EXIT_FAILURE);
404-
}
405-
if (should_daemonize)
398+
Application application;
399+
if (const auto failure_str = application.init())
400+
{
401+
spdlog::critical("Failed to init application: {}", failure_str.value());
402+
403+
// Report the failure to the parent process (if daemonized; otherwise goes to stderr).
404+
writeString(pipe_write_fd, "Failed to init application: ");
405+
writeString(pipe_write_fd, failure_str.value().c_str());
406+
::exit(EXIT_FAILURE);
407+
}
408+
if (should_daemonize)
409+
{
410+
step_14_notify_init_complete(pipe_write_fd);
411+
}
412+
413+
application.runWhile([] { return g_running == 1; });
414+
415+
} catch (const std::exception& ex)
406416
{
407-
step_14_notify_init_complete(pipe_write_fd);
417+
spdlog::critical("Unhandled exception: {}", ex.what());
418+
result = EXIT_FAILURE;
408419
}
409420

410-
application.runWhile([] { return g_running == 1; });
411-
412421
if (g_running == 0)
413422
{
414423
spdlog::debug("Received termination signal.");
415424
}
416425
}
417426
spdlog::info("OCVSMD daemon terminated.");
418427

419-
return EXIT_SUCCESS;
428+
return result;
420429
}

src/sdk/daemon.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,12 +69,13 @@ class DaemonImpl final : public Daemon
6969
},
7070
[this](const ExecCmdChannel::Input& input) {
7171
//
72+
// NOLINTNEXTLINE
7273
logger_->info("C << 🔵 Ch Msg='{}'.", reinterpret_cast<const char*>(input.some_stuff.data()));
7374

7475
if (countdown_--)
7576
{
7677
logger_->info("C >> 🔵 Ch '{}' msg.",
77-
reinterpret_cast<const char*>(input.some_stuff.data()));
78+
reinterpret_cast<const char*>(input.some_stuff.data())); // NOLINT
7879
const int result = ipc_exec_cmd_ch_->send(input);
7980
(void) result;
8081
}

test/common/ipc/test_server_router.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,11 +224,11 @@ TEST_F(TestServerRouter, channel_send)
224224
const Channel::Output msg{&mr_};
225225
EXPECT_CALL(server_pipe_mock, send(cl_id, PayloadOfRouteChannelMsg(msg, mr_, tag, seq++))) //
226226
.WillOnce(Return(0));
227-
EXPECT_THAT(maybe_channel->send(msg), 0);
227+
EXPECT_THAT(maybe_channel->send(msg), 0); // NOLINT
228228

229229
EXPECT_CALL(server_pipe_mock, send(cl_id, PayloadOfRouteChannelMsg(msg, mr_, tag, seq++))) //
230230
.WillOnce(Return(0));
231-
EXPECT_THAT(maybe_channel->send(msg), 0);
231+
EXPECT_THAT(maybe_channel->send(msg), 0); // NOLINT
232232
}
233233

234234
// NOLINTEND(cppcoreguidelines-avoid-magic-numbers, readability-magic-numbers)

0 commit comments

Comments
 (0)