From d00f7a94fd8b3fcb23cb5208407e79e963eb4287 Mon Sep 17 00:00:00 2001 From: boltgolt Date: Sat, 18 Feb 2023 20:22:51 +0100 Subject: [PATCH] Fix warnings --- howdy/src/pam/main.cc | 16 ++++++++-------- howdy/src/pam/optional_task.hh | 10 +++++----- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/howdy/src/pam/main.cc b/howdy/src/pam/main.cc index e3e79e2..68501b4 100644 --- a/howdy/src/pam/main.cc +++ b/howdy/src/pam/main.cc @@ -270,8 +270,8 @@ auto identify(pam_handle_t *pamh, int flags, int argc, const char **argv, // NOTE: We should replace mutex and condition_variable by atomic wait, but // it's too recent (C++20) - std::mutex m; - std::condition_variable cv; + std::mutex mutx; + std::condition_variable convar; ConfirmationType confirmation_type(ConfirmationType::Unset); // This task wait for the status of the python subprocess (we don't want a @@ -280,12 +280,12 @@ auto identify(pam_handle_t *pamh, int flags, int argc, const char **argv, int status; wait(&status); { - std::unique_lock lk(m); + std::unique_lock lock(mutx); if (confirmation_type == ConfirmationType::Unset) { confirmation_type = ConfirmationType::Howdy; } } - cv.notify_one(); + convar.notify_one(); return status; }); @@ -297,12 +297,12 @@ auto identify(pam_handle_t *pamh, int flags, int argc, const char **argv, int pam_res = pam_get_authtok( pamh, PAM_AUTHTOK, const_cast(&auth_tok_ptr), nullptr); { - std::unique_lock lk(m); + std::unique_lock lock(mutx); if (confirmation_type == ConfirmationType::Unset) { confirmation_type = ConfirmationType::Pam; } } - cv.notify_one(); + convar.notify_one(); return std::tuple(pam_res, auth_tok_ptr); }); @@ -315,8 +315,8 @@ auto identify(pam_handle_t *pamh, int flags, int argc, const char **argv, // Wait for the end either of the child or the password input { - std::unique_lock lk(m); - cv.wait(lk, [&] { return confirmation_type != ConfirmationType::Unset; }); + std::unique_lock lock(mutx); + convar.wait(lock, [&] { return confirmation_type != ConfirmationType::Unset; }); } // The password has been entered or an error has occurred diff --git a/howdy/src/pam/optional_task.hh b/howdy/src/pam/optional_task.hh index 36f9929..b439628 100644 --- a/howdy/src/pam/optional_task.hh +++ b/howdy/src/pam/optional_task.hh @@ -11,11 +11,11 @@ template class optional_task { std::thread thread; std::packaged_task task; std::future future; - bool spawned; - bool is_active; + bool spawned{false}; + bool is_active{false}; public: - explicit optional_task(std::function fn); + explicit optional_task(std::function func); void activate(); template auto wait(std::chrono::duration dur) -> std::future_status; @@ -25,8 +25,8 @@ public: }; template -optional_task::optional_task(std::function fn) - : task(std::packaged_task(std::move(fn))), future(task.get_future()), +optional_task::optional_task(std::function func) + : task(std::packaged_task(std::move(func))), future(task.get_future()), spawned(false), is_active(false) {} // Create a new thread and launch the task on it.