From: Davin McCall Date: Wed, 7 Aug 2019 11:53:16 +0000 (+1000) Subject: Avoid signed-unsigned comparison warning. X-Git-Tag: v0.7.0~5 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=3e33c17d5d02b65ebfcf86d23219b5cb9cb3a617;p=oweals%2Fdinit.git Avoid signed-unsigned comparison warning. --- diff --git a/src/proc-service.cc b/src/proc-service.cc index 150f34d..9bdc2b3 100644 --- a/src/proc-service.cc +++ b/src/proc-service.cc @@ -1,4 +1,5 @@ #include +#include #include #include @@ -467,6 +468,12 @@ void scripted_service::exec_failed(run_proc_err errcode) noexcept } } +// Return a value as an unsigned-type value. +template typename std::make_unsigned::type make_unsigned_val(T val) +{ + return static_cast::type>(val); +} + bgproc_service::pid_result_t bgproc_service::read_pid_file(bp_sys::exit_status *exit_status) noexcept { @@ -492,7 +499,7 @@ bgproc_service::read_pid_file(bp_sys::exit_status *exit_status) noexcept bool valid_pid = false; try { unsigned long long v = std::stoull(pidbuf, nullptr, 0); - if (v <= std::numeric_limits::max()) { + if (v <= make_unsigned_val(std::numeric_limits::max())) { pid = (pid_t) v; valid_pid = true; }