Skip to content

Commit ede768e

Browse files
Sumitkumar Satputethatguysumeet
authored andcommitted
Improve nodiscard adoption for OSAL call sites
Signed-off-by: Sumitkumar Satpute <sumitkumar.sa.satpute@bti.bmwgroup.com>
1 parent d8799bd commit ede768e

8 files changed

Lines changed: 22 additions & 17 deletions

File tree

score/launch_manager/src/control_client/src/details/control_client_impl.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ ControlClientImpl::ControlClientImpl(std::function<void(const score::lcm::Execut
9494

9595
ipc_channel_ = score::lcm::internal::ControlClientChannel::initializeControlClientChannel();
9696

97-
ipc_request_semaphore_.init(1U, false);
97+
static_cast<void>(ipc_request_semaphore_.init(1U, false));
9898
ipc_response_thread_ = std::make_unique<std::thread>(&ControlClientImpl::run, this);
9999
}
100100

@@ -107,7 +107,7 @@ ControlClientImpl::~ControlClientImpl() noexcept {
107107
ipc_response_thread_->join();
108108
}
109109

110-
ipc_request_semaphore_.deinit();
110+
static_cast<void>(ipc_request_semaphore_.deinit());
111111
}
112112

113113
void ControlClientImpl::run() {
@@ -284,7 +284,7 @@ score::concurrency::InterruptibleFuture<void> ControlClientImpl::SendIpcMessage(
284284
}
285285

286286
// we definitely shouldn't forget to release semaphore
287-
ipc_request_semaphore_.post();
287+
static_cast<void>(ipc_request_semaphore_.post());
288288
}
289289
else
290290
{
@@ -375,7 +375,7 @@ score::Result<score::lcm::ExecutionErrorEvent> ControlClientImpl::GetExecutionEr
375375
}
376376

377377
// we definitely shouldn't forget to release semaphore
378-
ipc_request_semaphore_.post();
378+
static_cast<void>(ipc_request_semaphore_.post());
379379
}
380380
// else not needed as kCommunicationError is the default return value
381381
}

score/launch_manager/src/daemon/src/alive_monitor/details/ifappl/MonitorIfDaemon_UT.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ struct MonitorIfDaemonFixture
7474
/// Initialize the IPC server so that peek/pop/hasOverflow use real shared memory.
7575
void initIpc()
7676
{
77-
ipcServer.init(makeUniqueIpcName());
77+
static_cast<void>(ipcServer.init(makeUniqueIpcName()));
7878
}
7979

8080
/// Drive the process to the 'running' state and notify observers.

score/launch_manager/src/daemon/src/osal/security_policy.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace internal {
1919

2020
namespace osal {
2121

22-
int setSecurityPolicy(const char* policy);
22+
[[nodiscard]] int setSecurityPolicy(const char* policy);
2323

2424
}
2525

score/launch_manager/src/daemon/src/osal/semaphore.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class Semaphore final {
6363
/// @return An OsalReturnType indicating the result of the operation.
6464
/// - `OsalReturnType::KSuccess`: The semaphore was successfully initialized.
6565
/// - `OsalReturnType::KFail`: An error occurred during the initialization.
66-
OsalReturnType init(uint32_t value, bool shared);
66+
[[nodiscard]] OsalReturnType init(uint32_t value, bool shared);
6767

6868
/// @brief Destroys the semaphore and releases any resources associated with it.
6969
/// This method uses `sem_destroy` to destroy the semaphore:
@@ -72,7 +72,7 @@ class Semaphore final {
7272
/// @return An OsalReturnType indicating the result of the deinitialization.
7373
/// - `OsalReturnType::KSuccess`: The semaphore was successfully deinitialized.
7474
/// - `OsalReturnType::KFail`: An error occurred during the deinitialization.
75-
OsalReturnType deinit();
75+
[[nodiscard]] OsalReturnType deinit();
7676

7777
/// @brief Decrement the semaphore, blocking until the semaphore can be decremented or the timeout expires.
7878
/// This method does not use `sem_timedwait` to attempt to decrement the semaphore because that does not use a monotonic clock.
@@ -85,7 +85,7 @@ class Semaphore final {
8585
/// - `OsalReturnType::KSuccess`: The semaphore was successfully decremented within the specified time.
8686
/// - `OsalReturnType::KTimeout`: The semaphore was not decremented because the wait timed out.
8787
/// - `OsalReturnType::KFail`: An error occurred during the wait operation (e.g., if the system clock could not be read).
88-
OsalReturnType timedWait(std::chrono::milliseconds delay);
88+
[[nodiscard]] OsalReturnType timedWait(std::chrono::milliseconds delay);
8989

9090
/// @brief Increments (posts) the semaphore.
9191
/// This method uses `sem_post` to increment the semaphore:
@@ -96,7 +96,7 @@ class Semaphore final {
9696
/// @return An OsalReturnType indicating the result of the operation.
9797
/// - `OsalReturnType::KSuccess`: The semaphore was successfully incremented (posted).
9898
/// - `OsalReturnType::KFail`: An error occurred during the increment (post) operation.
99-
OsalReturnType post();
99+
[[nodiscard]] OsalReturnType post();
100100

101101
/// @brief Decrements (waits) the semaphore.
102102
/// This method uses `sem_wait` to decrement the semaphore:
@@ -107,7 +107,7 @@ class Semaphore final {
107107
/// @return An OsalReturnType indicating the result of the operation.
108108
/// - `OsalReturnType::KSuccess`: The semaphore was successfully decremented (waited).
109109
/// - `OsalReturnType::KFail`: An error occurred during the decrement (wait) operation.
110-
OsalReturnType wait();
110+
[[nodiscard]] OsalReturnType wait();
111111

112112
private:
113113
/// @brief POSIX semaphore object

score/launch_manager/src/daemon/src/osal/set_affinity.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace osal {
3636
/// currently physically on the system and permitted to the
3737
/// thread according to any restrictions that may be imposed
3838
/// elsewhere.
39-
int32_t setaffinity(uint32_t cpumask) noexcept(true);
39+
[[nodiscard]] int32_t setaffinity(uint32_t cpumask) noexcept(true);
4040
} // namespace osal
4141
} // namespace lcm
4242
} // namespace internal

score/launch_manager/src/daemon/src/osal/set_groups.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ namespace osal {
3232
/// to the underlying OS call.
3333
/// @param __groups pointer to the list of groups, may be NULL
3434
/// @returns 0 on success, -1 on failure.
35-
std::int32_t setgroups(size_t __n, const gid_t *__groups) noexcept(true);
35+
[[nodiscard]] std::int32_t setgroups(size_t __n, const gid_t *__groups) noexcept(true);
3636
} // namespace osal
3737
} // namespace lcm
3838
} // namespace internal

score/launch_manager/src/daemon/src/process_group_manager/details/process_info_node.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ void ProcessInfoNode::terminated(int32_t process_status)
282282
// handle the situation where a worker thread is waiting for a process to terminate
283283
if (has_semaphore_.exchange(false))
284284
{
285-
terminator_.post();
285+
static_cast<void>(terminator_.post());
286286
}
287287
}
288288

@@ -519,7 +519,7 @@ inline void ProcessInfoNode::handleTerminationProcess()
519519
{
520520
auto pg_mgr = graph_->getProcessGroupManager();
521521

522-
terminator_.init(0U, false);
522+
static_cast<void>(terminator_.init(0U, false));
523523
has_semaphore_.store(true);
524524
LM_LOG_DEBUG() << "Requesting termination of process" << process_index_ << "of" << graph_->getProcessGroupName()
525525
<< "pid" << pid_ << "(" << config_->startup_config_.short_name_ << ")";
@@ -538,7 +538,7 @@ inline void ProcessInfoNode::handleTerminationProcess()
538538
}
539539

540540
has_semaphore_.store(false);
541-
terminator_.deinit();
541+
static_cast<void>(terminator_.deinit());
542542
}
543543

544544
inline void ProcessInfoNode::handleForcedTermination()

score/launch_manager/src/lifecycle_client/src/details/report_running_impl.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,12 @@ namespace score::mw::lifecycle {
105105
}
106106

107107
// Final post to semaphore, so LM know that communication channel can be closed now
108-
sync->send_sync_.post();
108+
if (sync->send_sync_.post() == OsalReturnType::kFail)
109+
{
110+
LM_LOG_ERROR() << "[Lifecycle Client] Final synchronization post failed.";
111+
112+
return comms_error;
113+
}
109114
// Mark as reported if successful
110115
reported = true;
111116
// Set return value to success

0 commit comments

Comments
 (0)